Search in sources :

Example 1 with MaterializationService

use of org.apache.calcite.materialize.MaterializationService in project calcite by apache.

the class RelOptLattice method getAggregate.

/**
 * Retrieves a materialized table that will satisfy an aggregate query on
 * the star table.
 *
 * <p>The current implementation creates a materialization and populates it,
 * provided that {@link Lattice#auto} is true.
 *
 * <p>Future implementations might return materializations at a different
 * level of aggregation, from which the desired result can be obtained by
 * rolling up.
 *
 * @param planner Current planner
 * @param groupSet Grouping key
 * @param measureList Calls to aggregate functions
 * @return Materialized table
 */
public Pair<CalciteSchema.TableEntry, TileKey> getAggregate(RelOptPlanner planner, ImmutableBitSet groupSet, List<Lattice.Measure> measureList) {
    final CalciteConnectionConfig config = planner.getContext().unwrap(CalciteConnectionConfig.class);
    if (config == null) {
        return null;
    }
    final MaterializationService service = MaterializationService.instance();
    boolean create = lattice.auto && config.createMaterializations();
    final CalciteSchema schema = starRelOptTable.unwrap(CalciteSchema.class);
    return service.defineTile(lattice, groupSet, measureList, schema, create, false);
}
Also used : CalciteConnectionConfig(org.apache.calcite.config.CalciteConnectionConfig) CalciteSchema(org.apache.calcite.jdbc.CalciteSchema) MaterializationService(org.apache.calcite.materialize.MaterializationService)

Aggregations

CalciteConnectionConfig (org.apache.calcite.config.CalciteConnectionConfig)1 CalciteSchema (org.apache.calcite.jdbc.CalciteSchema)1 MaterializationService (org.apache.calcite.materialize.MaterializationService)1