@@ -387,28 +387,6 @@ impl GlobalIndexScanner {
387387 & self ,
388388 entries : & [ & GlobalIndexEntry ] ,
389389 predicates : & [ ( PredicateOperator , & [ Datum ] , & DataType ) ] ,
390- ) -> Result < Option < ( Vec < RowRange > , Vec < RowRange > , bool ) > > {
391- // A bitmap answers floating ranges and negations with every non-null
392- // row (see `bitmap_meta_may_match`), so those results are candidates
393- // only. Sorted indexes answer them exactly.
394- // An all-NULL bitmap shard is pruned before it answers anything.
395- let bitmap_superset = entries. iter ( ) . any ( |entry| {
396- matches ! ( entry. index_type, GlobalIndexFileKind :: Bitmap )
397- && !sorted_entry_meta ( entry) . only_nulls ( )
398- } ) && predicates. iter ( ) . any ( |( op, _, data_type) | {
399- is_floating_point ( data_type) && is_bitmap_floating_residual_sensitive_op ( * op)
400- } ) ;
401- Ok ( self . evaluate_leaf_entries ( entries, predicates) . await ?. map (
402- |( row_ranges, coverage, fully_evaluated) | {
403- ( row_ranges, coverage, fully_evaluated && !bitmap_superset)
404- } ,
405- ) )
406- }
407-
408- async fn evaluate_leaf_entries (
409- & self ,
410- entries : & [ & GlobalIndexEntry ] ,
411- predicates : & [ ( PredicateOperator , & [ Datum ] , & DataType ) ] ,
412390 ) -> Result < Option < ( Vec < RowRange > , Vec < RowRange > , bool ) > > {
413391 let Some ( normalized_predicates) = predicates
414392 . iter ( )
@@ -614,6 +592,14 @@ impl GlobalIndexScanner {
614592 )
615593 } ) ;
616594
595+ // A bitmap answers floating ranges and negations with every non-null
596+ // row (see `bitmap_meta_may_match`), so its results are candidates
597+ // only. Sorted indexes answer them exactly. Only bitmap shards that
598+ // survive pruning by every conjunct below contribute rows.
599+ let bitmap_superset_ops = predicates. iter ( ) . any ( |( op, _, data_type) | {
600+ is_floating_point ( data_type) && is_bitmap_floating_residual_sensitive_op ( * op)
601+ } ) ;
602+ let mut bitmap_retained = false ;
617603 let mut query_plans = Vec :: with_capacity ( entries. len ( ) ) ;
618604 let mut all_matching_ranges = Vec :: new ( ) ;
619605 let mut fully_evaluated = true ;
@@ -623,6 +609,7 @@ impl GlobalIndexScanner {
623609 . iter ( )
624610 . all ( |matches| matches[ entry_idx] )
625611 {
612+ bitmap_retained |= matches ! ( entry. index_type, GlobalIndexFileKind :: Bitmap ) ;
626613 all_matching_ranges. push ( RowRange :: new ( entry. row_range_start , entry. row_range_end ) ) ;
627614 continue ;
628615 }
@@ -693,9 +680,11 @@ impl GlobalIndexScanner {
693680 // Only a proven identity remains (other conjuncts may have
694681 // declined their budget). Preserve its indexed domain and
695682 // leave the residual filter to the ordinary table reader.
683+ bitmap_retained |= matches ! ( entry. index_type, GlobalIndexFileKind :: Bitmap ) ;
696684 all_matching_ranges. push ( RowRange :: new ( entry. row_range_start , entry. row_range_end ) ) ;
697685 continue ;
698686 }
687+ bitmap_retained |= matches ! ( entry. index_type, GlobalIndexFileKind :: Bitmap ) ;
699688 query_plans. push ( EntryQueryPlan {
700689 entry_idx,
701690 between_matches,
@@ -771,7 +760,7 @@ impl GlobalIndexScanner {
771760 Ok ( Some ( (
772761 crate :: table:: merge_row_ranges ( all_ranges) ,
773762 coverage ( ) ,
774- fully_evaluated,
763+ fully_evaluated && ! ( bitmap_retained && bitmap_superset_ops ) ,
775764 ) ) )
776765 }
777766
0 commit comments