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

org.apache.calcite.linq4j.DefaultQueryable 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.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 java.math.BigDecimal;
import java.util.Comparator;

/**
 * Implementation of the {@link Queryable} interface that
 * implements the extension methods by calling into the {@link Extensions}
 * class.
 *
 * @param  Element type
 */
abstract class DefaultQueryable extends DefaultEnumerable
    implements Queryable, OrderedQueryable {
  private final QueryableFactory factory;

  /**
   * Creates a DefaultQueryable using a factory that records events.
   */
  protected DefaultQueryable() {
    this(QueryableRecorder.instance());
  }

  /**
   * Creates a DefaultQueryable using a particular factory.
   */
  protected DefaultQueryable(QueryableFactory factory) {
    this.factory = factory;
  }

  // override return type
  @Override protected Queryable getThis() {
    return this;
  }

  protected OrderedQueryable getThisOrderedQueryable() {
    return this;
  }

  @Override public Enumerable asEnumerable() {
    return new AbstractEnumerable() {
      @Override public Enumerator enumerator() {
        return DefaultQueryable.this.enumerator();
      }
    };
  }

  // Disambiguate

  @Override public Queryable union(Enumerable source1) {
    return factory.union(getThis(), source1);
  }

  @Override public Queryable union(Enumerable source1,
      EqualityComparer comparer) {
    return factory.union(getThis(), source1, comparer);
  }

  @Override public Queryable intersect(Enumerable source1) {
    return intersect(source1, false);
  }

  @Override public Queryable intersect(Enumerable source1, boolean all) {
    return factory.intersect(getThis(), source1, all);
  }

  @Override public Queryable intersect(Enumerable source1,
      EqualityComparer comparer) {
    return intersect(source1, comparer, false);
  }

  @Override public Queryable intersect(Enumerable source1,
      EqualityComparer comparer, boolean all) {
    return factory.intersect(getThis(), source1, comparer, all);
  }

  @Override public Queryable except(Enumerable enumerable1,
      EqualityComparer comparer) {
    return except(enumerable1, comparer, false);
  }
  @Override public Queryable except(Enumerable enumerable1,
      EqualityComparer comparer, boolean all) {
    return factory.except(getThis(), enumerable1, comparer, all);
  }

  @Override public Queryable except(Enumerable enumerable1) {
    return except(enumerable1, false);
  }

  @Override public Queryable except(Enumerable enumerable1, boolean all) {
    return factory.except(getThis(), enumerable1, all);
  }

  @Override public Queryable take(int count) {
    return factory.take(getThis(), count);
  }

  @Override public Queryable skip(int count) {
    return factory.skip(getThis(), count);
  }

  @Override public Queryable reverse() {
    return factory.reverse(getThis());
  }

  @Override public Queryable distinct() {
    return factory.distinct(getThis());
  }

  @Override public Queryable distinct(EqualityComparer comparer) {
    return factory.distinct(getThis(), comparer);
  }

  @Override public  Queryable ofType(Class clazz) {
    return factory.ofType(getThis(), clazz);
  }

  @Override public Queryable<@Nullable T> defaultIfEmpty() {
    return factory.defaultIfEmpty(getThis());
  }

  @Override public Queryable asQueryable() {
    return this;
  }

  @Override public  Queryable cast(Class clazz) {
    return factory.cast(getThis(), clazz);
  }

  // End disambiguate

  @Override public @Nullable T aggregate(
      FunctionExpression> selector) {
    return factory.aggregate(getThis(), selector);
  }

  @Override public  TAccumulate aggregate(TAccumulate seed,
      FunctionExpression> selector) {
    return factory.aggregate(getThis(), seed, selector);
  }

  @Override public  TResult aggregate(TAccumulate seed,
      FunctionExpression> func,
      FunctionExpression> selector) {
    return factory.aggregate(getThis(), seed, func, selector);
  }

  @Override public boolean all(FunctionExpression> predicate) {
    return factory.all(getThis(), predicate);
  }

  @Override public boolean any(FunctionExpression> predicate) {
    return factory.any(getThis(), predicate);
  }

  @Override public BigDecimal averageBigDecimal(
      FunctionExpression> selector) {
    return factory.averageBigDecimal(getThis(), selector);
  }

  @Override public BigDecimal averageNullableBigDecimal(
      FunctionExpression> selector) {
    return factory.averageNullableBigDecimal(getThis(), selector);
  }

  @Override public double averageDouble(FunctionExpression> selector) {
    return factory.averageDouble(getThis(), selector);
  }

  @Override public Double averageNullableDouble(
      FunctionExpression> selector) {
    return factory.averageNullableDouble(getThis(), selector);
  }

  @Override public int averageInteger(FunctionExpression> selector) {
    return factory.averageInteger(getThis(), selector);
  }

  @Override public Integer averageNullableInteger(
      FunctionExpression> selector) {
    return factory.averageNullableInteger(getThis(), selector);
  }

  @Override public float averageFloat(FunctionExpression> selector) {
    return factory.averageFloat(getThis(), selector);
  }

  @Override public Float averageNullableFloat(
      FunctionExpression> selector) {
    return factory.averageNullableFloat(getThis(), selector);
  }

  @Override public long averageLong(FunctionExpression> selector) {
    return factory.averageLong(getThis(), selector);
  }

  @Override public Long averageNullableLong(
      FunctionExpression> selector) {
    return factory.averageNullableLong(getThis(), selector);
  }

  @Override public Queryable concat(Enumerable source2) {
    return factory.concat(getThis(), source2);
  }

  @Override public int count(FunctionExpression> func) {
    return factory.count(getThis(), func);
  }

  @Override public T first(FunctionExpression> predicate) {
    return factory.first(getThis(), predicate);
  }

  @Override public @Nullable T firstOrDefault(FunctionExpression> predicate) {
    return factory.firstOrDefault(getThis(), predicate);
  }

  @Override public  Queryable> groupBy(
      FunctionExpression> keySelector) {
    return factory.groupBy(getThis(), keySelector);
  }

  @Override public  Queryable> groupBy(
      FunctionExpression> keySelector,
      EqualityComparer comparer) {
    return factory.groupBy(getThis(), keySelector, comparer);
  }

  @Override public  Queryable> groupBy(
      FunctionExpression> keySelector,
      FunctionExpression> elementSelector) {
    return factory.groupBy(getThis(), keySelector, elementSelector);
  }

  @Override public  Queryable> groupBy(
      FunctionExpression> keySelector,
      FunctionExpression> elementSelector,
      EqualityComparer comparer) {
    return factory.groupBy(getThis(), keySelector, elementSelector, comparer);
  }

  @Override public  Queryable groupByK(
      FunctionExpression> keySelector,
      FunctionExpression, TResult>> resultSelector) {
    return factory.groupByK(getThis(), keySelector, resultSelector);
  }

  @Override public  Queryable groupByK(
      FunctionExpression> keySelector,
      FunctionExpression, TResult>> resultSelector,
      EqualityComparer comparer) {
    return factory.groupByK(getThis(), keySelector, resultSelector, comparer);
  }

  @Override public  Queryable groupBy(
      FunctionExpression> keySelector,
      FunctionExpression> elementSelector,
      FunctionExpression, TResult>> resultSelector) {
    return factory.groupBy(getThis(), keySelector, elementSelector,
        resultSelector);
  }

  @Override public  Queryable groupBy(
      FunctionExpression> keySelector,
      FunctionExpression> elementSelector,
      FunctionExpression, TResult>> resultSelector,
      EqualityComparer comparer) {
    return factory.groupBy(getThis(), keySelector, elementSelector,
        resultSelector, comparer);
  }

  @Override public  Queryable groupJoin(
      Enumerable inner,
      FunctionExpression> outerKeySelector,
      FunctionExpression> innerKeySelector,
      FunctionExpression, TResult>> resultSelector) {
    return factory.groupJoin(getThis(), inner, outerKeySelector,
        innerKeySelector, resultSelector);
  }

  @Override public  Queryable groupJoin(
      Enumerable inner,
      FunctionExpression> outerKeySelector,
      FunctionExpression> innerKeySelector,
      FunctionExpression, TResult>> resultSelector,
      EqualityComparer comparer) {
    return factory.groupJoin(getThis(), inner, outerKeySelector,
        innerKeySelector, resultSelector, comparer);
  }

  @Override public  Queryable join(
      Enumerable inner,
      FunctionExpression> outerKeySelector,
      FunctionExpression> innerKeySelector,
      FunctionExpression> resultSelector) {
    return factory.join(getThis(), inner, outerKeySelector, innerKeySelector,
        resultSelector);
  }

  @Override public  Queryable join(
      Enumerable inner,
      FunctionExpression> outerKeySelector,
      FunctionExpression> innerKeySelector,
      FunctionExpression> resultSelector,
      EqualityComparer comparer) {
    return factory.join(getThis(), inner, outerKeySelector, innerKeySelector,
        resultSelector, comparer);
  }

  @Override public T last(FunctionExpression> predicate) {
    return factory.last(getThis(), predicate);
  }

  @Override public T lastOrDefault(FunctionExpression> predicate) {
    return factory.lastOrDefault(getThis(), predicate);
  }

  @Override public long longCount(FunctionExpression> predicate) {
    return factory.longCount(getThis(), predicate);
  }

  @Override public > TResult max(
      FunctionExpression> selector) {
    return factory.max(getThis(), selector);
  }

  @Override public > TResult min(
      FunctionExpression> selector) {
    return factory.min(getThis(), selector);
  }

  @Override public  OrderedQueryable orderBy(
      FunctionExpression> keySelector) {
    return factory.orderBy(getThis(), keySelector);
  }

  @Override public  OrderedQueryable orderBy(
      FunctionExpression> keySelector,
      Comparator comparator) {
    return factory.orderBy(getThis(), keySelector, comparator);
  }

  @Override public  OrderedQueryable orderByDescending(
      FunctionExpression> keySelector) {
    return factory.orderByDescending(getThis(), keySelector);
  }

  @Override public  OrderedQueryable orderByDescending(
      FunctionExpression> keySelector,
      Comparator comparator) {
    return factory.orderByDescending(getThis(), keySelector, comparator);
  }

  @Override public  Queryable select(
      FunctionExpression> selector) {
    return factory.select(getThis(), selector);
  }

  @Override public  Queryable selectN(
      FunctionExpression> selector) {
    return factory.selectN(getThis(), selector);
  }

  @Override public  Queryable selectMany(
      FunctionExpression>> selector) {
    return factory.selectMany(getThis(), selector);
  }

  @Override public  Queryable selectManyN(
      FunctionExpression>> selector) {
    return factory.selectManyN(getThis(), selector);
  }

  @Override public  Queryable selectMany(
      FunctionExpression>>
        collectionSelector,
      FunctionExpression> resultSelector) {
    return factory.selectMany(getThis(), collectionSelector, resultSelector);
  }

  @Override public  Queryable selectManyN(
      FunctionExpression>>
        collectionSelector,
      FunctionExpression> resultSelector) {
    return factory.selectManyN(getThis(), collectionSelector, resultSelector);
  }

  @Override public T single(FunctionExpression> predicate) {
    return factory.single(getThis(), predicate);
  }

  @Override public @Nullable T singleOrDefault(FunctionExpression> predicate) {
    return factory.singleOrDefault(getThis(), predicate);
  }

  @Override public Queryable skipWhile(FunctionExpression> predicate) {
    return factory.skipWhile(getThis(), predicate);
  }

  @Override public Queryable skipWhileN(
      FunctionExpression> predicate) {
    return factory.skipWhileN(getThis(), predicate);
  }

  @Override public BigDecimal sumBigDecimal(
      FunctionExpression> selector) {
    return factory.sumBigDecimal(getThis(), selector);
  }

  @Override public BigDecimal sumNullableBigDecimal(
      FunctionExpression> selector) {
    return factory.sumNullableBigDecimal(getThis(), selector);
  }

  @Override public double sumDouble(FunctionExpression> selector) {
    return factory.sumDouble(getThis(), selector);
  }

  @Override public Double sumNullableDouble(
      FunctionExpression> selector) {
    return factory.sumNullableDouble(getThis(), selector);
  }

  @Override public int sumInteger(FunctionExpression> selector) {
    return factory.sumInteger(getThis(), selector);
  }

  @Override public Integer sumNullableInteger(
      FunctionExpression> selector) {
    return factory.sumNullableInteger(getThis(), selector);
  }

  @Override public long sumLong(FunctionExpression> selector) {
    return factory.sumLong(getThis(), selector);
  }

  @Override public Long sumNullableLong(
      FunctionExpression> selector) {
    return factory.sumNullableLong(getThis(), selector);
  }

  @Override public float sumFloat(FunctionExpression> selector) {
    return factory.sumFloat(getThis(), selector);
  }

  @Override public Float sumNullableFloat(
      FunctionExpression> selector) {
    return factory.sumNullableFloat(getThis(), selector);
  }

  @Override public Queryable takeWhile(FunctionExpression> predicate) {
    return factory.takeWhile(getThis(), predicate);
  }

  @Override public Queryable takeWhileN(
      FunctionExpression> predicate) {
    return factory.takeWhileN(getThis(), predicate);
  }

  @Override public > OrderedQueryable thenBy(
      FunctionExpression> keySelector) {
    return factory.thenBy(getThisOrderedQueryable(), keySelector);
  }

  @Override public  OrderedQueryable thenBy(
      FunctionExpression> keySelector,
      Comparator comparator) {
    return factory.thenByDescending(getThisOrderedQueryable(), keySelector,
        comparator);
  }

  @Override public > OrderedQueryable thenByDescending(
      FunctionExpression> keySelector) {
    return factory.thenByDescending(getThisOrderedQueryable(), keySelector);
  }

  @Override public  OrderedQueryable thenByDescending(
      FunctionExpression> keySelector,
      Comparator comparator) {
    return factory.thenBy(getThisOrderedQueryable(), keySelector, comparator);
  }

  @Override public Queryable where(
      FunctionExpression> predicate) {
    return factory.where(getThis(), predicate);
  }

  @Override public Queryable whereN(
      FunctionExpression> predicate) {
    return factory.whereN(getThis(), predicate);
  }

  @Override public  Queryable zip(Enumerable source1,
      FunctionExpression> resultSelector) {
    return factory.zip(getThis(), source1, resultSelector);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy