public abstract class Extensions extends Object
We have preserved most of the API. But we've changed a few things, so that the API is more typical Java API:
Expressions.break_(org.apache.calcite.linq4j.tree.LabelTarget)Enumerable, similar to LINQ.NET's
IEnumerable. IEnumerable is built into C#, and that gives it
advantages: the standard collections implement it, and you can use
any IEnumerable in a foreach loop. We made the Java
Enumerable extend Iterable,
so that it can be used in for-each loops. But the standard
collections still don't implement it. A few methods that take an
IEnumerable in LINQ.NET take an Iterable in LINQ4J.ToDictionary methods become
toMap.NullableLongFunction1 and
LongFunction1, and the
variants of ExtendedEnumerable.sum(org.apache.calcite.linq4j.function.BigDecimalFunction1<TSource>) that call them.
averageDouble,
averageInteger,
groupByK,
selectN,
selectManyN,
skipWhileN,
sumBigDecimal,
sumNullableBigDecimal,
whereN
have been renamed from average, groupBy, max,
min, select, selectMany, skipWhile and
where to prevent ambiguity.IQueryable and IEnumerable interfaces have many such methods.
In Java, those methods need to be explicitly added to the interface, and will
need to be implemented by every class that implements that interface.
We can help by implementing the methods as static methods, and by
providing an abstract base class that implements the extension methods
in the interface. Hence AbstractEnumerable and
AbstractQueryable call methods in Extensions.Function0,
Function1,
Function2, depending
on the number of arguments to the function, because Java types cannot be
overloaded based on the number of type parameters.Int32 → int or Integer,
Int64 → long or Long,
bool → boolean or Boolean,
Dictionary → Map,
Lookup → Map whose value type is an Iterable,
Func<T, bool> becomes Func1<T, Boolean>.
It would be wrong to infer that the function is allowed to return null.| Modifier | Constructor and Description |
|---|---|
private |
Extensions() |
| Modifier and Type | Method and Description |
|---|---|
static <T> Queryable<T> |
asQueryable(DefaultEnumerable<T> source) |
(package private) static <T extends Comparable<T>> |
comparableComparator() |
static RuntimeException |
todo() |
static final Function2<BigDecimal,BigDecimal,BigDecimal> BIG_DECIMAL_SUM
static final Function2<Comparable,Comparable,Comparable> COMPARABLE_MIN
static final Function2<Comparable,Comparable,Comparable> COMPARABLE_MAX
public static RuntimeException todo()
public static <T> Queryable<T> asQueryable(DefaultEnumerable<T> source)
static <T extends Comparable<T>> Comparator<T> comparableComparator()
Copyright © 2012–2021 The Apache Software Foundation. All rights reserved.