11// SPDX-License-Identifier: Apache-2.0
22// SPDX-FileCopyrightText: Copyright the Vortex contributors
33
4- //! Proves a filter's zone maps once over a scan's rows, before any chunk is planned.
4+ //! Evaluates a filter's pruning plans once over a scan's rows, before any chunk is planned.
55
66use std:: ops:: Range ;
77use std:: sync:: Arc ;
@@ -31,24 +31,24 @@ use crate::plan::physical::PlanRef;
3131use crate :: plan:: physical:: pipeline:: Scan ;
3232use crate :: plan:: physical:: pipeline:: Split ;
3333
34- /// The planner a prune planner continues into, given the rows the proofs kept, or `None` when
35- /// no proof ran.
34+ /// The planner a prune planner continues into, given the rows pruning kept, or `None` when
35+ /// no pruning plan ran.
3636pub type PruneNext = Box < dyn FnOnce ( Option < Mask > ) -> Box < dyn Planner > + Send > ;
3737
38- /// Runs the filter's zone-map proofs over the scan's rows and emits the planner it was built
39- /// to continue into, with the rows no proof excludes . The zone maps are the only reads,
40- /// started together. Rows every proof excludes end the scan here: nothing is emitted. A filter
41- /// without proofs emits the next planner at once.
38+ /// Evaluates the filter's pruning plans over the scan's rows and emits the planner it was
39+ /// built to continue into, with the rows no plan pruned . The zone maps are the only reads,
40+ /// started together. Rows every plan prunes end the scan here: nothing is emitted. A filter
41+ /// without pruning plans emits the next planner at once.
4242pub struct PrunePlanner {
4343 scan : Arc < PreparedScan > ,
4444 rows : Range < u64 > ,
45- /// What to emit once every proof has run, taken when it is.
45+ /// What to emit once every pruning plan has run, taken when it is.
4646 next : Option < PruneNext > ,
47- /// Whether any proof ran, so the kept rows mean something.
48- proved : bool ,
49- /// The rows no proof has excluded yet, over `rows`.
47+ /// Whether any pruning plan ran, so the kept rows mean something.
48+ pruned : bool ,
49+ /// The rows no pruning plan has excluded yet, over `rows`.
5050 mask : Mask ,
51- proofs : IntoIter < PlanRef > ,
51+ pruning : IntoIter < PlanRef > ,
5252 active : Option < ScanAdaptor > ,
5353 pieces : Vec < Mask > ,
5454 announced : bool ,
@@ -58,21 +58,21 @@ pub struct PrunePlanner {
5858}
5959
6060impl PrunePlanner {
61- /// The planner of the proofs of `scan`'s filter over `rows`, continuing into `next`.
61+ /// The planner of `scan`'s filter's pruning plans over `rows`, continuing into `next`.
6262 pub fn new ( scan : Arc < PreparedScan > , rows : Range < u64 > , next : PruneNext ) -> Self {
63- let proofs : Vec < _ > = scan
63+ let pruning : Vec < _ > = scan
6464 . filter
6565 . iter ( )
66- . flat_map ( |filter| filter. proofs ( ) . cloned ( ) )
66+ . flat_map ( |filter| filter. pruning ( ) . cloned ( ) )
6767 . collect ( ) ;
6868 let len = usize:: try_from ( rows. end - rows. start ) . unwrap_or ( usize:: MAX ) ;
6969 Self {
7070 scan,
7171 rows,
7272 next : Some ( next) ,
73- proved : false ,
73+ pruned : false ,
7474 mask : Mask :: new_true ( len) ,
75- proofs : proofs . into_iter ( ) ,
75+ pruning : pruning . into_iter ( ) ,
7676 active : None ,
7777 pieces : Vec :: new ( ) ,
7878 announced : false ,
@@ -107,11 +107,11 @@ impl Planner for PrunePlanner {
107107 }
108108 if !self . announced {
109109 self . announced = true ;
110- // A proof whose zones an earlier scan of the file proved compiles to its kept
111- // result and lists no segment, so only unproved proofs prefetch their zone maps.
110+ // A pruning plan whose zones an earlier scan of the file pruned compiles to its kept
111+ // result and lists no segment, so only unpruned plans prefetch their zone maps.
112112 let segments = segments_read (
113113 & self . scan . session ,
114- self . proofs . as_slice ( ) . iter ( ) ,
114+ self . pruning . as_slice ( ) . iter ( ) ,
115115 self . rows . clone ( ) ,
116116 & self . mask ,
117117 ) ?;
@@ -149,20 +149,20 @@ impl Planner for PrunePlanner {
149149 row_end = self . rows. end,
150150 input_rows = input,
151151 output_rows = self . mask. true_count( ) ,
152- "v2 zone proof evaluated"
152+ "v2 pruning plan evaluated"
153153 ) ;
154154 self . active = None ;
155155 self . pieces . clear ( ) ;
156- self . proved = true ;
156+ self . pruned = true ;
157157 }
158158 if self . mask . all_false ( ) {
159159 self . done = true ;
160160 return Ok ( PlannerOutput :: Done ) ;
161161 }
162- if let Some ( proof ) = self . proofs . next ( ) {
162+ if let Some ( plan ) = self . pruning . next ( ) {
163163 let scan = Scan :: try_new (
164164 self . scan . session . clone ( ) ,
165- proof ,
165+ plan ,
166166 vec ! [ Split {
167167 rows: self . rows. clone( ) ,
168168 mask: self . mask. clone( ) ,
@@ -173,20 +173,20 @@ impl Planner for PrunePlanner {
173173 self . active = Some ( ScanAdaptor :: new ( scan, Arc :: clone ( & self . scan . locations ) ) ) ;
174174 return Ok ( PlannerOutput :: Continue ) ;
175175 }
176- // Every proof has run: the planner this one continues into gets the kept rows.
176+ // Every pruning plan has run: the planner this one continues into gets the kept rows.
177177 self . done = true ;
178178 tracing:: debug!(
179179 row_start = self . rows. start,
180180 row_end = self . rows. end,
181181 kept_rows = self . mask. true_count( ) ,
182- "v2 zone proofs finished"
182+ "v2 pruning finished"
183183 ) ;
184184 let next = self
185185 . next
186186 . take ( )
187187 . ok_or_else ( || vortex_err ! ( "the prune planner has nothing to continue into" ) ) ?;
188188 let kept = self
189- . proved
189+ . pruned
190190 . then ( || std:: mem:: replace ( & mut self . mask , Mask :: new_true ( 0 ) ) ) ;
191191 Ok ( PlannerOutput :: Planner (
192192 WorkScope {
0 commit comments