/** Called after the constructor has completed and the model has been * loaded. */ void init() { final MaterializationService service = MaterializationService.instance(); for (CalciteSchema.LatticeEntry e : Schemas.getLatticeEntries(rootSchema)) { final Lattice lattice = e.getLattice(); for (Lattice.Tile tile : lattice.computeTiles()) { service.defineTile(lattice, tile.bitSet(), tile.measures, e.schema, true, true); } } }
/** Called after the constructor has completed and the model has been * loaded. */ void init() { final MaterializationService service = MaterializationService.instance(); for (CalciteSchema.LatticeEntry e : Schemas.getLatticeEntries(rootSchema)) { final Lattice lattice = e.getLattice(); for (Lattice.Tile tile : lattice.computeTiles()) { service.defineTile(lattice, tile.bitSet(), tile.measures, e.schema, true, true); } } }
public Pair<CalciteSchema.TableEntry, TileKey> defineTile(Lattice lattice, ImmutableBitSet groupSet, List<Lattice.Measure> measureList, CalciteSchema schema, boolean create, boolean exact, String suggestedTableName, TableFactory tableFactory) { MaterializationKey materializationKey; final TileKey tileKey = new TileKey(lattice, groupSet, ImmutableList.copyOf(measureList)); // Step 1. Look for an exact match for the tile. materializationKey = actor.keyByTile.get(tileKey); if (materializationKey != null) { final CalciteSchema.TableEntry tableEntry = checkValid(materializationKey); if (tableEntry != null) { return Pair.of(tableEntry, tileKey); } } // Step 2. Look for a match of the tile with the same dimensionality and an // acceptable list of measures. final TileKey tileKey0 = new TileKey(lattice, groupSet, ImmutableList.of()); for (TileKey tileKey1 : actor.tilesByDimensionality.get(tileKey0)) { assert tileKey1.dimensions.equals(groupSet); if (allSatisfiable(measureList, tileKey1)) { materializationKey = actor.keyByTile.get(tileKey1); if (materializationKey != null) { final CalciteSchema.TableEntry tableEntry = checkValid(materializationKey); if (tableEntry != null) {
public Pair<CalciteSchema.TableEntry, TileKey> defineTile(Lattice lattice, ImmutableBitSet groupSet, List<Lattice.Measure> measureList, CalciteSchema schema, boolean create, boolean exact, String suggestedTableName, TableFactory tableFactory) { MaterializationKey materializationKey; final TileKey tileKey = new TileKey(lattice, groupSet, ImmutableList.copyOf(measureList)); // Step 1. Look for an exact match for the tile. materializationKey = actor.keyByTile.get(tileKey); if (materializationKey != null) { final CalciteSchema.TableEntry tableEntry = checkValid(materializationKey); if (tableEntry != null) { return Pair.of(tableEntry, tileKey); } } // Step 2. Look for a match of the tile with the same dimensionality and an // acceptable list of measures. final TileKey tileKey0 = new TileKey(lattice, groupSet, ImmutableList.of()); for (TileKey tileKey1 : actor.tilesByDimensionality.get(tileKey0)) { assert tileKey1.dimensions.equals(groupSet); if (allSatisfiable(measureList, tileKey1)) { materializationKey = actor.keyByTile.get(tileKey1); if (materializationKey != null) { final CalciteSchema.TableEntry tableEntry = checkValid(materializationKey); if (tableEntry != null) {
/** 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); } }
/** 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); } }
service.defineTile(lattice, tile.bitSet(), tile.measures, e.schema, true, true, Util.last(nzTile.tableName), tableFactory);