@@ -2,8 +2,6 @@ use std::any::Any;
22use std:: fmt:: { Debug , Display } ;
33use std:: sync:: Arc ;
44
5- use vortex_array:: aliases:: hash_set:: HashSet ;
6-
75mod binary;
86mod column;
97pub mod datafusion;
@@ -16,6 +14,8 @@ mod project;
1614pub mod pruning;
1715mod row_filter;
1816mod select;
17+ #[ allow( dead_code) ]
18+ mod traversal;
1919
2020pub use binary:: * ;
2121pub use column:: * ;
@@ -27,9 +27,12 @@ pub use operators::*;
2727pub use project:: * ;
2828pub use row_filter:: * ;
2929pub use select:: * ;
30+ use vortex_array:: aliases:: hash_set:: HashSet ;
3031use vortex_array:: ArrayData ;
3132use vortex_dtype:: Field ;
32- use vortex_error:: VortexResult ;
33+ use vortex_error:: { VortexResult , VortexUnwrap } ;
34+
35+ use crate :: traversal:: { Node , ReferenceCollector } ;
3336
3437pub type ExprRef = Arc < dyn VortexExpr > ;
3538
@@ -41,14 +44,22 @@ pub trait VortexExpr: Debug + Send + Sync + DynEq + Display {
4144 /// Compute result of expression on given batch producing a new batch
4245 fn evaluate ( & self , batch : & ArrayData ) -> VortexResult < ArrayData > ;
4346
44- /// Accumulate all field references from this expression and its children in the provided set
45- fn collect_references < ' a > ( & ' a self , _references : & mut HashSet < & ' a Field > ) { }
47+ fn children ( & self ) -> Vec < & ExprRef > ;
48+
49+ fn replacing_children ( self : Arc < Self > , children : Vec < ExprRef > ) -> ExprRef ;
50+ }
51+
52+ pub trait VortexExprExt {
53+ /// Accumulate all field references from this expression and its children in a set
54+ fn references ( & self ) -> HashSet < & Field > ;
55+ }
4656
47- /// Accumulate all field references from this expression and its children in a new set
57+ impl VortexExprExt for ExprRef {
4858 fn references ( & self ) -> HashSet < & Field > {
49- let mut refs = HashSet :: new ( ) ;
50- self . collect_references ( & mut refs) ;
51- refs
59+ let mut collector = ReferenceCollector :: new ( ) ;
60+ // The collector is infallible, so we can unwrap the result
61+ self . accept ( & mut collector) . vortex_unwrap ( ) ;
62+ collector. into_fields ( )
5263 }
5364}
5465
0 commit comments