Class ComposedBitmapIndexAggregate


  • @API(EXPERIMENTAL)
    public class ComposedBitmapIndexAggregate
    extends Object
    Transform a tree of Boolean expressions into a tree of bitwise operations on streams of bitmaps from multiple IndexTypes.BITMAP_VALUE indexes with common group and position keys. So, AND turns into BITAND and OR into BITOR, with the leaves of the streams being scans of a BITMAP_VALUE index keyed by the leaf condition. Optional additional grouping predicates for all indexes are also preserved. This means dividing a set of conditions into three categories:
    1. group predicates common to all indexes
    2. group predicates for a single bitmap index
    3. position predicates applied to every scan
    Each of the second set of group predicates is turned into a single bitmap index scan by prepending the common group and appending the common position. These scans yield bitmaps with one bits for each unique position matching that single predicate. Applying bit operations on these bitmaps corresponding to the complex Boolean expression on the original predicates gives bitmaps with one bits for positions satisfying that complex condition.
    • Method Detail

      • tryPlan

        @Nonnull
        public static Optional<RecordQueryPlan> tryPlan​(@Nonnull
                                                        RecordQueryPlanner planner,
                                                        @Nonnull
                                                        RecordQuery query,
                                                        @Nonnull
                                                        IndexAggregateFunctionCall indexAggregateFunctionCall)
        Try to build a composed bitmap plan for the given query and aggregate function call.
        Parameters:
        planner - a query planner to use to construct the plans
        query - a query providing target record type, filter, and required fields
        indexAggregateFunctionCall - the function call giving the desired position and grouping
        Returns:
        an Optional query plan or Optional.empty if planning is not possible
      • tryPlan

        @Nonnull
        public Optional<RecordQueryPlan> tryPlan​(@Nonnull
                                                 RecordQueryPlanner planner,
                                                 @Nonnull
                                                 RecordQuery.Builder queryBuilder)
        Try to turn this composed bitmap into an executable plan.
        Parameters:
        planner - a query planner to use to construct the plans
        queryBuilder - a prototype query providing target record types and required fields
        Returns:
        an Optional query plan or Optional.empty if planning is not possible
      • tryBuild

        @Nonnull
        public static Optional<ComposedBitmapIndexAggregate> tryBuild​(@Nonnull
                                                                      QueryPlanner planner,
                                                                      @Nonnull
                                                                      Collection<String> recordTypeNames,
                                                                      @Nonnull
                                                                      IndexAggregateFunctionCall indexAggregateFunctionCall,
                                                                      @Nonnull
                                                                      QueryComponent filter)
        Try to build a composed bitmap for the given aggregate function and filters.

        The function should use a supported aggregate function (currently "bitmap_value") and the bitmap-indexed position field grouped by any common fields. The filter should supply equality conditions to the common fields. The filter can include additional equality conditions on various other fields for which there are appropriate bitmap indexes, in a Boolean expression that will be transformed into a set the corresponding bit operations on the bitmaps. The filter can also include range conditions on the position field.

        Parameters:
        planner - a query planner to use to construct the plans
        recordTypeNames - the record types on which the indexes are defined
        indexAggregateFunctionCall - the function giving the desired position and grouping
        filter - conditions on the groups and position
        Returns:
        an Optional composed bitmap or Optional.empty if there conditions could not be satisfied