org.apache.calcite.linq4j.QueryableRecorder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of calcite-linq4j Show documentation
Show all versions of calcite-linq4j Show documentation
Calcite APIs for LINQ (Language-Integrated Query) in Java
The 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 java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.Comparator;
import static org.apache.calcite.linq4j.QueryableDefaults.NonLeafReplayableQueryable;
/**
* Implementation of {@link QueryableFactory} that records each event
* and returns an object that can replay the event when you call its
* {@link org.apache.calcite.linq4j.QueryableDefaults.ReplayableQueryable#replay(QueryableFactory)}
* method.
*
* @param Element type
*/
public class QueryableRecorder implements QueryableFactory {
private static final QueryableRecorder INSTANCE = new QueryableRecorder();
@SuppressWarnings("unchecked")
public static QueryableRecorder instance() {
return INSTANCE;
}
public T aggregate(final Queryable source,
final FunctionExpression> func) {
return new QueryableDefaults.NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.aggregate(source, func);
}
}.single(); // CHECKSTYLE: IGNORE 0
}
public TAccumulate aggregate(final Queryable source,
final TAccumulate seed,
final FunctionExpression> func) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.aggregate(source, seed, func);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public TResult aggregate(final Queryable source,
final TAccumulate seed,
final FunctionExpression> func,
final FunctionExpression> selector) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.aggregate(source, seed, func, selector);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public boolean all(final Queryable source,
final FunctionExpression> predicate) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.all(source, predicate);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public boolean any(final Queryable source) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.any(source);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public boolean any(final Queryable source,
final FunctionExpression> predicate) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.any(source, predicate);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public BigDecimal averageBigDecimal(final Queryable source,
final FunctionExpression> selector) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.averageBigDecimal(source, selector);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public BigDecimal averageNullableBigDecimal(final Queryable source,
final FunctionExpression> selector) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.averageNullableBigDecimal(source, selector);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public double averageDouble(final Queryable source,
final FunctionExpression> selector) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.averageDouble(source, selector);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public Double averageNullableDouble(final Queryable source,
final FunctionExpression> selector) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.averageNullableDouble(source, selector);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public int averageInteger(final Queryable source,
final FunctionExpression> selector) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.averageInteger(source, selector);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public Integer averageNullableInteger(final Queryable source,
final FunctionExpression> selector) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.averageNullableInteger(source, selector);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public float averageFloat(final Queryable source,
final FunctionExpression> selector) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.averageFloat(source, selector);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public Float averageNullableFloat(final Queryable source,
final FunctionExpression> selector) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.averageNullableFloat(source, selector);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public long averageLong(final Queryable source,
final FunctionExpression> selector) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.averageLong(source, selector);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public Long averageNullableLong(final Queryable source,
final FunctionExpression> selector) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.averageNullableLong(source, selector);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public Queryable cast(final Queryable source,
final Class clazz) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.cast(source, clazz);
}
}.castQueryable(); // CHECKSTYLE: IGNORE 0
}
public Queryable concat(final Queryable source,
final Enumerable source2) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.concat(source, source2);
}
};
}
public boolean contains(final Queryable source, final T element) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.contains(source, element);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public boolean contains(final Queryable source, final T element,
final EqualityComparer comparer) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.contains(source, element, comparer);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public int count(final Queryable source) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.count(source);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public int count(final Queryable source,
final FunctionExpression> func) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.count(source, func);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public Queryable defaultIfEmpty(final Queryable source) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.defaultIfEmpty(source);
}
};
}
public Queryable defaultIfEmpty(final Queryable source, final T value) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.defaultIfEmpty(source, value);
}
};
}
public Queryable distinct(final Queryable source) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.distinct(source);
}
};
}
public Queryable distinct(final Queryable source,
final EqualityComparer comparer) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.distinct(source, comparer);
}
};
}
public T elementAt(final Queryable source, final int index) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.elementAt(source, index);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public T elementAtOrDefault(final Queryable source, final int index) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.elementAtOrDefault(source, index);
}
}.castSingle(); // CHECKSTYLE: IGNORE 0
}
public Queryable except(final Queryable source,
final Enumerable enumerable) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.except(source, enumerable);
}
};
}
public Queryable except(final Queryable source,
final Enumerable enumerable, final EqualityComparer comparer) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.except(source, enumerable, comparer);
}
};
}
public T first(final Queryable source) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.first(source);
}
}.single(); // CHECKSTYLE: IGNORE 0
}
public T first(final Queryable source,
final FunctionExpression> predicate) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.first(source, predicate);
}
}.single(); // CHECKSTYLE: IGNORE 0
}
public T firstOrDefault(final Queryable source) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.firstOrDefault(source);
}
}.single(); // CHECKSTYLE: IGNORE 0
}
public T firstOrDefault(final Queryable source,
final FunctionExpression> predicate) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.firstOrDefault(source, predicate);
}
}.single(); // CHECKSTYLE: IGNORE 0
}
public Queryable> groupBy(final Queryable source,
final FunctionExpression> keySelector) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.groupBy(source, keySelector);
}
}.castQueryable(); // CHECKSTYLE: IGNORE 0
}
public Queryable> groupBy(final Queryable source,
final FunctionExpression> keySelector,
final EqualityComparer comparer) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.groupBy(source, keySelector, comparer);
}
}.castQueryable(); // CHECKSTYLE: IGNORE 0
}
public Queryable> groupBy(
final Queryable source,
final FunctionExpression> keySelector,
final FunctionExpression> elementSelector) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.groupBy(source, keySelector, elementSelector);
}
}.castQueryable(); // CHECKSTYLE: IGNORE 0
}
public Queryable> groupBy(
final Queryable source,
final FunctionExpression> keySelector,
final FunctionExpression> elementSelector,
final EqualityComparer comparer) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.groupBy(source, keySelector, elementSelector, comparer);
}
}.castQueryable(); // CHECKSTYLE: IGNORE 0
}
public Queryable groupByK(
final Queryable source,
final FunctionExpression> keySelector,
final FunctionExpression, TResult>> resultSelector) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.groupByK(source, keySelector, resultSelector);
}
}.castQueryable(); // CHECKSTYLE: IGNORE 0
}
public Queryable groupByK(final Queryable source,
final FunctionExpression> keySelector,
final FunctionExpression, TResult>> resultSelector,
final EqualityComparer comparer) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.groupByK(source, keySelector, resultSelector, comparer);
}
}.castQueryable(); // CHECKSTYLE: IGNORE 0
}
public Queryable groupBy(
final Queryable source,
final FunctionExpression> keySelector,
final FunctionExpression> elementSelector,
final FunctionExpression, TResult>> resultSelector) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.groupBy(source, keySelector, elementSelector, resultSelector);
}
}.castQueryable(); // CHECKSTYLE: IGNORE 0
}
public Queryable groupBy(
final Queryable source,
final FunctionExpression> keySelector,
final FunctionExpression> elementSelector,
final FunctionExpression, TResult>> resultSelector,
final EqualityComparer comparer) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.groupBy(source, keySelector, elementSelector, resultSelector,
comparer);
}
}.castQueryable(); // CHECKSTYLE: IGNORE 0
}
public Queryable groupJoin(
final Queryable source, final Enumerable inner,
final FunctionExpression> outerKeySelector,
final FunctionExpression> innerKeySelector,
final FunctionExpression, TResult>> resultSelector) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.groupJoin(source, inner, outerKeySelector, innerKeySelector,
resultSelector);
}
}.castQueryable(); // CHECKSTYLE: IGNORE 0
}
public Queryable groupJoin(
final Queryable source, final Enumerable inner,
final FunctionExpression> outerKeySelector,
final FunctionExpression> innerKeySelector,
final FunctionExpression, TResult>> resultSelector,
final EqualityComparer comparer) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.groupJoin(source, inner, outerKeySelector, innerKeySelector,
resultSelector, comparer);
}
}.castQueryable(); // CHECKSTYLE: IGNORE 0
}
public Queryable intersect(final Queryable source,
final Enumerable enumerable) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.intersect(source, enumerable);
}
};
}
public Queryable intersect(final Queryable source,
final Enumerable enumerable, final EqualityComparer comparer) {
return new NonLeafReplayableQueryable(source) {
public void replay(QueryableFactory factory) {
factory.intersect(source, enumerable, comparer);
}
};
}
public Queryable join(
final Queryable