Class DataIndexer

java.lang.Object
io.deephaven.engine.table.impl.indexer.DataIndexer
All Implemented Interfaces:
TrackingRowSet.Indexer

public class DataIndexer extends Object implements TrackingRowSet.Indexer
Indexer that provides single and multi-column clustering indexes for a table, linked to a TrackingRowSet.
ApiNote:
DataIndexers should not be used after the host TrackingRowSet has been closed.
  • Method Details

    • existingOf

      public static DataIndexer existingOf(@NotNull @NotNull TrackingRowSet rowSet)
      DataIndexer lookup method. Use this call when you will query from the returned DataIndexer but not add new ones.
      Parameters:
      rowSet - The row set to index
      Returns:
      The DataIndexer for rowSet, or null if none exists
    • of

      public static DataIndexer of(@NotNull @NotNull TrackingRowSet rowSet)
      DataIndexer factory method. Use this call when you will add indexes to the returned DataIndexer.
      Parameters:
      rowSet - The row set to index
      Returns:
      The DataIndexer for rowSet, created by this call if necessary
    • hasDataIndex

      public static boolean hasDataIndex(@NotNull @NotNull Table table, @NotNull @NotNull String... keyColumnNames)
      Test whether table has a DataIndexer with a usable DataIndex for the given key columns. Note that a result from this method is a snapshot of current state, and does not guarantee anything about future calls to hasDataIndex(io.deephaven.engine.table.Table, java.lang.String...), getDataIndex(io.deephaven.engine.table.Table, java.lang.String...), or getOrCreateDataIndex(Table, String...).
      Parameters:
      table - The Table to check
      keyColumnNames - The key column names to check
      Returns:
      Whether table has a DataIndexer with a DataIndex for the given key columns
    • hasDataIndex

      public static boolean hasDataIndex(@NotNull @NotNull Table table, @NotNull @NotNull Collection<String> keyColumnNames)
      Test whether table has a DataIndexer with a usable DataIndex for the given key columns. Note that a result from this method is a snapshot of current state, and does not guarantee anything about future calls to hasDataIndex(io.deephaven.engine.table.Table, java.lang.String...), getDataIndex(io.deephaven.engine.table.Table, java.lang.String...), or getOrCreateDataIndex(Table, String...).
      Parameters:
      table - The Table to check
      keyColumnNames - The key column names to check
      Returns:
      Whether table has a DataIndexer with a DataIndex for the given key columns
    • hasDataIndex

      public boolean hasDataIndex(@NotNull @NotNull ColumnSource<?>... keyColumns)
      Test whether this DataIndexer has a usable DataIndex for the given key columns. Note that a result from this method is a snapshot of current state, and does not guarantee anything about future calls to hasDataIndex(io.deephaven.engine.table.Table, java.lang.String...), getDataIndex(io.deephaven.engine.table.Table, java.lang.String...), or getOrCreateDataIndex(Table, String...).
      Parameters:
      keyColumns - The key columns to check
      Returns:
      Whether this DataIndexer has a DataIndex for the given key columns
    • hasDataIndex

      public boolean hasDataIndex(@NotNull @NotNull Collection<ColumnSource<?>> keyColumns)
      Test whether this DataIndexer has a usable DataIndex for the given key columns. Note that a result from this method is a snapshot of current state, and does not guarantee anything about future calls to hasDataIndex(io.deephaven.engine.table.Table, java.lang.String...), getDataIndex(io.deephaven.engine.table.Table, java.lang.String...), or getOrCreateDataIndex(Table, String...).
      Parameters:
      keyColumns - The key columns to check
      Returns:
      Whether this DataIndexer has a DataIndex for the given key columns
    • getDataIndex

      @Nullable public static @Nullable DataIndex getDataIndex(@NotNull @NotNull Table table, String... keyColumnNames)
      If table has a DataIndexer, return a DataIndex for the given key columns, or null if no such index exists, if the cached index is invalid, or if the refreshing cached index is no longer live.
      Parameters:
      table - The Table to check
      keyColumnNames - The key columns for which to retrieve a DataIndex
      Returns:
      The DataIndex, or null if one does not exist
    • getDataIndex

      @Nullable public static @Nullable DataIndex getDataIndex(@NotNull @NotNull Table table, Collection<String> keyColumnNames)
      If table has a DataIndexer, return a DataIndex for the given key columns, or null if no such index exists, if the cached index is invalid, or if the refreshing cached index is no longer live.
      Parameters:
      table - The Table to check
      keyColumnNames - The key columns for which to retrieve a DataIndex
      Returns:
      The DataIndex, or null if one does not exist
    • getDataIndex

      public DataIndex getDataIndex(@NotNull @NotNull ColumnSource<?>... keyColumns)
      Return a DataIndex for the given key columns, or null if no such index exists, if the cached index is invalid, or if the refreshing cached index is no longer live.
      Parameters:
      keyColumns - The column sources for which to retrieve a DataIndex
      Returns:
      The DataIndex, or null if one does not exist
    • getDataIndex

      public DataIndex getDataIndex(@NotNull @NotNull Collection<ColumnSource<?>> keyColumns)
      Return a DataIndex for the given key columns, or null if no such index exists, if the cached index is invalid, or if the refreshing cached index is no longer live.
      Parameters:
      keyColumns - The column sources for which to retrieve a DataIndex
      Returns:
      The DataIndex, or null if one does not exist
    • getOptimalPartialIndex

      @Nullable public static @Nullable DataIndex getOptimalPartialIndex(Table table, String... keyColumnNames)
      Return a valid, live DataIndex for a strict subset of the given key columns, or null if no such index exists. Will choose the DataIndex that results in the largest index table, following the assumption that the largest index table will divide the source table into the most specific partitions.
      Parameters:
      table - The indexed Table
      keyColumnNames - The key column names to include
      Returns:
      The optimal partial DataIndex, or null if no such index exists
    • getOrCreateDataIndex

      public static DataIndex getOrCreateDataIndex(@NotNull @NotNull Table table, @NotNull @NotNull String... keyColumnNames)
      Create a DataIndex for table indexing keyColumns, if no valid, live data index already exists for these inputs.
      Parameters:
      table - The Table to index
      keyColumnNames - The key column names to include
      Returns:
      The existing or newly created DataIndex
      ApiNote:
      This method causes the returned DataIndex to be managed by the enclosing liveness manager.
    • getOrCreateDataIndex

      public static DataIndex getOrCreateDataIndex(@NotNull @NotNull Table table, @NotNull @NotNull Collection<String> keyColumnNames)
      Create a DataIndex for table indexing keyColumns, if no valid, live data index already exists for these inputs.
      Parameters:
      table - The Table to index
      keyColumnNames - The key column names to include
      Returns:
      The existing or newly created DataIndex
      ApiNote:
      This method causes the returned DataIndex to be managed by the enclosing liveness manager.
    • addDataIndex

      public void addDataIndex(@NotNull @NotNull DataIndex dataIndex)
      Add a DataIndex to this DataIndexer.
      Parameters:
      dataIndex - The DataIndex to add
      Throws:
      IllegalStateException - If a valid, live DataIndex already exists for the given key columns
    • dataIndexes

      public List<DataIndex> dataIndexes(boolean ensureValidAndLive)
      Parameters:
      ensureValidAndLive - Whether to ensure that returned DataIndexes are valid and live
      Returns:
      All the DataIndexes in this DataIndexer