Package com.twilio.kudu.sql
Class CalciteKuduTable
java.lang.Object
org.apache.calcite.schema.impl.AbstractTable
org.apache.calcite.adapter.java.AbstractQueryableTable
com.twilio.kudu.sql.CalciteKuduTable
- All Implemented Interfaces:
org.apache.calcite.schema.QueryableTable
,org.apache.calcite.schema.Table
,org.apache.calcite.schema.TranslatableTable
,org.apache.calcite.schema.Wrapper
- Direct Known Subclasses:
CalciteModifiableKuduTable
public class CalciteKuduTable
extends org.apache.calcite.adapter.java.AbstractQueryableTable
implements org.apache.calcite.schema.TranslatableTable
A
CalciteKuduTable
is responsible for returning rows of Objects back.
It is responsible for calling the RPC layer of Kudu reparsing them into
expected types for the RelTable used in the request.
It requires a KuduTable
to be opened and ready to be used.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Implementation ofQueryable
based on aCalciteKuduTable
. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.kudu.client.AsyncKuduClient
protected final List<CalciteKuduTable>
static final Instant
static final Long
static final Long
protected final CubeTableInfo.EventTimeAggregationType
protected final org.apache.kudu.client.KuduTable
protected final long
protected final TableType
protected final int
Fields inherited from class org.apache.calcite.adapter.java.AbstractQueryableTable
elementType
-
Constructor Summary
ConstructorsConstructorDescriptionCalciteKuduTable
(org.apache.kudu.client.KuduTable kuduTable, org.apache.kudu.client.AsyncKuduClient client, List<Integer> descendingOrderColumnIndexes, int timestampColumnIndex, List<CalciteKuduTable> cubeTables, TableType tableType, CubeTableInfo.EventTimeAggregationType eventTimeAggregationType, long readSnapshotTimeDifference) Create theCalciteKuduTable
for a physical scan over the providedKuduTable
. -
Method Summary
Modifier and TypeMethodDescription<T> org.apache.calcite.linq4j.Queryable<T>
asQueryable
(org.apache.calcite.linq4j.QueryProvider queryProvider, org.apache.calcite.schema.SchemaPlus schema, String tableName) executeQuery
(List<List<CalciteKuduPredicate>> predicates, List<Integer> columnIndices, long limit, long offset, boolean sorted, 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) Run the query against the kudu tablekuduTable
.org.apache.kudu.client.AsyncKuduClient
getDescendingColumnsIndicesInProjection
(org.apache.kudu.Schema projectedSchema) Return the integer indices of the descending sorted columns in the row projection.org.apache.kudu.client.KuduTable
org.apache.calcite.rel.type.RelDataType
getRowType
(org.apache.calcite.rel.type.RelDataTypeFactory typeFactory) Builds a mapping from Kudu Schema into relational schema namesorg.apache.calcite.schema.Statistic
int
boolean
isColumnOrderedDesc
(int columnIndex) boolean
isColumnOrderedDesc
(String columnName) org.apache.calcite.rel.RelNode
toRel
(org.apache.calcite.plan.RelOptTable.ToRelContext context, org.apache.calcite.plan.RelOptTable relOptTable) Methods inherited from class org.apache.calcite.adapter.java.AbstractQueryableTable
getElementType, getExpression
Methods inherited from class org.apache.calcite.schema.impl.AbstractTable
getJdbcTableType, isRolledUp, rolledUpColumnValidInsideAgg, unwrap
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.schema.Table
getJdbcTableType, isRolledUp, rolledUpColumnValidInsideAgg
Methods inherited from interface org.apache.calcite.schema.Wrapper
maybeUnwrap, unwrapOrThrow
-
Field Details
-
EPOCH_DAY_FOR_REVERSE_SORT
-
EPOCH_FOR_REVERSE_SORT_IN_MILLISECONDS
-
EPOCH_FOR_REVERSE_SORT_IN_MICROSECONDS
-
kuduTable
protected final org.apache.kudu.client.KuduTable kuduTable -
client
protected final org.apache.kudu.client.AsyncKuduClient client -
descendingOrderedColumnIndexes
-
timestampColumnIndex
protected final int timestampColumnIndex -
cubeTables
-
tableType
-
eventTimeAggregationType
-
readSnapshotTimeDifference
protected final long readSnapshotTimeDifference
-
-
Constructor Details
-
CalciteKuduTable
public CalciteKuduTable(org.apache.kudu.client.KuduTable kuduTable, org.apache.kudu.client.AsyncKuduClient client, List<Integer> descendingOrderColumnIndexes, int timestampColumnIndex, List<CalciteKuduTable> cubeTables, TableType tableType, CubeTableInfo.EventTimeAggregationType eventTimeAggregationType, long readSnapshotTimeDifference) Create theCalciteKuduTable
for a physical scan over the providedKuduTable
.KuduTable
must exist and be opened. UseCalciteKuduTableBuilder
to build a table instead of this constructor- Parameters:
kuduTable
- the opened kudu tableclient
- kudu client that is used to write mutationsdescendingOrderColumnIndexes
- indexes of columns that are stored in descending ordertimestampColumnIndex
- column index that represents the single timestampcubeTables
- the list of cube tables (if this is a fact table)tableType
- type of this tableeventTimeAggregationType
- How the table is aggregated across time rangesreadSnapshotTimeDifference
- time difference between snapshot to read in past and current time
-
-
Method Details
-
getStatistic
public org.apache.calcite.schema.Statistic getStatistic()- Specified by:
getStatistic
in interfaceorg.apache.calcite.schema.Table
- Overrides:
getStatistic
in classorg.apache.calcite.schema.impl.AbstractTable
-
getRowType
public org.apache.calcite.rel.type.RelDataType getRowType(org.apache.calcite.rel.type.RelDataTypeFactory typeFactory) Builds a mapping from Kudu Schema into relational schema names- Specified by:
getRowType
in interfaceorg.apache.calcite.schema.Table
-
toRel
public org.apache.calcite.rel.RelNode toRel(org.apache.calcite.plan.RelOptTable.ToRelContext context, org.apache.calcite.plan.RelOptTable relOptTable) - Specified by:
toRel
in interfaceorg.apache.calcite.schema.TranslatableTable
-
executeQuery
public KuduEnumerable executeQuery(List<List<CalciteKuduPredicate>> predicates, List<Integer> columnIndices, long limit, long offset, boolean sorted, 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) Run the query against the kudu tablekuduTable
.KuduPredicate
are the filters to apply to the query,columnIndices
are the columns to return in the response and finallylimit
is used to limit the results that come back.- Parameters:
predicates
- each member in the first list represents a single scan.columnIndices
- the fields ordinals to select out of Kudulimit
- process the results until limit is reached. If less then 0, no limitoffset
- skip offset number of rows before returning resultssorted
- whether to return rows in sorted ordergroupBySortedOrLimited
- indicates if the groupBy method should be counting unique keysscanStats
- scan stats collectorcancelFlag
- flag to indicate the query has been canceledprojection
- function to map theRowResult
to calcite objectfilterFunction
- predicate to apply toRowResult
isSingleObject
- boolean indicating if the projection returns Object[] or ObjectsortedPrefixKeySelector
- 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 samesortPkColumns
- the indexes of the primary key columns that are present in the ORDER BY clause- Returns:
- Enumeration on the objects, Fields conform to
getRowType(org.apache.calcite.rel.type.RelDataTypeFactory)
.
-
asQueryable
public <T> org.apache.calcite.linq4j.Queryable<T> asQueryable(org.apache.calcite.linq4j.QueryProvider queryProvider, org.apache.calcite.schema.SchemaPlus schema, String tableName) - Specified by:
asQueryable
in interfaceorg.apache.calcite.schema.QueryableTable
-
isColumnOrderedDesc
-
isColumnOrderedDesc
public boolean isColumnOrderedDesc(int columnIndex) -
getKuduTable
public org.apache.kudu.client.KuduTable getKuduTable() -
getClient
public org.apache.kudu.client.AsyncKuduClient getClient() -
getEventTimeAggregationType
-
getDescendingColumnsIndicesInProjection
public List<Integer> getDescendingColumnsIndicesInProjection(org.apache.kudu.Schema projectedSchema) Return the integer indices of the descending sorted columns in the row projection.- Parameters:
projectedSchema
- the Kudu Schema used in RPC requests- Returns:
- Column indexes in the RPC that are in descending order
-
getCubeTables
-
getTimestampColumnIndex
public int getTimestampColumnIndex() -
getDescendingOrderedColumnIndexes
-
getTableType
-