Package org.apache.calcite.rel.metadata
Class RelMetadataQueryBase
java.lang.Object
org.apache.calcite.rel.metadata.RelMetadataQueryBase
- Direct Known Subclasses:
RelMetadataQuery
Base class for the RelMetadataQuery that uses the metadata handler class
generated by the Janino.
To add a new implementation to this interface, follow these steps:
- Extends
RelMetadataQuery
(name it MyRelMetadataQuery for example) to reuse the Calcite builtin metadata query interfaces. In this class, define all the extended Handlers for your metadata and implement the metadata query interfaces. - Write your customized provider class
RelMdXyz
. Follow the pattern from an existing class such asRelMdColumnOrigins
, overloading on all of the logical relational expressions to which the query applies. - Add a
SOURCE
static member to each of your provider class, similar toRelMdColumnOrigins.SOURCE
. - Extends
DefaultRelMetadataProvider
(name it MyRelMetadataProvider for example) and supplement the "SOURCE"s into the builtin list (This is not required, useChainedRelMetadataProvider
to chain your customized "SOURCE"s with default ones also works). - Set
MyRelMetadataProvider
into the cluster instance. - Use
RelOptCluster.setMetadataQuerySupplier(Supplier)
to set the metadata querySupplier
into the cluster instance. ThisSupplier
should return a fresh new instance. - Use the cluster instance to create
SqlToRelConverter
. - Query your metadata within
RelOptRuleCall
with the interfaces you defined inMyRelMetadataQuery
.
-
Field Summary
Modifier and TypeFieldDescriptionSet of active metadata queries, and cache of previous results.final @Nullable JaninoRelMetadataProvider
Deprecated.static final ThreadLocal<@Nullable JaninoRelMetadataProvider>
-
Constructor Summary
ModifierConstructorDescriptionprotected
RelMetadataQueryBase
(@Nullable JaninoRelMetadataProvider metadataProvider) Deprecated.protected
RelMetadataQueryBase
(@Nullable MetadataHandlerProvider provider) -
Method Summary
Modifier and TypeMethodDescriptionboolean
clearCache
(RelNode rel) Removes cached metadata values for specified RelNode.protected <MH extends MetadataHandler<?>>
MHProvide a handler for the requested metadata class.protected static <H> H
initialHandler
(Class<H> handlerClass) Deprecated.protected <M extends Metadata,
H extends MetadataHandler<M>>
Hrevise
(Class<? extends RelNode> class_, MetadataDef<M> def) Deprecated.protected <H extends MetadataHandler<?>>
HRe-generates the handler for a given kind of metadata, adding support forclass_
if it is not already present.
-
Field Details
-
map
Set of active metadata queries, and cache of previous results. -
metadataProvider
Deprecated. -
THREAD_PROVIDERS
-
-
Constructor Details
-
RelMetadataQueryBase
Deprecated. -
RelMetadataQueryBase
-
-
Method Details
-
initialHandler
Deprecated. -
revise
@Deprecated protected <M extends Metadata,H extends MetadataHandler<M>> H revise(Class<? extends RelNode> class_, MetadataDef<M> def) Deprecated.Re-generates the handler for a given kind of metadata, adding support forclass_
if it is not already present. -
revise
Re-generates the handler for a given kind of metadata, adding support forclass_
if it is not already present. -
handler
Provide a handler for the requested metadata class.- Type Parameters:
MH
- The metadata type the handler relates to.- Parameters:
handlerClass
- The handler interface expected- Returns:
- The handler implementation.
-
clearCache
Removes cached metadata values for specified RelNode.- Parameters:
rel
- RelNode whose cached metadata should be removed- Returns:
- true if cache for the provided RelNode was not empty
-