All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.calcite.linq4j.ExtendedQueryable Maven / Gradle / Ivy

There is a newer version: 1.38.0
Show newest version
/*
 * 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.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.FunctionExpression;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.Covariant;

import java.math.BigDecimal;
import java.util.Comparator;

/**
 * Extension methods in Queryable.
 *
 * @param  Element type
 */
@Covariant(0)
interface ExtendedQueryable extends ExtendedEnumerable {

  /**
   * Applies an accumulator function over a sequence.
   */
  @Nullable TSource aggregate(
      FunctionExpression> selector);

  /**
   * Applies an accumulator function over a
   * sequence. The specified seed value is used as the initial
   * accumulator value.
   */
   TAccumulate aggregate(TAccumulate seed,
      FunctionExpression>
        selector);

  /**
   * 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.
   */
   TResult aggregate(TAccumulate seed,
      FunctionExpression> func,
      FunctionExpression> selector);

  /**
   * Determines whether all the elements of a sequence
   * satisfy a condition.
   */
  boolean all(FunctionExpression> predicate);

  /**
   * Determines whether any element of a sequence
   * satisfies a condition.
   */
  boolean any(FunctionExpression> predicate);

  /**
   * Computes the average of a sequence of Decimal
   * values that is obtained by invoking a projection function on
   * each element of the input sequence.
   */
  BigDecimal averageBigDecimal(
      FunctionExpression> selector);

  /**
   * 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.
   */
  BigDecimal averageNullableBigDecimal(
      FunctionExpression> selector);

  /**
   * Computes the average of a sequence of Double
   * values that is obtained by invoking a projection function on
   * each element of the input sequence.
   */
  double averageDouble(FunctionExpression> selector);

  /**
   * 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.
   */
  Double averageNullableDouble(
      FunctionExpression> selector);

  /**
   * Computes the average of a sequence of int values
   * that is obtained by invoking a projection function on each
   * element of the input sequence.
   */
  int averageInteger(FunctionExpression> selector);

  /**
   * 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.
   */
  Integer averageNullableInteger(
      FunctionExpression> selector);

  /**
   * Computes the average of a sequence of Float
   * values that is obtained by invoking a projection function on
   * each element of the input sequence.
   */
  float averageFloat(FunctionExpression> selector);

  /**
   * 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.
   */
  Float averageNullableFloat(
      FunctionExpression> selector);

  /**
   * Computes the average of a sequence of long values
   * that is obtained by invoking a projection function on each
   * element of the input sequence.
   */
  long averageLong(FunctionExpression> selector);

  /**
   * 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.
   */
  Long averageNullableLong(
      FunctionExpression> selector);

  /**
   * Concatenates two sequences.
   */
  @Override Queryable concat(Enumerable source2);

  /**
   * Returns the number of elements in the specified
   * sequence that satisfies a condition.
   */
  int count(FunctionExpression> predicate);

  /**
   * Returns the elements of the specified sequence or
   * the type parameter's default value in a singleton collection if
   * the sequence is empty.
   */
  @Override Queryable<@Nullable TSource> defaultIfEmpty();

  /**
   * Returns distinct elements from a sequence by using
   * the default equality comparer to compare values.
   */
  @Override Queryable distinct();

  /**
   * Returns distinct elements from a sequence by using
   * a specified EqualityComparer<TSource> to compare values.
   */
  @Override Queryable distinct(EqualityComparer comparer);

  /**
   * Produces the set difference of two sequences by
   * using the default equality comparer to compare values,
   * eliminate duplicates. (Defined by Enumerable.)
   */
  @Override Queryable except(Enumerable enumerable);

  /**
   * Produces the set difference of two sequences by
   * using the default equality comparer to compare values,
   * using {@code all} to indicate whether to eliminate duplicates.
   * (Defined by Enumerable.)
   */
  @Override Queryable except(Enumerable enumerable, boolean all);

