Package com.twilio.kudu.sql
Class KuduEnumerable
java.lang.Object
org.apache.calcite.linq4j.DefaultEnumerable<T>
org.apache.calcite.linq4j.AbstractEnumerable<Object>
com.twilio.kudu.sql.KuduEnumerable
- All Implemented Interfaces:
CloneableEnumerable<Object>
,Iterable<Object>
,org.apache.calcite.linq4j.Enumerable<Object>
,org.apache.calcite.linq4j.ExtendedEnumerable<Object>
,org.apache.calcite.linq4j.ExtendedOrderedEnumerable<Object>
,org.apache.calcite.linq4j.OrderedEnumerable<Object>
,org.apache.calcite.linq4j.RawEnumerable<Object>
public final class KuduEnumerable
extends org.apache.calcite.linq4j.AbstractEnumerable<Object>
implements CloneableEnumerable<Object>
An
Enumerable
that *can* returns Kudu records in Ascending order on
their primary key. It does so by wrapping a List
of
CalciteKuduEnumerable
, querying each one for their next row and
comparing those rows. This requires each CalciteKuduEnumerable
scan
only one Partition
within the Kudu Table. This
guarantees the first rows coming out of the
AsyncKuduScanner
will return rows sorted by
primary key.-
Field Summary
Modifier and TypeFieldDescriptionfinal boolean
final long
final long
final long
final KuduScanStats
final boolean
-
Constructor Summary
ConstructorDescriptionKuduEnumerable
(List<List<CalciteKuduPredicate>> predicates, List<Integer> columnIndices, org.apache.kudu.client.AsyncKuduClient client, CalciteKuduTable calciteKuduTable, long limit, long offset, boolean sort, boolean groupBySortedOrLimited, KuduScanStats scanStats, AtomicBoolean cancelFlag, org.apache.calcite.linq4j.function.Function1<Object, Object> projection, org.apache.calcite.linq4j.function.Predicate1<Object> filterFunction, boolean isSingleObject, org.apache.calcite.linq4j.function.Function1<Object, Object> sortedPrefixKeySelector, List<Integer> sortPkColumns) A KuduEnumerable is anEnumerable
for Kudu that can be configured to be sorted. -
Method Summary
Modifier and TypeMethodDescriptionclone
(List<List<CalciteKuduPredicate>> conjunctions) Clone this enumerable by merging theCalciteKuduPredicate
into existing set.org.apache.calcite.linq4j.Enumerator<Object>
org.apache.kudu.Schema
<TKey,
TAccumulate, TResult>
org.apache.calcite.linq4j.Enumerable<TResult>groupBy
(org.apache.calcite.linq4j.function.Function1<Object, TKey> keySelector, org.apache.calcite.linq4j.function.Function0<TAccumulate> accumulatorInitializer, org.apache.calcite.linq4j.function.Function2<TAccumulate, Object, TAccumulate> accumulatorAdder, org.apache.calcite.linq4j.function.Function2<TKey, TAccumulate, TResult> resultSelector) org.apache.calcite.linq4j.function.Function1<List<Object>,
org.apache.calcite.linq4j.Enumerable<Object>> nestedJoinPredicates
(org.apache.calcite.rel.core.Join joinNode) Return a function that accepts the Left hand sides rows and creates a newSortableEnumerable
that will match the batch of rows.org.apache.calcite.linq4j.Enumerator<Object>
sortedEnumerator
(List<org.apache.kudu.client.AsyncKuduScanner> scanners, List<org.apache.calcite.linq4j.Enumerator<CalciteRow>> subEnumerables) org.apache.calcite.linq4j.Enumerator<Object>
unsortedEnumerator
(List<org.apache.kudu.client.AsyncKuduScanner> scanners, BlockingQueue<CalciteScannerMessage<CalciteRow>> messages) Methods inherited from class org.apache.calcite.linq4j.AbstractEnumerable
iterator
Methods inherited from class org.apache.calcite.linq4j.DefaultEnumerable
aggregate, aggregate, aggregate, all, any, any, asEnumerable, asOrderedQueryable, asQueryable, average, average, average, average, average, average, average, average, average, average, cast, concat, contains, contains, correlateJoin, count, count, createOrderedEnumerable, defaultIfEmpty, defaultIfEmpty, distinct, distinct, elementAt, elementAtOrDefault, except, except, except, except, first, first, firstOrDefault, firstOrDefault, foreach, getThis, getThisOrdered, groupBy, groupBy, groupBy, groupBy, groupBy, groupBy, groupBy, groupBy, groupBy, groupJoin, groupJoin, hashJoin, hashJoin, hashJoin, hashJoin, intersect, intersect, intersect, intersect, into, last, last, lastOrDefault, lastOrDefault, longCount, longCount, max, max, max, max, max, max, max, max, max, max, max, max, min, min, min, min, min, min, min, min, min, min, min, min, ofType, orderBy, orderBy, orderByDescending, orderByDescending, removeAll, reverse, select, select, selectMany, selectMany, selectMany, selectMany, sequenceEqual, sequenceEqual, single, single, singleOrDefault, singleOrDefault, skip, skipWhile, skipWhile, sortedGroupBy, sum, sum, sum, sum, sum, sum, sum, sum, sum, sum, take, takeWhile, takeWhile, thenBy, thenBy, thenByDescending, thenByDescending, toList, toLookup, toLookup, toLookup, toLookup, toMap, toMap, toMap, toMap, union, union, where, where, zip
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.calcite.linq4j.Enumerable
asQueryable
Methods inherited from interface org.apache.calcite.linq4j.ExtendedEnumerable
aggregate, aggregate, aggregate, all, any, any, asEnumerable, average, average, average, average, average, average, average, average, average, average, cast, concat, contains, contains, correlateJoin, count, count, defaultIfEmpty, defaultIfEmpty, distinct, distinct, elementAt, elementAtOrDefault, except, except, except, except, first, first, firstOrDefault, firstOrDefault, foreach, groupBy, groupBy, groupBy, groupBy, groupBy, groupBy, groupBy, groupBy, groupBy, groupJoin, groupJoin, hashJoin, hashJoin, hashJoin, hashJoin, intersect, intersect, intersect, intersect, into, last, last, lastOrDefault, lastOrDefault, longCount, longCount, max, max, max, max, max, max, max, max, max, max, max, max, min, min, min, min, min, min, min, min, min, min, min, min, ofType, orderBy, orderBy, orderByDescending, orderByDescending, removeAll, reverse, select, select, selectMany, selectMany, selectMany, selectMany, sequenceEqual, sequenceEqual, single, single, singleOrDefault, singleOrDefault, skip, skipWhile, skipWhile, sortedGroupBy, sum, sum, sum, sum, sum, sum, sum, sum, sum, sum, take, takeWhile, takeWhile, toList, toLookup, toLookup, toLookup, toLookup, toMap, toMap, toMap, toMap, union, union, where, where, zip
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Field Details
-
sort
public final boolean sort -
groupBySortedOrLimited
public final boolean groupBySortedOrLimited -
sortedPrefixKeySelector
-
sortPkColumns
-
limit
public final long limit -
offset
public final long offset -
groupFetchLimit
public final long groupFetchLimit -
scanStats
-
-
Constructor Details
-
KuduEnumerable
public KuduEnumerable(List<List<CalciteKuduPredicate>> predicates, List<Integer> columnIndices, org.apache.kudu.client.AsyncKuduClient client, CalciteKuduTable calciteKuduTable, long limit, long offset, boolean sort, boolean groupBySortedOrLimited, KuduScanStats scanStats, AtomicBoolean cancelFlag, org.apache.calcite.linq4j.function.Function1<Object, Object> projection, org.apache.calcite.linq4j.function.Predicate1<Object> filterFunction, boolean isSingleObject, org.apache.calcite.linq4j.function.Function1<Object, Object> sortedPrefixKeySelector, List<Integer> sortPkColumns) A KuduEnumerable is anEnumerable
for Kudu that can be configured to be sorted.- Parameters:
predicates
- list of the filters for each disjoint Kudu ScancolumnIndices
- the column indexes to fetch from the tableclient
- Kudu client that will execute the scanscalciteKuduTable
- table metadata for the scanlimit
- the number of rows this should return. -1 indicates no limitoffset
- the number of rows from kudu to skip prior to returning rowssort
- whether or not have Kudu RPCs come back in sorted by primary keygroupBySortedOrLimited
- when sorted, andExtendedEnumerable.groupBy(Function1, Function0, Function2, Function2)
scanStats
- a container of scan stats that should be updated as the scan executes.cancelFlag
- boolean indicating the end process has asked the query to finish.projection
- function to translateRowResult
into CalcitefilterFunction
- filter applied to everyRowResult
isSingleObject
- whether or not Calcite object is an Object or ansortedPrefixKeySelector
- the subset of columns being sorted by that are a prefix of the primary key of the table, or an empty list if the group by and order by columns are the same (only used if groupBySorted is true)sortPkColumns
- the indexes of the primary key columns that are present in the ORDER BY clause
-
-
Method Details
-
unsortedEnumerator
public org.apache.calcite.linq4j.Enumerator<Object> unsortedEnumerator(List<org.apache.kudu.client.AsyncKuduScanner> scanners, BlockingQueue<CalciteScannerMessage<CalciteRow>> messages) -
sortedEnumerator
public org.apache.calcite.linq4j.Enumerator<Object> sortedEnumerator(List<org.apache.kudu.client.AsyncKuduScanner> scanners, List<org.apache.calcite.linq4j.Enumerator<CalciteRow>> subEnumerables) -
getTableSchema
public org.apache.kudu.Schema getTableSchema() -
enumerator
- Specified by:
enumerator
in interfaceorg.apache.calcite.linq4j.RawEnumerable<Object>
-
groupBy
public <TKey,TAccumulate, org.apache.calcite.linq4j.Enumerable<TResult> groupByTResult> (org.apache.calcite.linq4j.function.Function1<Object, TKey> keySelector, org.apache.calcite.linq4j.function.Function0<TAccumulate> accumulatorInitializer, org.apache.calcite.linq4j.function.Function2<TAccumulate, Object, TAccumulate> accumulatorAdder, org.apache.calcite.linq4j.function.Function2<TKey, TAccumulate, TResult> resultSelector) -
clone
Description copied from interface:CloneableEnumerable
Clone this enumerable by merging theCalciteKuduPredicate
into existing set.- Specified by:
clone
in interfaceCloneableEnumerable<Object>
- Parameters:
conjunctions
- the additional predicates that need to be conjoined to the query.- Returns:
- another
CloneableEnumerable
with the additional conjunctions
-
nestedJoinPredicates
public org.apache.calcite.linq4j.function.Function1<List<Object>,org.apache.calcite.linq4j.Enumerable<Object>> nestedJoinPredicates(org.apache.calcite.rel.core.Join joinNode) Return a function that accepts the Left hand sides rows and creates a newSortableEnumerable
that will match the batch of rows.- Parameters:
joinNode
- TheJoin
relation for this nest join.- Returns:
- a function that produces another
SortableEnumerable
that matches the batches passed in.
-