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.
  • Field Details

    • EPOCH_DAY_FOR_REVERSE_SORT

      public static final Instant EPOCH_DAY_FOR_REVERSE_SORT
    • EPOCH_FOR_REVERSE_SORT_IN_MILLISECONDS

      public static final Long EPOCH_FOR_REVERSE_SORT_IN_MILLISECONDS
    • EPOCH_FOR_REVERSE_SORT_IN_MICROSECONDS

      public static final Long 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

      protected final List<Integer> descendingOrderedColumnIndexes
    • timestampColumnIndex

      protected final int timestampColumnIndex
    • cubeTables

      protected final List<CalciteKuduTable> cubeTables
    • tableType

      protected final TableType tableType
    • eventTimeAggregationType

      protected final CubeTableInfo.EventTimeAggregationType 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 the CalciteKuduTable for a physical scan over the providedKuduTable. KuduTable must exist and be opened. Use CalciteKuduTableBuilder to build a table instead of this constructor
      Parameters:
      kuduTable - the opened kudu table
      client - kudu client that is used to write mutations
      descendingOrderColumnIndexes - indexes of columns that are stored in descending order
      timestampColumnIndex - column index that represents the single timestamp
      cubeTables - the list of cube tables (if this is a fact table)
      tableType - type of this table
      eventTimeAggregationType - How the table is aggregated across time ranges
      readSnapshotTimeDifference - 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 interface org.apache.calcite.schema.Table
      Overrides:
      getStatistic in class org.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 interface org.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 interface org.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 table kuduTable. KuduPredicate are the filters to apply to the query, columnIndices are the columns to return in the response and finally limit 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 Kudu
      limit - process the results until limit is reached. If less then 0, no limit
      offset - skip offset number of rows before returning results
      sorted - whether to return rows in sorted order
      groupBySortedOrLimited - indicates if the groupBy method should be counting unique keys
      scanStats - scan stats collector
      cancelFlag - flag to indicate the query has been canceled
      projection - function to map the RowResult to calcite object
      filterFunction - predicate to apply to RowResult
      isSingleObject - boolean indicating if the projection returns Object[] or Object
      sortedPrefixKeySelector - 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
      sortPkColumns - 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 interface org.apache.calcite.schema.QueryableTable
    • isColumnOrderedDesc

      public boolean isColumnOrderedDesc(String columnName)
    • isColumnOrderedDesc

      public boolean isColumnOrderedDesc(int columnIndex)
    • getKuduTable

      public org.apache.kudu.client.KuduTable getKuduTable()
    • getClient

      public org.apache.kudu.client.AsyncKuduClient getClient()
    • getEventTimeAggregationType

      public CubeTableInfo.EventTimeAggregationType 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

      public List<CalciteKuduTable> getCubeTables()
    • getTimestampColumnIndex

      public int getTimestampColumnIndex()
    • getDescendingOrderedColumnIndexes

      public List<Integer> getDescendingOrderedColumnIndexes()
    • getTableType

      public TableType getTableType()