  /**
   * Produces the set difference of two sequences by
   * using the specified {@code EqualityComparer} to compare
   * values, eliminate duplicates.
   */
  @Override Queryable except(Enumerable enumerable,
      EqualityComparer comparer);

  /**
   * Produces the set difference of two sequences by
   * using the specified {@code EqualityComparer} to compare
   * values, using {@code all} to indicate whether to eliminate duplicates.
   */
  @Override Queryable except(Enumerable enumerable,
      EqualityComparer comparer, boolean all);
  /**
   * Returns the first element of a sequence that
   * satisfies a specified condition.
   */
  TSource first(FunctionExpression> predicate);

  /**
   * Returns the first element of a sequence that
   * satisfies a specified condition or a default value if no such
   * element is found.
   */
  @Nullable TSource firstOrDefault(FunctionExpression> predicate);

  /**
   * Groups the elements of a sequence according to a
   * specified key selector function.
   */
   Queryable> groupBy(
      FunctionExpression> keySelector);

  /**
   * Groups the elements of a sequence according to a
   * specified key selector function and compares the keys by using
   * a specified comparer.
   */
   Queryable> groupBy(
      FunctionExpression> keySelector,
      EqualityComparer comparer);

  /**
   * 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.
   */
   Queryable> groupBy(
      FunctionExpression> keySelector,
      FunctionExpression> elementSelector);

  /**
   * 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.
   */
   Queryable> groupBy(
      FunctionExpression> keySelector,
      FunctionExpression> elementSelector,
      EqualityComparer comparer);

