Package org.apache.calcite.rel.metadata
Class ChainedRelMetadataProvider
- java.lang.Object
-
- org.apache.calcite.rel.metadata.ChainedRelMetadataProvider
-
- All Implemented Interfaces:
RelMetadataProvider
- Direct Known Subclasses:
DefaultRelMetadataProvider
public class ChainedRelMetadataProvider extends java.lang.Object implements RelMetadataProvider
Implementation of theRelMetadataProvider
interface via theGlossary.CHAIN_OF_RESPONSIBILITY_PATTERN
.When a consumer calls the
apply(java.lang.Class<? extends org.apache.calcite.rel.RelNode>, java.lang.Class<? extends M>)
method to ask for a provider for a particular type ofRelNode
andMetadata
, scans the list of underlying providers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ChainedRelMetadataProvider.ChainedInvocationHandler
Invocation handler that calls a list ofMetadata
objects, returning the first non-null value.
-
Field Summary
Fields Modifier and Type Field Description private com.google.common.collect.ImmutableList<RelMetadataProvider>
providers
-
Constructor Summary
Constructors Modifier Constructor Description protected
ChainedRelMetadataProvider(com.google.common.collect.ImmutableList<RelMetadataProvider> providers)
Creates a chain.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <M extends Metadata>
UnboundMetadata<M>apply(java.lang.Class<? extends RelNode> relClass, java.lang.Class<? extends M> metadataClass)
Retrieves metadata of a particular type and for a particular sub-class of relational expression.boolean
equals(java.lang.Object obj)
<M extends Metadata>
com.google.common.collect.Multimap<java.lang.reflect.Method,MetadataHandler<M>>handlers(MetadataDef<M> def)
int
hashCode()
static RelMetadataProvider
of(java.util.List<RelMetadataProvider> list)
Creates a chain.
-
-
-
Field Detail
-
providers
private final com.google.common.collect.ImmutableList<RelMetadataProvider> providers
-
-
Constructor Detail
-
ChainedRelMetadataProvider
protected ChainedRelMetadataProvider(com.google.common.collect.ImmutableList<RelMetadataProvider> providers)
Creates a chain.
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
apply
public <M extends Metadata> UnboundMetadata<M> apply(java.lang.Class<? extends RelNode> relClass, java.lang.Class<? extends M> metadataClass)
Description copied from interface:RelMetadataProvider
Retrieves metadata of a particular type and for a particular sub-class of relational expression.The object returned is a function. It can be applied to a relational expression of the given type to create a metadata object.
For example, you might call
RelMetadataProvider provider; LogicalFilter filter; RexNode predicate; Function<RelNode, Metadata> function = provider.apply(LogicalFilter.class, Selectivity.class}; Selectivity selectivity = function.apply(filter); Double d = selectivity.selectivity(predicate);
- Specified by:
apply
in interfaceRelMetadataProvider
- Parameters:
relClass
- Type of relational expressionmetadataClass
- Type of metadata- Returns:
- Function that will field a metadata instance; or null if this provider cannot supply metadata of this type
-
handlers
public <M extends Metadata> com.google.common.collect.Multimap<java.lang.reflect.Method,MetadataHandler<M>> handlers(MetadataDef<M> def)
- Specified by:
handlers
in interfaceRelMetadataProvider
-
of
public static RelMetadataProvider of(java.util.List<RelMetadataProvider> list)
Creates a chain.
-
-