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

com.hazelcast.org.apache.calcite.linq4j.QueryableFactory 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.linq4j;

import com.hazelcast.org.apache.calcite.linq4j.function.BigDecimalFunction1;
import com.hazelcast.org.apache.calcite.linq4j.function.DoubleFunction1;
import com.hazelcast.org.apache.calcite.linq4j.function.EqualityComparer;
import com.hazelcast.org.apache.calcite.linq4j.function.FloatFunction1;
import com.hazelcast.org.apache.calcite.linq4j.function.Function1;
import com.hazelcast.org.apache.calcite.linq4j.function.Function2;
import com.hazelcast.org.apache.calcite.linq4j.function.IntegerFunction1;
import com.hazelcast.org.apache.calcite.linq4j.function.LongFunction1;
import com.hazelcast.org.apache.calcite.linq4j.function.NullableBigDecimalFunction1;
import com.hazelcast.org.apache.calcite.linq4j.function.NullableDoubleFunction1;
import com.hazelcast.org.apache.calcite.linq4j.function.NullableFloatFunction1;
import com.hazelcast.org.apache.calcite.linq4j.function.NullableIntegerFunction1;
import com.hazelcast.org.apache.calcite.linq4j.function.NullableLongFunction1;
import com.hazelcast.org.apache.calcite.linq4j.function.Predicate1;
import com.hazelcast.org.apache.calcite.linq4j.function.Predicate2;
import com.hazelcast.org.apache.calcite.linq4j.tree.FunctionExpression;

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

/**
 * Factory for building {@link Queryable} objects.
 *
 * @param  Element type
 */
public interface QueryableFactory {

  /**
   * Applies an accumulator function over a sequence.
   */
  T aggregate(Queryable source,
      FunctionExpression> selector);

