com.hazelcast.org.apache.calcite.rel.metadata.RelMetadataProvider Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hazelcast.org.apache.calcite.rel.metadata;
import com.hazelcast.org.apache.calcite.rel.RelNode;
import com.hazelcast.com.google.common.collect.Multimap;
import java.lang.reflect.Method;
/**
* RelMetadataProvider defines an interface for obtaining metadata about
* relational expressions. This interface is weakly-typed and is not intended to
* be called directly in most contexts; instead, use a strongly-typed facade
* such as {@link RelMetadataQuery}.
*
* For background and motivation, see wiki.
*
*
If your provider is not a singleton, we recommend that you implement
* {@link Object#equals(Object)} and {@link Object#hashCode()} methods. This
* makes the cache of {@link JaninoRelMetadataProvider} more effective.
*/
public interface RelMetadataProvider {
//~ Methods ----------------------------------------------------------------
/**
* 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);
*
*
* @param relClass Type of relational expression
* @param metadataClass Type of metadata
* @return Function that will field a metadata instance; or null if this
* provider cannot supply metadata of this type
*/
UnboundMetadata apply(
Class extends RelNode> relClass, Class extends M> metadataClass);
Multimap> handlers(
MetadataDef def);
}