Package org.apache.calcite.materialize
Class MaterializationService
java.lang.Object
org.apache.calcite.materialize.MaterializationService
Manages the collection of materialized tables known to the system,
and the process by which they become valid and invalid.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Default implementation ofMaterializationService.TableFactory
.static interface
Creates tables that represent a materialized view. -
Method Summary
Modifier and TypeMethodDescription@Nullable CalciteSchema.TableEntry
Checks whether a materialization is valid, and if so, returns the table where the data are stored.void
clear()
De-registers all materialized tables in the system.@Nullable MaterializationKey
defineMaterialization
(CalciteSchema schema, @Nullable TileKey tileKey, String viewSql, @Nullable List<String> viewSchemaPath, @Nullable String suggestedTableName, boolean create, boolean existing) Defines a new materialization.@Nullable MaterializationKey
defineMaterialization
(CalciteSchema schema, @Nullable TileKey tileKey, String viewSql, @Nullable List<String> viewSchemaPath, @Nullable String suggestedTableName, MaterializationService.TableFactory tableFactory, boolean create, boolean existing) Defines a new materialization.@Nullable Pair<CalciteSchema.TableEntry,
TileKey> defineTile
(Lattice lattice, ImmutableBitSet groupSet, List<Lattice.Measure> measureList, CalciteSchema schema, boolean create, boolean exact) Defines a tile.@Nullable Pair<CalciteSchema.TableEntry,
TileKey> defineTile
(Lattice lattice, ImmutableBitSet groupSet, List<Lattice.Measure> measureList, CalciteSchema schema, boolean create, boolean exact, String suggestedTableName, MaterializationService.TableFactory tableFactory) static MaterializationService
instance()
Returns the instance of the materialization service.query
(CalciteSchema rootSchema) Gathers a list of all materialized tables known within a given root schema.void
static void
Used by tests, to ensure that they see their own service.
-
Method Details
-
defineMaterialization
public @Nullable MaterializationKey defineMaterialization(CalciteSchema schema, @Nullable TileKey tileKey, String viewSql, @Nullable List<String> viewSchemaPath, @Nullable String suggestedTableName, boolean create, boolean existing) Defines a new materialization. Returns its key. -
defineMaterialization
public @Nullable MaterializationKey defineMaterialization(CalciteSchema schema, @Nullable TileKey tileKey, String viewSql, @Nullable List<String> viewSchemaPath, @Nullable String suggestedTableName, MaterializationService.TableFactory tableFactory, boolean create, boolean existing) Defines a new materialization. Returns its key. -
checkValid
Checks whether a materialization is valid, and if so, returns the table where the data are stored. -
defineTile
public @Nullable Pair<CalciteSchema.TableEntry,TileKey> defineTile(Lattice lattice, ImmutableBitSet groupSet, List<Lattice.Measure> measureList, CalciteSchema schema, boolean create, boolean exact) Defines a tile.Setting the
create
flag to false prevents a materialization from being created if one does not exist. Critically, it is set to false during the recursive SQL that populates a materialization. Otherwise a materialization would try to create itself to populate itself! -
defineTile
public @Nullable Pair<CalciteSchema.TableEntry,TileKey> defineTile(Lattice lattice, ImmutableBitSet groupSet, List<Lattice.Measure> measureList, CalciteSchema schema, boolean create, boolean exact, String suggestedTableName, MaterializationService.TableFactory tableFactory) -
query
Gathers a list of all materialized tables known within a given root schema. (Each root schema defines a disconnected namespace, with no overlap with the current schema. Especially in a test run, the contents of two root schemas may look similar.) -
clear
public void clear()De-registers all materialized tables in the system. -
setThreadLocal
public static void setThreadLocal()Used by tests, to ensure that they see their own service. -
instance
Returns the instance of the materialization service. Usually the global one, but returns a thread-local one during testing (whensetThreadLocal()
has been called by the current thread). -
removeMaterialization
-