public static double estimateSelectivity ( final String dimension , final BitmapIndexSelector indexSelector , final Predicate < String > predicate ) { Preconditions . checkNotNull ( dimension , "dimension" ) ; Preconditions . checkNotNull ( indexSelector , "selector" ) ; Preconditions . checkNotNull ( predicate , "predicate" ) ; // Missing dimension -> match all rows if the predicate matches null; match no rows otherwise try ( final CloseableIndexed < String > dimValues = indexSelector . getDimensionValues ( dimension ) ) { if ( dimValues == null || dimValues . size ( ) == 0 ) { return predicate . apply ( null ) ? 1. : 0. ; } // Apply predicate to all dimension values and union the matching bitmaps final BitmapIndex bitmapIndex = indexSelector . getBitmapIndex ( dimension ) ; return estimateSelectivity ( bitmapIndex , IntIteratorUtils . toIntList ( makePredicateQualifyingIndexIterable ( bitmapIndex , predicate , dimValues ) . iterator ( ) ) , indexSelector . getNumRows ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } }
Return an estimated selectivity for bitmaps of all values matching the given predicate .