org.apache.calcite.linq4j.QueryableDefaults 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.function.BigDecimalFunction1;
import org.apache.calcite.linq4j.function.DoubleFunction1;
import org.apache.calcite.linq4j.function.EqualityComparer;
import org.apache.calcite.linq4j.function.FloatFunction1;
import org.apache.calcite.linq4j.function.Function1;
import org.apache.calcite.linq4j.function.Function2;
import org.apache.calcite.linq4j.function.Functions;
import org.apache.calcite.linq4j.function.IntegerFunction1;
import org.apache.calcite.linq4j.function.LongFunction1;
import org.apache.calcite.linq4j.function.NullableBigDecimalFunction1;
import org.apache.calcite.linq4j.function.NullableDoubleFunction1;
import org.apache.calcite.linq4j.function.NullableFloatFunction1;
import org.apache.calcite.linq4j.function.NullableIntegerFunction1;
import org.apache.calcite.linq4j.function.NullableLongFunction1;
import org.apache.calcite.linq4j.function.Predicate1;
import org.apache.calcite.linq4j.function.Predicate2;
import org.apache.calcite.linq4j.tree.Expression;
import org.apache.calcite.linq4j.tree.Expressions;
import org.apache.calcite.linq4j.tree.FunctionExpression;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.Comparator;
import java.util.Iterator;
/**
* Default implementations for methods in the {@link Queryable} interface.
*/
public abstract class QueryableDefaults {
/**
* Applies an accumulator function over a
* sequence.
*/
public static T aggregate(Queryable queryable,
FunctionExpression> func) {
throw Extensions.todo();
}
/**
* Applies an accumulator function over a
* sequence. The specified seed value is used as the initial
* accumulator value.
*/
public static TAccumulate aggregate(Queryable queryable,
TAccumulate seed,
FunctionExpression> func) {
throw Extensions.todo();
}
/**
* Applies an accumulator function over a
* sequence. The specified seed value is used as the initial
* accumulator value, and the specified function is used to select
* the result value.
*/
public static TResult aggregate(
Queryable queryable, TAccumulate seed,
FunctionExpression> func,
FunctionExpression> selector) {
throw Extensions.todo();
}
/**
* Determines whether all the elements of a sequence
* satisfy a condition.
*/
public static boolean all(Queryable queryable,
FunctionExpression> predicate) {
throw Extensions.todo();
}
/**
* Determines whether a sequence contains any
* elements.
*/
public static void any(Queryable queryable) {
throw Extensions.todo();
}
/**
* Determines whether any element of a sequence
* satisfies a condition.
*/
public static boolean any(Queryable queryable,
FunctionExpression> predicate) {
throw Extensions.todo();
}
/**
* Converts a generic {@code Enumerable} to a generic
* {@code IQueryable}.
*/
public static Queryable asQueryable(Queryable queryable) {
throw Extensions.todo();
}
/**
* Computes the average of a sequence of Decimal
* values that is obtained by invoking a projection function on
* each element of the input sequence.
*/
public static BigDecimal averageBigDecimal(Queryable queryable,
FunctionExpression> selector) {
throw Extensions.todo();
}
/**
* Computes the average of a sequence of nullable
* Decimal values that is obtained by invoking a projection
* function on each element of the input sequence.
*/
public static BigDecimal averageNullableBigDecimal(Queryable queryable,
FunctionExpression> selector) {
throw Extensions.todo();
}
/**
* Computes the average of a sequence of Double
* values that is obtained by invoking a projection function on
* each element of the input sequence.
*/
public static double averageDouble(Queryable queryable,
FunctionExpression> selector) {
throw Extensions.todo();
}
/**
* Computes the average of a sequence of nullable
* Double values that is obtained by invoking a projection
* function on each element of the input sequence.
*/
public static Double averageNullableDouble(Queryable queryable,
FunctionExpression> selector) {
throw Extensions.todo();
}
/**
* Computes the average of a sequence of int values
* that is obtained by invoking a projection function on each
* element of the input sequence.
*/
public static int averageInteger(Queryable queryable,
FunctionExpression> selector) {
throw Extensions.todo();
}
/**
* Computes the average of a sequence of nullable
* int values that is obtained by invoking a projection function
* on each element of the input sequence.
*/
public static Integer averageNullableInteger(Queryable queryable,
FunctionExpression> selector) {
throw Extensions.todo();
}
/**
* Computes the average of a sequence of Float
* values that is obtained by invoking a projection function on
* each element of the input sequence.
*/
public static float averageFloat(Queryable queryable,
FunctionExpression> selector) {
throw Extensions.todo();
}
/**
* Computes the average of a sequence of nullable
* Float values that is obtained by invoking a projection
* function on each element of the input sequence.
*/
public static Float averageNullableFloat(Queryable queryable,
FunctionExpression> selector) {
throw Extensions.todo();
}
/**
* Computes the average of a sequence of long values
* that is obtained by invoking a projection function on each
* element of the input sequence.
*/
public static long averageLong(Queryable queryable,
FunctionExpression> selector) {
throw Extensions.todo();
}
/**
* Computes the average of a sequence of nullable
* long values that is obtained by invoking a projection function
* on each element of the input sequence.
*/
public static Long averageNullableLong(Queryable queryable,
FunctionExpression> selector) {
throw Extensions.todo();
}
/**
* Analogous to LINQ's Enumerable.Cast extension method.
*
* @param clazz Target type
* @param Target type
*
* @return Collection of T2
*/
public static Queryable cast(final Queryable source,
final Class clazz) {
return new BaseQueryable(source.getProvider(), clazz,
source.getExpression()) {
public Enumerator enumerator() {
return new EnumerableDefaults.CastingEnumerator(source.enumerator(),
clazz);
}
};
}
/**
* Concatenates two sequences.
*/
public static Queryable concat(Queryable queryable0,
Enumerable source2) {
throw Extensions.todo();
}
/**
* Determines whether a sequence contains a specified
* element by using the default equality comparer.
*/
public static boolean contains(Queryable queryable, T element) {
throw Extensions.todo();
}
/**
* Determines whether a sequence contains a specified
* element by using a specified {@code EqualityComparer}.
*/
public static boolean contains(Queryable queryable, T element,
EqualityComparer comparer) {
throw Extensions.todo();
}
/**
* Returns the number of elements in a
* sequence.
*/
public static int count(Queryable queryable) {
throw Extensions.todo();
}
/**
* Returns the number of elements in the specified
* sequence that satisfies a condition.
*/
public static int count(Queryable queryable,
FunctionExpression> func) {
throw Extensions.todo();
}
/**
* Returns the elements of the specified sequence or
* the type parameter's default value in a singleton collection if
* the sequence is empty.
*/
public static Queryable defaultIfEmpty(Queryable queryable) {
throw Extensions.todo();
}
/**
* Returns the elements of the specified sequence or
* the specified value in a singleton collection if the sequence
* is empty.
*/
public static T defaultIfEmpty(Queryable queryable, T value) {
throw Extensions.todo();
}
/**
* Returns distinct elements from a sequence by using
* the default equality comparer to compare values.
*/
public static Queryable distinct(Queryable queryable) {
throw Extensions.todo();
}
/**
* Returns distinct elements from a sequence by using
* a specified {@code EqualityComparer} to compare values.
*/
public static Queryable distinct(Queryable queryable,
EqualityComparer comparer) {
throw Extensions.todo();
}
/**
* Returns the element at a specified index in a
* sequence.
*/
public static T elementAt(Queryable queryable, int index) {
throw Extensions.todo();
}
/**
* Returns the element at a specified index in a
* sequence or a default value if the index is out of
* range.
*/
public static T elementAtOrDefault(Queryable queryable, int index) {
throw Extensions.todo();
}
/**
* Produces the set difference of two sequences by
* using the default equality comparer to compare values. (Defined
* by Queryable.)
*/
public static Queryable except(Queryable queryable,
Enumerable enumerable) {
throw Extensions.todo();
}
/**
* Produces the set difference of two sequences by
* using the specified {@code EqualityComparer} to compare
* values.
*/
public static Queryable except(Queryable queryable,
Enumerable enumerable, EqualityComparer comparer) {
throw Extensions.todo();
}
/**
* Returns the first element of a sequence. (Defined
* by Queryable.)
*/
public static T first(Queryable queryable) {
throw Extensions.todo();
}
/**
* Returns the first element of a sequence that
* satisfies a specified condition.
*/
public static T first(Queryable queryable,
FunctionExpression> predicate) {
throw Extensions.todo();
}
/**
* Returns the first element of a sequence, or a
* default value if the sequence contains no elements.
*/
public static T firstOrDefault(Queryable queryable) {
throw Extensions.todo();
}
/**
* Returns the first element of a sequence that
* satisfies a specified condition or a default value if no such
* element is found.
*/
public static T firstOrDefault(Queryable queryable,
FunctionExpression> predicate) {
throw Extensions.todo();
}
/**
* Groups the elements of a sequence according to a
* specified key selector function.
*/
public static Queryable> groupBy(
Queryable queryable,
FunctionExpression> keySelector) {
throw Extensions.todo();
}
/**
* Groups the elements of a sequence according to a
* specified key selector function and compares the keys by using
* a specified comparer.
*/
public static Queryable> groupBy(
Queryable queryable,
FunctionExpression> keySelector,
EqualityComparer comparer) {
throw Extensions.todo();
}
/**
* Groups the elements of a sequence according to a
* specified key selector function and projects the elements for
* each group by using a specified function.
*/
public static Queryable> groupBy(
Queryable queryable,
FunctionExpression> keySelector,
FunctionExpression> elementSelector) {
throw Extensions.todo();
}
/**
* Groups the elements of a sequence according to a
* specified key selector function and creates a result value from
* each group and its key.
*
* NOTE: Renamed from {@code groupBy} to distinguish from
* {@link #groupBy(org.apache.calcite.linq4j.Queryable, org.apache.calcite.linq4j.tree.FunctionExpression, org.apache.calcite.linq4j.tree.FunctionExpression)},
* which has the same erasure.
*/
public static Queryable> groupByK(
Queryable queryable,
FunctionExpression> keySelector,
FunctionExpression, TResult>>
elementSelector) {
throw Extensions.todo();
}
/**
* Groups the elements of a sequence and projects the
* elements for each group by using a specified function. Key
* values are compared by using a specified comparer.
*/
public static Queryable> groupBy(
Queryable queryable,
FunctionExpression> keySelector,
FunctionExpression> elementSelector,
EqualityComparer comparer) {
throw Extensions.todo();
}
/**
* Groups the elements of a sequence according to a
* specified key selector function and creates a result value from
* each group and its key. Keys are compared by using a specified
* comparer.
*
* NOTE: Renamed from {@code groupBy} to distinguish from
* {@link #groupBy(org.apache.calcite.linq4j.Queryable, org.apache.calcite.linq4j.tree.FunctionExpression, org.apache.calcite.linq4j.tree.FunctionExpression, org.apache.calcite.linq4j.function.EqualityComparer)},
* which has the same erasure.
*/
public static Queryable groupByK(
Queryable queryable,
FunctionExpression> keySelector,
FunctionExpression, TResult>>
elementSelector,
EqualityComparer comparer) {
throw Extensions.todo();
}
/**
* Groups the elements of a sequence according to a
* specified key selector function and creates a result value from
* each group and its key. The elements of each group are
* projected by using a specified function.
*/
public static Queryable groupBy(
Queryable queryable,
FunctionExpression> keySelector,
FunctionExpression> elementSelector,
FunctionExpression, TResult>>
resultSelector) {
throw Extensions.todo();
}
/**
* Groups the elements of a sequence according to a
* specified key selector function and creates a result value from
* each group and its key. Keys are compared by using a specified
* comparer and the elements of each group are projected by using
* a specified function.
*/
public static Queryable groupBy(
Queryable queryable,
FunctionExpression> keySelector,
FunctionExpression> elementSelector,
FunctionExpression, TResult>>
resultSelector,
EqualityComparer comparer) {
throw Extensions.todo();
}
/**
* Correlates the elements of two sequences based on
* key equality and groups the results. The default equality
* comparer is used to compare keys.
*/
public static Queryable groupJoin(
Queryable outer, Enumerable inner,
FunctionExpression> outerKeySelector,
FunctionExpression> innerKeySelector,
FunctionExpression, TResult>>
resultSelector) {
throw Extensions.todo();
}
/**
* Correlates the elements of two sequences based on
* key equality and groups the results. A specified
* {@code EqualityComparer} is used to compare keys.
*/
public static Enumerable groupJoin(
Queryable outer, Enumerable inner,
FunctionExpression> outerKeySelector,
FunctionExpression> innerKeySelector,
FunctionExpression, TResult>>
resultSelector,
EqualityComparer comparer) {
throw Extensions.todo();
}
/**
* Produces the set intersection of two sequences by
* using the default equality comparer to compare values. (Defined
* by Queryable.)
*/
public static Queryable intersect(Queryable queryable,
Enumerable enumerable) {
throw Extensions.todo();
}
/**
* Produces the set intersection of two sequences by
* using the specified {@code EqualityComparer} to compare
* values.
*/
public static Queryable intersect(Queryable queryable,
Enumerable enumerable, EqualityComparer comparer) {
throw Extensions.todo();
}
/**
* Correlates the elements of two sequences based on
* matching keys. The default equality comparer is used to compare
* keys.
*/
public static Queryable join(
Queryable outer, Enumerable inner,
FunctionExpression> outerKeySelector,
FunctionExpression> innerKeySelector,
FunctionExpression> resultSelector) {
throw Extensions.todo();
}
/**
* Correlates the elements of two sequences based on
* matching keys. A specified {@code EqualityComparer} is used to
* compare keys.
*/
public static Queryable join(
Queryable outer, Enumerable inner,
FunctionExpression> outerKeySelector,
FunctionExpression> innerKeySelector,
FunctionExpression> resultSelector,
EqualityComparer comparer) {
throw Extensions.todo();
}
/**
* Returns the last element in a sequence. (Defined
* by Queryable.)
*/
public static T last(Queryable queryable) {
throw Extensions.todo();
}
/**
* Returns the last element of a sequence that
* satisfies a specified condition.
*/
public static T last(Queryable queryable,
FunctionExpression> predicate) {
throw Extensions.todo();
}
/**
* Returns the last element in a sequence, or a
* default value if the sequence contains no elements.
*/
public static T lastOrDefault(Queryable queryable) {
throw Extensions.todo();
}
/**
* Returns the last element of a sequence that
* satisfies a condition or a default value if no such element is
* found.
*/
public static T lastOrDefault(Queryable queryable,
FunctionExpression> predicate) {
throw Extensions.todo();
}
/**
* Returns an long that represents the total number
* of elements in a sequence.
*/
public static long longCount(Queryable xable) {
throw Extensions.todo();
}
/**
* Returns an long that represents the number of
* elements in a sequence that satisfy a condition.
*/
public static long longCount(Queryable queryable,
FunctionExpression> predicate) {
throw Extensions.todo();
}
/**
* Returns the maximum value in a generic
* {@code IQueryable}.
*/
public static T max(Queryable queryable) {
throw Extensions.todo();
}
/**
* Invokes a projection function on each element of a
* generic {@code IQueryable} and returns the maximum resulting
* value.
*/
public static TResult max(Queryable queryable,
FunctionExpression> selector) {
throw Extensions.todo();
}
/**
* Returns the minimum value in a generic
* {@code IQueryable}.
*/
public static T min(Queryable queryable) {
throw Extensions.todo();
}
/**
* Invokes a projection function on each element of a
* generic {@code IQueryable} and returns the minimum resulting
* value.
*/
public static TResult min(Queryable queryable,
FunctionExpression> selector) {
throw Extensions.todo();
}
/**
* Filters the elements of an IQueryable based on a
* specified type.
*
* This method generates a
* {@link org.apache.calcite.linq4j.tree.MethodCallExpression} that
* represents calling {@code ofType} itself as a constructed generic method.
* It then passes the {@code MethodCallExpression} to the
* {@link org.apache.calcite.linq4j.QueryProvider#createQuery createQuery}
* method of the
* {@link org.apache.calcite.linq4j.QueryProvider} represented by
* the Provider property of the source parameter.
*
* The query behavior that occurs as a result of executing an expression
* tree that represents calling OfType depends on the implementation of the
* type of the source parameter. The expected behavior is that it filters
* out any elements in source that are not of type TResult.
*
*
NOTE: clazz parameter not present in C# LINQ; necessary because of
* Java type erasure.
*/
public static Queryable ofType(Queryable> queryable,
Class clazz) {
throw Extensions.todo();
}
/**
* Sorts the elements of a sequence in ascending
* order according to a key.
*
* @see #thenBy
*/
public static OrderedQueryable orderBy(
Queryable source, FunctionExpression> keySelector) {
throw Extensions.todo();
}
/**
* Sorts the elements of a sequence in ascending
* order by using a specified comparer.
*/
public static OrderedQueryable orderBy(Queryable source,
FunctionExpression> keySelector,
Comparator comparator) {
throw Extensions.todo();
}
/**
* Sorts the elements of a sequence in descending
* order according to a key.
*/
public static OrderedQueryable orderByDescending(
Queryable source,
FunctionExpression> keySelector) {
throw Extensions.todo();
}
/**
* Sorts the elements of a sequence in descending
* order by using a specified comparer.
*/
public static OrderedQueryable orderByDescending(
Queryable source, FunctionExpression> keySelector,
Comparator comparator) {
throw Extensions.todo();
}
/**
* Inverts the order of the elements in a
* sequence.
*/
public static Queryable reverse(Queryable source) {
throw Extensions.todo();
}
/**
* Projects each element of a sequence into a new form.
*/
public static Queryable select(Queryable source,
FunctionExpression> selector) {
return source.getProvider().createQuery(
Expressions.call(source.getExpression(), "select", selector),
functionResultType(selector));
}
private static