  /**
   * Applies an accumulator function over a
   * sequence. The specified seed value is used as the initial
   * accumulator value.
   */
   TAccumulate aggregate(Queryable source, 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(Queryable source,
      TAccumulate seed,
      FunctionExpression> func,
      FunctionExpression> selector);

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

  /**
   * Determines whether a sequence contains any
   * elements.
   */
  boolean any(Queryable source);

  /**
   * Determines whether any element of a sequence
   * satisfies a condition.
   */
  boolean any(Queryable source, 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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      FunctionExpression> selector);

  /**
   * Concatenates two sequences.
   */
  Queryable concat(Queryable source, Enumerable source2);

  /**
   * Determines whether a sequence contains a specified
   * element by using the default equality comparer.
   */
  boolean contains(Queryable source, T element);

  /**
   * Determines whether a sequence contains a specified
   * element by using a specified {@code EqualityComparer}.
   */
  boolean contains(Queryable source, T element,
      EqualityComparer comparer);

  /**
   * Returns the number of elements in a
   * sequence.
   */
  int count(Queryable source);

  /**
   * Returns the number of elements in the specified
   * sequence that satisfies a condition.
   */
  int count(Queryable source, 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.
   */
  Queryable defaultIfEmpty(Queryable source);

  /**
   * Returns the elements of the specified sequence or
   * the specified value in a singleton collection if the sequence
   * is empty.
   */
  Queryable defaultIfEmpty(Queryable source, T value);

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

  /**
   * Returns distinct elements from a sequence by using
   * a specified {@code EqualityComparer} to compare values.
   */
  Queryable distinct(Queryable source, EqualityComparer comparer);

  /**
   * Returns the element at a specified index in a
   * sequence.
   */
  T elementAt(Queryable source, int index);

  /**
   * Returns the element at a specified index in a
   * sequence or a default value if the index is out of
   * range.
   */
  T elementAtOrDefault(Queryable source, int index);

  /**
   * Produces the set difference of two sequences by
   * using the default equality comparer to compare values,
   * eliminate duplicates. (Defined by Queryable.)
   */
  Queryable except(Queryable source, 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 Queryable.)
   */
  Queryable except(Queryable source, Enumerable enumerable, boolean all);

  /**
   * Produces the set difference of two sequences by
   * using the specified {@code EqualityComparer} to compare
   * values, eliminate duplicates.
   */
  Queryable except(Queryable source, 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.
   */
  Queryable except(Queryable source, Enumerable enumerable,
      EqualityComparer comparer, boolean all);

  /**
   * Returns the first element of a sequence. (Defined
   * by Queryable.)
   */
  T first(Queryable source);

  /**
   * Returns the first element of a sequence that
   * satisfies a specified condition.
   */
  T first(Queryable source, FunctionExpression> predicate);

  /**
   * Returns the first element of a sequence, or a
   * default value if the sequence contains no elements.
   */
  T firstOrDefault(Queryable source);

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

  /**
   * Groups the elements of a sequence according to a
   * specified key selector function.
   */
   Queryable> groupBy(Queryable source,
      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(Queryable source,
      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(
      Queryable source, 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(
      Queryable source, 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.
   */
   Queryable groupByK(
      Queryable source, 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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      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
   * EqualityComparer is used to compare keys.
   */
   Queryable groupJoin(Queryable source,
      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.)
   */
  Queryable intersect(Queryable source, 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.)
   */
  Queryable intersect(Queryable source, Enumerable enumerable, boolean all);

  /**
   * Produces the set intersection of two sequences by
   * using the specified EqualityComparer to compare
   * values, eliminate duplicates.
   */
  Queryable intersect(Queryable source, Enumerable enumerable,
      EqualityComparer comparer);

  /**
   * Produces the set intersection of two sequences by
   * using the specified EqualityComparer to compare
   * values, using {@code all} to indicate whether to eliminate duplicates.
   */
  Queryable intersect(Queryable source, 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(Queryable source,
      Enumerable inner,
      FunctionExpression> outerKeySelector,
      FunctionExpression> innerKeySelector,
      FunctionExpression> resultSelector);

  /**
   * Correlates the elements of two sequences based on
   * matching keys. A specified EqualityComparer is used to
   * compare keys.
   */
   Queryable join(Queryable source,
      Enumerable inner,
      FunctionExpression> outerKeySelector,
      FunctionExpression> innerKeySelector,
      FunctionExpression> resultSelector,
      EqualityComparer comparer);

  /**
   * Returns the last element in a sequence. (Defined
   * by Queryable.)
   */
  T last(Queryable source);

  /**
   * Returns the last element of a sequence that
   * satisfies a specified condition.
   */
  T last(Queryable source, FunctionExpression> predicate);

  /**
   * Returns the last element in a sequence, or a
   * default value if the sequence contains no elements.
   */
  T lastOrDefault(Queryable source);

  /**
   * Returns the last element of a sequence that
   * satisfies a condition or a default value if no such element is
   * found.
   */
  T lastOrDefault(Queryable source,
      FunctionExpression> predicate);

  /**
   * Returns an long that represents the total number
   * of elements in a sequence.
   */
  long longCount(Queryable source);

  /**
   * Returns an long that represents the number of
   * elements in a sequence that satisfy a condition.
   */
  long longCount(Queryable source,
      FunctionExpression> predicate);

  /**
   * Returns the maximum value in a generic
   * {@code IQueryable}.
   */
  T max(Queryable source);

  /**
   * Invokes a projection function on each element of a
   * generic {@code IQueryable} and returns the maximum resulting
   * value.
   */
  > TResult max(Queryable source,
      FunctionExpression> selector);

  /**
   * Returns the minimum value in a generic
   * {@code IQueryable}.
   */
  T min(Queryable source);

  /**
   * Invokes a projection function on each element of a
   * generic {@code IQueryable} and returns the minimum resulting
   * value.
   */
  > TResult min(Queryable source,
      FunctionExpression> selector);

  /**
   * Filters the elements of an IQueryable based on a
   * specified type.
   */
   Queryable ofType(Queryable source,
      Class clazz);

   Queryable cast(Queryable source, Class clazz);

  /**
   * Sorts the elements of a sequence in ascending
   * order according to a key.
   */
   OrderedQueryable orderBy(Queryable source,
      FunctionExpression> keySelector);

  /**
   * Sorts the elements of a sequence in ascending
   * order by using a specified comparer.
   */
   OrderedQueryable orderBy(Queryable source,
      FunctionExpression> keySelector,
      Comparator comparator);

  /**
   * Sorts the elements of a sequence in descending
   * order according to a key.
   */
   OrderedQueryable orderByDescending(
      Queryable source, FunctionExpression> keySelector);

  /**
   * Sorts the elements of a sequence in descending
   * order by using a specified comparer.
   */
   OrderedQueryable orderByDescending(Queryable source,
      FunctionExpression> keySelector,
      Comparator comparator);

  /**
   * Inverts the order of the elements in a sequence.
   */
  Queryable reverse(Queryable source);

  /**
   * Projects each element of a sequence into a new form.
   */
   Queryable select(Queryable source,
      FunctionExpression> selector);

  /**
   * Projects each element of a sequence into a new
   * form by incorporating the element's index.
   */
   Queryable selectN(Queryable source,
      FunctionExpression> selector);


  /**
   * Projects each element of a sequence to an
   * {@code Enumerable} and combines the resulting sequences into one
   * sequence.
   */
   Queryable selectMany(Queryable source,
      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.
   */
   Queryable selectManyN(Queryable source,
      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(Queryable source,
      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.
   */
   Queryable selectManyN(Queryable source,
      FunctionExpression>>
        collectionSelector,
      FunctionExpression> resultSelector);

  /**
   * Determines whether two sequences are equal by
   * using the default equality comparer to compare
   * elements.
   */
  boolean sequenceEqual(Queryable source, Enumerable enumerable);

  /**
   * Determines whether two sequences are equal by
   * using a specified EqualityComparer to compare
   * elements.
   */
  boolean sequenceEqual(Queryable source, Enumerable enumerable,
      EqualityComparer comparer);

  /**
   * Returns the only element of a sequence, and throws
   * an exception if there is not exactly one element in the
   * sequence.
   */
  T single(Queryable source);

  /**
   * Returns the only element of a sequence that
   * satisfies a specified condition, and throws an exception if
   * more than one such element exists.
   */
  T single(Queryable source, 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.
   */
  T singleOrDefault(Queryable source);

  /**
   * 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.
   */
  T singleOrDefault(Queryable source,
      FunctionExpression> predicate);

  /**
   * Bypasses a specified number of elements in a
   * sequence and then returns the remaining elements.
   */
  Queryable skip(Queryable source, int count);

  /**
   * Bypasses elements in a sequence as long as a
   * specified condition is true and then returns the remaining
   * elements.
   */
  Queryable skipWhile(Queryable source,
      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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      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(Queryable source,
      FunctionExpression> selector);

  /**
   * Returns a specified number of contiguous elements
   * from the start of a sequence.
   */
  Queryable take(Queryable source, int count);

  /**
   * Returns elements from a sequence as long as a
   * specified condition is true.
   */
  Queryable takeWhile(Queryable source,
      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(Queryable source,
      FunctionExpression> predicate);

  > OrderedQueryable thenBy(
      OrderedQueryable source,
      FunctionExpression> keySelector);

   OrderedQueryable thenBy(OrderedQueryable source,
      FunctionExpression> keySelector,
      Comparator comparator);

  > OrderedQueryable thenByDescending(
      OrderedQueryable source,
      FunctionExpression> keySelector);

   OrderedQueryable thenByDescending(OrderedQueryable source,
      FunctionExpression> keySelector,
      Comparator comparator);

  /**
   * Produces the set union of two sequences by using
   * the default equality comparer.
   */
  Queryable union(Queryable source, Enumerable source1);

  /**
   * Produces the set union of two sequences by using a
   * specified {@code EqualityComparer}.
   */
  Queryable union(Queryable source, Enumerable source1,
      EqualityComparer comparer);

  /**
   * Filters a sequence of values based on a
   * predicate.
   */
  Queryable where(Queryable source,
      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(Queryable source,
      FunctionExpression> predicate);

  /**
   * Merges two sequences by using the specified
   * predicate function.
   */
   Queryable zip(Queryable source,
      Enumerable source1,
      FunctionExpression> resultSelector);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy