org.apache.calcite.linq4j.QueryProvider 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 org.apache.calcite.linq4j;
import org.apache.calcite.linq4j.tree.Expression;
import java.lang.reflect.Type;
/**
* Defines methods to create and execute queries that are described by a
* {@link Queryable} object.
*
* Analogous to LINQ's System.Linq.QueryProvider.
*/
public interface QueryProvider {
/**
* Constructs a {@link Queryable} object that can evaluate the query
* represented by a specified expression tree.
*
* NOTE: The {@link org.apache.calcite.linq4j.Queryable#getExpression()}
* property of the returned {@link Queryable} object is equal to
* {@code expression}.
*
* @param expression Expression
* @param rowType Row type
* @param Row type
*
* @return Queryable
*/
Queryable createQuery(Expression expression, Class rowType);
/**
* Constructs a {@link Queryable} object that can evaluate the query
* represented by a specified expression tree. The row type may contain
* generic information.
*
* @param expression Expression
* @param rowType Row type
* @param Row type
*
* @return Queryable
*/
Queryable createQuery(Expression expression, Type rowType);
/**
* Executes the query represented by a specified expression tree.
*
* This method executes queries that return a single value
* (instead of an enumerable sequence of values). Expression trees that
* represent queries that return enumerable results are executed when the
* {@link Queryable} object that contains the expression tree is
* enumerated.
*
* The Queryable standard query operator methods that return singleton
* results call {@code execute}. They pass it a
* {@link org.apache.calcite.linq4j.tree.MethodCallExpression}
* that represents a linq4j query.
*/
T execute(Expression expression, Class type);
/**
* Executes the query represented by a specified expression tree.
* The row type may contain type parameters.
*/
T execute(Expression expression, Type type);
/**
* Executes a queryable, and returns an enumerator over the
* rows that it yields.
*
* @param queryable Queryable
*
* @return Enumerator over rows
*/
Enumerator executeQuery(Queryable queryable);
}