33
44use std:: sync:: Arc ;
55
6+ use vortex_compute:: filter:: Filter ;
67use vortex_error:: { VortexResult , vortex_panic} ;
78use vortex_mask:: Mask ;
8- use vortex_vector:: { Vector , VectorOps , vector_matches_dtype} ;
9+ use vortex_vector:: { Vector , vector_matches_dtype} ;
910
1011use crate :: execution:: { BatchKernelRef , BindCtx , DummyExecutionCtx , ExecutionCtx } ;
1112use crate :: pipeline:: PipelinedNode ;
@@ -24,7 +25,7 @@ pub trait ArrayOperator: 'static + Send + Sync {
2425 ///
2526 /// If the mask length does not match the array length.
2627 /// If the array's implementation returns an invalid vector (wrong length, wrong type, etc.).
27- fn execute_batch ( & self , selection : & Mask , ctx : & mut dyn ExecutionCtx ) -> VortexResult < Vector > ;
28+ fn execute_batch ( & self , ctx : & mut dyn ExecutionCtx ) -> VortexResult < Vector > ;
2829
2930 /// Returns the array as a pipeline node, if supported.
3031 fn as_pipelined ( & self ) -> Option < & dyn PipelinedNode > ;
@@ -38,8 +39,8 @@ pub trait ArrayOperator: 'static + Send + Sync {
3839}
3940
4041impl ArrayOperator for Arc < dyn Array > {
41- fn execute_batch ( & self , selection : & Mask , ctx : & mut dyn ExecutionCtx ) -> VortexResult < Vector > {
42- self . as_ref ( ) . execute_batch ( selection , ctx)
42+ fn execute_batch ( & self , ctx : & mut dyn ExecutionCtx ) -> VortexResult < Vector > {
43+ self . as_ref ( ) . execute_batch ( ctx)
4344 }
4445
4546 fn as_pipelined ( & self ) -> Option < & dyn PipelinedNode > {
@@ -56,17 +57,8 @@ impl ArrayOperator for Arc<dyn Array> {
5657}
5758
5859impl < V : VTable > ArrayOperator for ArrayAdapter < V > {
59- fn execute_batch ( & self , selection : & Mask , ctx : & mut dyn ExecutionCtx ) -> VortexResult < Vector > {
60- let vector =
61- <V :: OperatorVTable as OperatorVTable < V > >:: execute_batch ( & self . 0 , selection, ctx) ?;
62-
63- // Such a cheap check that we run it always. More expensive DType checks live in
64- // debug_assertions.
65- assert_eq ! (
66- vector. len( ) ,
67- selection. true_count( ) ,
68- "Batch execution returned vector of incorrect length"
69- ) ;
60+ fn execute_batch ( & self , ctx : & mut dyn ExecutionCtx ) -> VortexResult < Vector > {
61+ let vector = V :: execute ( & self . 0 , ctx) ?;
7062
7163 if cfg ! ( debug_assertions) {
7264 // Checks for correct type and nullability.
@@ -108,17 +100,20 @@ impl BindCtx for () {
108100
109101impl dyn Array + ' _ {
110102 pub fn execute ( & self ) -> VortexResult < Vector > {
111- self . execute_with_selection ( & Mask :: new_true ( self . len ( ) ) )
103+ // Check if the array is a pipeline node
104+ if self . as_pipelined ( ) . is_some ( ) {
105+ return PipelineDriver :: new ( self . to_array ( ) ) . execute ( & Mask :: new_true ( self . len ( ) ) ) ;
106+ }
107+ self . execute_batch ( & mut DummyExecutionCtx )
112108 }
113109
114110 pub fn execute_with_selection ( & self , selection : & Mask ) -> VortexResult < Vector > {
115- assert_eq ! ( self . len( ) , selection. len( ) ) ;
116-
117111 // Check if the array is a pipeline node
118112 if self . as_pipelined ( ) . is_some ( ) {
119113 return PipelineDriver :: new ( self . to_array ( ) ) . execute ( selection) ;
120114 }
121-
122- self . execute_batch ( selection, & mut DummyExecutionCtx )
115+ Ok ( self
116+ . execute_batch ( & mut DummyExecutionCtx ) ?
117+ . filter ( selection) )
123118 }
124119}
0 commit comments