public class ReflectiveRelMetadataProvider extends Object implements RelMetadataProvider, ReflectiveVisitor
RelMetadataProvider interface that dispatches
metadata methods to methods on a given object via reflection.
The methods on the target object must be public and non-static, and have
the same signature as the implemented metadata method except for an
additional first parameter of type RelNode or a sub-class. That
parameter gives this provider an indication of that relational expressions it
can handle.
For an example, see RelMdColumnOrigins.SOURCE.
| Modifier | Constructor and Description |
|---|---|
protected |
ReflectiveRelMetadataProvider(Map<Class<RelNode>,com.google.common.base.Function<RelNode,Metadata>> map,
Class<?> metadataClass0)
Creates a ReflectiveRelMetadataProvider.
|
| Modifier and Type | Method and Description |
|---|---|
com.google.common.base.Function<RelNode,Metadata> |
apply(Class<? extends RelNode> relClass,
Class<? extends Metadata> metadataClass)
Retrieves metadata of a particular type and for a particular sub-class
of relational expression.
|
static RelMetadataProvider |
reflectiveSource(Method method,
Object target)
Returns an implementation of
RelMetadataProvider that scans for
methods with a preceding argument. |
static RelMetadataProvider |
reflectiveSource(Object target,
Method... methods)
Returns a reflective metadata provider that implements several
methods.
|
public static RelMetadataProvider reflectiveSource(Method method, Object target)
RelMetadataProvider that scans for
methods with a preceding argument.
For example, BuiltInMetadata.Selectivity has a method
BuiltInMetadata.Selectivity.getSelectivity(org.apache.calcite.rex.RexNode).
A class
class RelMdSelectivity { public Double getSelectivity(Union rel, RexNode predicate) { } public Double getSelectivity(Filter rel, RexNode predicate) { }
provides implementations of selectivity for relational expressions
that extend Union
or Filter.
public static RelMetadataProvider reflectiveSource(Object target, Method... methods)
public com.google.common.base.Function<RelNode,Metadata> apply(Class<? extends RelNode> relClass, Class<? extends Metadata> metadataClass)
RelMetadataProviderThe 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);
apply in interface RelMetadataProviderrelClass - Type of relational expressionmetadataClass - Type of metadataCopyright © 2012–2015 The Apache Software Foundation. All rights reserved.