11use crate :: common:: {
2- properties:: { attr_ref:: GroupAttrRefs , schema:: Schema , Attribute } ,
2+ properties:: {
3+ attr_ref:: { AttrRef , GroupAttrRefs } ,
4+ schema:: Schema ,
5+ Attribute ,
6+ } ,
37 types:: GroupId ,
48} ;
59
@@ -13,10 +17,12 @@ use crate::common::{
1317pub trait MemoExt : Send + Sync + ' static {
1418 /// Get the schema of a group in the memo.
1519 fn get_schema ( & self , group_id : GroupId ) -> Schema ;
16- /// Get the attribute reference of a group in the memo.
17- fn get_attribute_ref ( & self , group_id : GroupId ) -> GroupAttrRefs ;
18- /// Get the attribute information of a given attribute in a group in the memo.
20+ /// Get the attribute info of a given attribute in a group in the memo.
1921 fn get_attribute_info ( & self , group_id : GroupId , attr_ref_idx : u64 ) -> Attribute ;
22+ /// Get the attribute reference of a group in the memo.
23+ fn get_attribute_refs ( & self , group_id : GroupId ) -> GroupAttrRefs ;
24+ /// Get the attribute reference of a given attribute in a group in the memo.
25+ fn get_attribute_ref ( & self , group_id : GroupId , attr_ref_idx : u64 ) -> AttrRef ;
2026
2127 // TODO: Figure out what other information is needed to compute the cost...
2228}
@@ -26,18 +32,22 @@ pub mod tests {
2632 use std:: collections:: HashMap ;
2733
2834 use crate :: common:: {
29- properties:: { attr_ref:: GroupAttrRefs , schema:: Schema , Attribute } ,
35+ properties:: {
36+ attr_ref:: { AttrRef , GroupAttrRefs } ,
37+ schema:: Schema ,
38+ Attribute ,
39+ } ,
3040 types:: GroupId ,
3141 } ;
3242
3343 pub struct MemoGroupInfo {
3444 pub schema : Schema ,
35- pub attr_ref : GroupAttrRefs ,
45+ pub attr_refs : GroupAttrRefs ,
3646 }
3747
3848 impl MemoGroupInfo {
39- pub fn new ( schema : Schema , attr_ref : GroupAttrRefs ) -> Self {
40- Self { schema, attr_ref }
49+ pub fn new ( schema : Schema , attr_refs : GroupAttrRefs ) -> Self {
50+ Self { schema, attr_refs }
4151 }
4252 }
4353
@@ -63,13 +73,17 @@ pub mod tests {
6373 self . memo . get ( & group_id) . unwrap ( ) . schema . clone ( )
6474 }
6575
66- fn get_attribute_ref ( & self , group_id : GroupId ) -> GroupAttrRefs {
67- self . memo . get ( & group_id) . unwrap ( ) . attr_ref . clone ( )
68- }
69-
7076 fn get_attribute_info ( & self , group_id : GroupId , attr_ref_idx : u64 ) -> Attribute {
7177 self . memo . get ( & group_id) . unwrap ( ) . schema . attributes [ attr_ref_idx as usize ] . clone ( )
7278 }
79+
80+ fn get_attribute_refs ( & self , group_id : GroupId ) -> GroupAttrRefs {
81+ self . memo . get ( & group_id) . unwrap ( ) . attr_refs . clone ( )
82+ }
83+
84+ fn get_attribute_ref ( & self , group_id : GroupId , attr_ref_idx : u64 ) -> AttrRef {
85+ self . memo . get ( & group_id) . unwrap ( ) . attr_refs . attr_refs ( ) [ attr_ref_idx as usize ] . clone ( )
86+ }
7387 }
7488
7589 impl From < HashMap < GroupId , MemoGroupInfo > > for MockMemoExtImpl {
0 commit comments