  /**
   * 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.tree.FunctionExpression, org.apache.calcite.linq4j.tree.FunctionExpression)}, * which has the same erasure.

*/ Queryable groupByK( FunctionExpression> keySelector, FunctionExpression, TResult>> resultSelector); /** * 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. */ Queryable groupByK( FunctionExpression> keySelector, FunctionExpression, TResult>> resultSelector, EqualityComparer comparer); /** * 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. */ Queryable groupBy( FunctionExpression> keySelector, FunctionExpression> elementSelector, FunctionExpression, TResult>> resultSelector); /** * 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. */ Queryable groupBy( FunctionExpression> keySelector, FunctionExpression> elementSelector, FunctionExpression, TResult>> resultSelector, EqualityComparer comparer); /** * Correlates the elements of two sequences based on * key equality and groups the results. The default equality * comparer is used to compare keys. */ Queryable groupJoin(Enumerable inner, FunctionExpression> outerKeySelector, FunctionExpression> innerKeySelector, FunctionExpression, TResult>> resultSelector); /** * Correlates the elements of two sequences based on * key equality and groups the results. A specified * {@code EqualityComparer} is used to compare keys. */ Queryable groupJoin(Enumerable inner, FunctionExpression> outerKeySelector, FunctionExpression> innerKeySelector, FunctionExpression, TResult>> resultSelector, EqualityComparer comparer); /** * Produces the set intersection of two sequences by * using the default equality comparer to compare values, * eliminate duplicates.(Defined by Queryable.) */ @Override Queryable intersect(Enumerable enumerable); /** * Produces the set intersection of two sequences by * using the default equality comparer to compare values, * using {@code all} to indicate whether to eliminate duplicates. * (Defined by Queryable.) */ @Override Queryable intersect(Enumerable enumerable, boolean all); /** * Produces the set intersection of two sequences by * using the specified {@code EqualityComparer} to compare * values, eliminate duplicates. */ @Override Queryable intersect(Enumerable enumerable, EqualityComparer comparer); /** * Produces the set intersection of two sequences by * using the specified {@code EqualityComparer} to compare * values, using {@code all} to indicate whether to eliminate duplicates. */ @Override Queryable intersect(Enumerable enumerable, EqualityComparer comparer, boolean all); /** * Correlates the elements of two sequences based on * matching keys. The default equality comparer is used to compare * keys. */ Queryable join(Enumerable inner, FunctionExpression> outerKeySelector, FunctionExpression> innerKeySelector, FunctionExpression> resultSelector); /** * Correlates the elements of two sequences based on * matching keys. A specified {@code EqualityComparer} is used to * compare keys. */ Queryable join(Enumerable inner, FunctionExpression> outerKeySelector, FunctionExpression> innerKeySelector, FunctionExpression> resultSelector, EqualityComparer comparer); /** * Returns the last element of a sequence that * satisfies a specified condition. */ TSource last(FunctionExpression> predicate); /** * Returns the last element of a sequence that * satisfies a condition or a default value if no such element is * found. */ @Nullable TSource lastOrDefault(FunctionExpression> predicate); /** * Returns an long that represents the number of * elements in a sequence that satisfy a condition. */ long longCount(FunctionExpression> predicate); /** * Invokes a projection function on each element of a * generic {@code IQueryable} and returns the maximum resulting * value. */ > @Nullable TResult max( FunctionExpression> selector); /** * Invokes a projection function on each element of a * generic {@code IQueryable} and returns the minimum resulting * value. */ > @Nullable TResult min( FunctionExpression> selector); /** * Filters the elements of an IQueryable based on a * specified type. * *

The OfType method generates a * {@link org.apache.calcite.linq4j.tree.MethodCallExpression} that represents * calling OfType itself as a constructed generic method. It then passes the * MethodCallExpression to the CreateQuery(Expression) method of the * {@link 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.

*/ @Override Queryable ofType(Class clazz); @Override Queryable cast(Class clazz); /** * Sorts the elements of a sequence in ascending * order according to a key. */ OrderedQueryable orderBy( FunctionExpression> keySelector); /** * Sorts the elements of a sequence in ascending * order by using a specified comparer. */ OrderedQueryable orderBy( FunctionExpression> keySelector, Comparator comparator); /** * Sorts the elements of a sequence in descending * order according to a key. */ OrderedQueryable orderByDescending( FunctionExpression> keySelector); /** * Sorts the elements of a sequence in descending * order by using a specified comparer. */ OrderedQueryable orderByDescending( FunctionExpression> keySelector, Comparator comparator); /** * Inverts the order of the elements in a sequence. */ @Override Queryable reverse(); /** * Projects each element of a sequence into a new form. */ Queryable select( FunctionExpression> selector); /** * Projects each element of a sequence into a new * form by incorporating the element's index. * *

NOTE: Renamed from {@code select} because had same erasure as * {@link #select(org.apache.calcite.linq4j.tree.FunctionExpression)}.

*/ Queryable selectN( FunctionExpression> selector); /** * Projects each element of a sequence to an * {@code Enumerable} and combines the resulting sequences into one * sequence. */ Queryable selectMany( FunctionExpression>> selector); /** * Projects each element of a sequence to an * {@code Enumerable} and combines the resulting sequences into one * sequence. The index of each source element is used in the * projected form of that element. * *

NOTE: Renamed from {@code selectMany} because had same erasure as * {@link #selectMany(org.apache.calcite.linq4j.tree.FunctionExpression)}

*/ Queryable selectManyN( FunctionExpression>> selector); /** * Projects each element of a sequence to an * {@code Enumerable} that incorporates the index of the source * element that produced it. A result selector function is invoked * on each element of each intermediate sequence, and the * resulting values are combined into a single, one-dimensional * sequence and returned. */ Queryable selectMany( FunctionExpression>> collectionSelector, FunctionExpression> resultSelector); /** * Projects each element of a sequence to an * {@code Enumerable} and invokes a result selector function on each * element therein. The resulting values from each intermediate * sequence are combined into a single, one-dimensional sequence * and returned. * *

NOTE: Renamed from {@code selectMany} because had same erasure as * {@link #selectMany(org.apache.calcite.linq4j.tree.FunctionExpression, org.apache.calcite.linq4j.tree.FunctionExpression)} */ Queryable selectManyN( FunctionExpression>> collectionSelector, FunctionExpression> resultSelector); /** * Returns the only element of a sequence that * satisfies a specified condition, and throws an exception if * more than one such element exists. */ TSource single(FunctionExpression> predicate); /** * Returns the only element of a sequence, or a * default value if the sequence is empty; this method throws an * exception if there is more than one element in the * sequence. */ @Override @Nullable TSource singleOrDefault(); /** * Returns the only element of a sequence that * satisfies a specified condition or a default value if no such * element exists; this method throws an exception if more than * one element satisfies the condition. */ @Nullable TSource singleOrDefault(FunctionExpression> predicate); /** * Bypasses a specified number of elements in a * sequence and then returns the remaining elements. */ @Override Queryable skip(int count); /** * Bypasses elements in a sequence as long as a * specified condition is true and then returns the remaining * elements. */ Queryable skipWhile( FunctionExpression> predicate); /** * Bypasses elements in a sequence as long as a * specified condition is true and then returns the remaining * elements. The element's index is used in the logic of the * predicate function. */ Queryable skipWhileN( FunctionExpression> predicate); /** * Computes the sum of the sequence of Decimal values * that is obtained by invoking a projection function on each * element of the input sequence. */ BigDecimal sumBigDecimal( FunctionExpression> selector); /** * Computes the sum of the sequence of nullable * Decimal values that is obtained by invoking a projection * function on each element of the input sequence. */ BigDecimal sumNullableBigDecimal( FunctionExpression> selector); /** * Computes the sum of the sequence of Double values * that is obtained by invoking a projection function on each * element of the input sequence. */ double sumDouble(FunctionExpression> selector); /** * Computes the sum of the sequence of nullable * Double values that is obtained by invoking a projection * function on each element of the input sequence. */ Double sumNullableDouble( FunctionExpression> selector); /** * Computes the sum of the sequence of int values * that is obtained by invoking a projection function on each * element of the input sequence. */ int sumInteger(FunctionExpression> selector); /** * Computes the sum of the sequence of nullable int * values that is obtained by invoking a projection function on * each element of the input sequence. */ Integer sumNullableInteger( FunctionExpression> selector); /** * Computes the sum of the sequence of long values * that is obtained by invoking a projection function on each * element of the input sequence. */ long sumLong(FunctionExpression> selector); /** * Computes the sum of the sequence of nullable long * values that is obtained by invoking a projection function on * each element of the input sequence. */ Long sumNullableLong( FunctionExpression> selector); /** * Computes the sum of the sequence of Float values * that is obtained by invoking a projection function on each * element of the input sequence. */ float sumFloat(FunctionExpression> selector); /** * Computes the sum of the sequence of nullable * Float values that is obtained by invoking a projection * function on each element of the input sequence. */ Float sumNullableFloat( FunctionExpression> selector); /** * Returns a specified number of contiguous elements * from the start of a sequence. */ @Override Queryable take(int count); /** * Returns elements from a sequence as long as a * specified condition is true. */ Queryable takeWhile( FunctionExpression> predicate); /** * Returns elements from a sequence as long as a * specified condition is true. The element's index is used in the * logic of the predicate function. */ Queryable takeWhileN( FunctionExpression> predicate); /** * Produces the set union of two sequences by using * the default equality comparer. */ @Override Queryable union(Enumerable source1); /** * Produces the set union of two sequences by using a * specified {@code EqualityComparer}. */ @Override Queryable union(Enumerable source1, EqualityComparer comparer); /** * Filters a sequence of values based on a * predicate. */ Queryable where( FunctionExpression> predicate); /** * Filters a sequence of values based on a * predicate. Each element's index is used in the logic of the * predicate function. */ Queryable whereN( FunctionExpression> predicate); /** * Merges two sequences by using the specified * predicate function. */ Queryable zip(Enumerable source1, FunctionExpression> resultSelector); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy