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

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 Type functionResultType( FunctionExpression> selector) { return selector.body.getType(); } /** * 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.Queryable, org.apache.calcite.linq4j.tree.FunctionExpression)}. */ public static Queryable selectN(Queryable source, FunctionExpression> selector) { throw Extensions.todo(); } /** * Projects each element of a sequence to an * {@code Enumerable} and combines the resulting sequences into one * sequence. */ public static Queryable selectMany(Queryable source, FunctionExpression>> selector) { throw Extensions.todo(); } /** * 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.Queryable, org.apache.calcite.linq4j.tree.FunctionExpression)}. */ public static Queryable selectManyN(Queryable source, FunctionExpression>> selector) { throw Extensions.todo(); } /** * 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. */ public static Queryable selectMany( Queryable source, FunctionExpression>> collectionSelector, FunctionExpression> resultSelector) { throw Extensions.todo(); } /** * 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.Queryable, org.apache.calcite.linq4j.tree.FunctionExpression, org.apache.calcite.linq4j.tree.FunctionExpression)}. */ public static Queryable selectManyN( Queryable source, FunctionExpression>> collectionSelector, FunctionExpression> resultSelector) { throw Extensions.todo(); } /** * Determines whether two sequences are equal by * using the default equality comparer to compare * elements. */ public static boolean sequenceEqual(Queryable queryable, Enumerable enumerable) { throw Extensions.todo(); } /** * Determines whether two sequences are equal by * using a specified {@code EqualityComparer} to compare * elements. */ public static boolean sequenceEqual(Queryable queryable, Enumerable enumerable, EqualityComparer comparer) { throw Extensions.todo(); } /** * Returns the only element of a sequence, and throws * an exception if there is not exactly one element in the * sequence. */ public static T single(Queryable source) { throw Extensions.todo(); } /** * Returns the only element of a sequence that * satisfies a specified condition, and throws an exception if * more than one such element exists. */ public static T single(Queryable source, FunctionExpression> predicate) { throw Extensions.todo(); } /** * 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. */ public static T singleOrDefault(Queryable source) { throw Extensions.todo(); } /** * 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. */ public static T singleOrDefault(Queryable source, FunctionExpression> predicate) { throw Extensions.todo(); } /** * Bypasses a specified number of elements in a * sequence and then returns the remaining elements. */ public static Queryable skip(Queryable source, int count) { return EnumerableDefaults.skip(source.asEnumerable(), count).asQueryable(); } /** * Bypasses elements in a sequence as long as a * specified condition is true and then returns the remaining * elements. */ public static Queryable skipWhile(Queryable source, FunctionExpression> predicate) { return skipWhileN(source, Expressions.lambda( Functions.toPredicate2(predicate.getFunction()))); } /** * 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. */ public static Queryable skipWhileN(final Queryable source, final FunctionExpression> predicate) { return new BaseQueryable(source.getProvider(), source.getElementType(), source.getExpression()) { public Enumerator enumerator() { return new EnumerableDefaults.SkipWhileEnumerator<>( source.enumerator(), predicate.getFunction()); } }; } /** * Computes the sum of the sequence of Decimal values * that is obtained by invoking a projection function on each * element of the input sequence. */ public static BigDecimal sumBigDecimal(Queryable sources, FunctionExpression> selector) { throw Extensions.todo(); } /** * 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. */ public static BigDecimal sumNullableBigDecimal(Queryable source, FunctionExpression> selector) { throw Extensions.todo(); } /** * Computes the sum of the sequence of Double values * that is obtained by invoking a projection function on each * element of the input sequence. */ public static double sumDouble(Queryable source, FunctionExpression> selector) { throw Extensions.todo(); } /** * 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. */ public static Double sumNullableDouble(Queryable source, FunctionExpression> selector) { throw Extensions.todo(); } /** * Computes the sum of the sequence of int values * that is obtained by invoking a projection function on each * element of the input sequence. */ public static int sumInteger(Queryable source, FunctionExpression> selector) { throw Extensions.todo(); } /** * 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. */ public static Integer sumNullableInteger(Queryable source, FunctionExpression> selector) { throw Extensions.todo(); } /** * Computes the sum of the sequence of long values * that is obtained by invoking a projection function on each * element of the input sequence. */ public static long sumLong(Queryable source, FunctionExpression> selector) { throw Extensions.todo(); } /** * 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. */ public static Long sumNullableLong(Queryable source, FunctionExpression> selector) { throw Extensions.todo(); } /** * Computes the sum of the sequence of Float values * that is obtained by invoking a projection function on each * element of the input sequence. */ public static float sumFloat(Queryable source, FunctionExpression> selector) { throw Extensions.todo(); } /** * 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. */ public static Float sumNullableFloat(Queryable source, FunctionExpression> selector) { throw Extensions.todo(); } /** * Returns a specified number of contiguous elements * from the start of a sequence. */ public static Queryable take(Queryable source, int count) { return EnumerableDefaults.take(source.asEnumerable(), count).asQueryable(); } /** * Returns elements from a sequence as long as a * specified condition is true. */ public static Queryable takeWhile(Queryable source, FunctionExpression> predicate) { return takeWhileN(source, Expressions.lambda( Functions.toPredicate2(predicate.getFunction()))); } /** * 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. */ public static Queryable takeWhileN(final Queryable source, final FunctionExpression> predicate) { return new BaseQueryable(source.getProvider(), source.getElementType(), source.getExpression()) { public Enumerator enumerator() { return new EnumerableDefaults.TakeWhileEnumerator<>( source.enumerator(), predicate.getFunction()); } }; } /** * Performs a subsequent ordering of the elements in a sequence in * ascending order according to a key. */ public static > OrderedQueryable thenBy( OrderedQueryable source, FunctionExpression> keySelector) { throw Extensions.todo(); } /** * Performs a subsequent ordering of the elements in a sequence in * ascending order according to a key, using a specified comparator. */ public static OrderedQueryable thenBy(OrderedQueryable source, FunctionExpression> keySelector, Comparator comparator) { throw Extensions.todo(); } /** * Performs a subsequent ordering of the elements in a sequence in * descending order according to a key. */ public static > OrderedQueryable thenByDescending( OrderedQueryable source, FunctionExpression> keySelector) { throw Extensions.todo(); } /** * Performs a subsequent ordering of the elements in a sequence in * dscending order according to a key, using a specified comparator. */ public static OrderedQueryable thenByDescending( OrderedQueryable source, FunctionExpression> keySelector, Comparator comparator) { throw Extensions.todo(); } /** * Produces the set union of two sequences by using * the default equality comparer. */ public static Queryable union(Queryable source0, Enumerable source1) { throw Extensions.todo(); } /** * Produces the set union of two sequences by using a * specified {@code EqualityComparer}. */ public static Queryable union(Queryable source0, Enumerable source1, EqualityComparer comparer) { throw Extensions.todo(); } /** * Filters a sequence of values based on a * predicate. */ public static Queryable where(final Queryable source, final FunctionExpression> predicate) { return new NonLeafReplayableQueryable(source) { public void replay(QueryableFactory factory) { factory.where(source, predicate); } }; } /** * Filters a sequence of values based on a * predicate. Each element's index is used in the logic of the * predicate function. */ public static Queryable whereN(Queryable source, FunctionExpression> predicate) { throw Extensions.todo(); } /** * Merges two sequences by using the specified * predicate function. */ public static Queryable zip(Queryable source0, Enumerable source1, FunctionExpression> resultSelector) { throw Extensions.todo(); } /** Replayable. * * @param element type */ public interface Replayable extends Queryable { void replay(QueryableFactory factory); } /** Replayable queryable. * * @param element type */ public abstract static class ReplayableQueryable extends DefaultQueryable implements Replayable { public void replay(QueryableFactory factory) { } public Iterator iterator() { return Linq4j.enumeratorIterator(enumerator()); } public Enumerator enumerator() { return getProvider().executeQuery(this); } /** * Convenience method, for {@link QueryableRecorder} methods that * return a scalar value such as {@code boolean} or * {@link BigDecimal}. */ @SuppressWarnings("unchecked") U castSingle() { return ((Queryable) (Queryable) this).single(); } /** * Convenience method, for {@link QueryableRecorder} methods that * return a Queryable of a different element type than the source. */ @SuppressWarnings("unchecked") public Queryable castQueryable() { return (Queryable) (Queryable) this; } } /** Non-leaf replayable queryable. * * @param element type */ public abstract static class NonLeafReplayableQueryable extends ReplayableQueryable { private final Queryable original; protected NonLeafReplayableQueryable(Queryable original) { this.original = original; } public Type getElementType() { return original.getElementType(); } public Expression getExpression() { return original.getExpression(); } public QueryProvider getProvider() { return original.getProvider(); } } }