Class AbstractTableLocation

java.lang.Object
io.deephaven.engine.table.impl.locations.impl.SubscriptionAggregator<TableLocation.Listener>
io.deephaven.engine.table.impl.locations.impl.AbstractTableLocation
All Implemented Interfaces:
LogOutputAppendable, DelegatingLivenessReferent, LivenessReferent, TableLocation, TableLocationState, PushdownFilterMatcher, NamedImplementation
Direct Known Subclasses:
NonexistentTableLocation, ParquetTableLocation, PythonTableDataService.TableLocationImpl

public abstract class AbstractTableLocation extends SubscriptionAggregator<TableLocation.Listener> implements TableLocation, DelegatingLivenessReferent
Partial TableLocation implementation for use by TableDataService implementations.
  • Constructor Details

    • AbstractTableLocation

      protected AbstractTableLocation(@NotNull @NotNull TableKey tableKey, @NotNull @NotNull TableLocationKey tableLocationKey, boolean supportsSubscriptions)
      Parameters:
      tableKey - Table key for the table this location belongs to
      tableLocationKey - Table location key that identifies this location
      supportsSubscriptions - Whether subscriptions are to be supported
  • Method Details

    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • asLivenessReferent

      public LivenessReferent asLivenessReferent()
      Description copied from interface: DelegatingLivenessReferent
      Returns the "real" LivenessReferent instance. When implementing this, care should be taken to match lifecycle of the DelegatingLivenessReferent instance with this instance, as the returned LivenessReferent behaves as a proxy for this.
      Specified by:
      asLivenessReferent in interface DelegatingLivenessReferent
      Returns:
      a LivenessReferent to use to manage this object's liveness.
    • initializeState

      protected void initializeState()
      No-op by default, can be overridden by subclasses to initialize state on first access.

      The expectation for static locations that override this is to call handleUpdateInternal(RowSet, long) instead of handleUpdate(RowSet, long), and handleUpdateInternal(TableLocationState) instead of handleUpdate(TableLocationState) from inside initializeState(). Otherwise, the initialization logic will recurse infinitely.

    • getStateLock

      @NotNull public final @NotNull Object getStateLock()
      Specified by:
      getStateLock in interface TableLocationState
      Returns:
      The Object that accessors should synchronize on if they want to invoke multiple getters with consistent results.
    • getRowSet

      public final RowSet getRowSet()
      Specified by:
      getRowSet in interface TableLocationState
      Returns:
      The (possibly-empty) RowSet of a table location, or null if RowSet information is unknown or does not exist for this table location.
    • getSize

      public final long getSize()
      Specified by:
      getSize in interface TableLocationState
      Returns:
      The size of a table location:
      NULL_SIZE: Size information is unknown or does not exist for this location
      >= 0: The table location exists and has (possibly empty) data
    • getLastModifiedTimeMillis

      public final long getLastModifiedTimeMillis()
      Specified by:
      getLastModifiedTimeMillis in interface TableLocationState
      Returns:
      The last modified time for a table location, in milliseconds from the epoch:
      NULL_TIME: Modification time information is unknown or does not exist for this location
      >= 0: The time this table was last modified, in milliseconds from the UTC epoch
    • getTableKey

      @NotNull public final @NotNull ImmutableTableKey getTableKey()
      Specified by:
      getTableKey in interface TableLocation
      Returns:
      An ImmutableTableKey instance for the enclosing table
    • getKey

      @NotNull public final @NotNull ImmutableTableLocationKey getKey()
      Specified by:
      getKey in interface TableLocation
      Returns:
      An ImmutableTableLocationKey instance for this location
    • deliverInitialSnapshot

      protected final void deliverInitialSnapshot(@NotNull @NotNull TableLocation.Listener listener)
      Description copied from class: SubscriptionAggregator
      Prompt listeners to record current state, under the subscriptions lock.
      Specified by:
      deliverInitialSnapshot in class SubscriptionAggregator<TableLocation.Listener>
      Parameters:
      listener - The listener to notify
    • handleUpdate

      public final void handleUpdate(RowSet rowSet, long lastModifiedTimeMillis)
      See TableLocationState for documentation of values.
      Parameters:
      rowSet - The new RowSet. Ownership passes to this location; callers should copy it if necessary.
      lastModifiedTimeMillis - The new lastModificationTimeMillis
    • handleUpdateInternal

      protected final void handleUpdateInternal(RowSet rowSet, long lastModifiedTimeMillis)
    • handleUpdate

      public void handleUpdate(@NotNull @NotNull TableLocationState source)
      Update all state fields from source's values, as in handleUpdate(RowSet, long). See TableLocationState for documentation of values.
      Parameters:
      source - The source to copy state values from
    • handleUpdateInternal

      protected final void handleUpdateInternal(@NotNull @NotNull TableLocationState source)
    • getColumnLocation

      @NotNull public final @NotNull ColumnLocation getColumnLocation(@NotNull @NotNull CharSequence name)
      Specified by:
      getColumnLocation in interface TableLocation
      Parameters:
      name - The column name
      Returns:
      The ColumnLocation for the defined column under this table location. The exact same ColumnLocation object should be returned for the same column name.
    • makeColumnLocation

      @NotNull protected abstract @NotNull ColumnLocation makeColumnLocation(@NotNull @NotNull String name)
    • clearColumnLocations

      public final void clearColumnLocations()
      Clear all column locations (usually because a truncated location was observed).
    • hasAnyCachedDataIndex

      protected boolean hasAnyCachedDataIndex()
    • hasCachedDataIndex

      public boolean hasCachedDataIndex(@NotNull @NotNull String... columns)
      Description copied from interface: TableLocation
      Check if this TableLocation has a data index for the specified columns already loaded in memory.
      Specified by:
      hasCachedDataIndex in interface TableLocation
      Parameters:
      columns - The set of columns to check for
      Returns:
      Whether the TableLocation has a cached index for the specified columns
    • getDataIndex

      @Nullable public final @Nullable BasicDataIndex getDataIndex(@NotNull @NotNull String... columns)
      Description copied from interface: TableLocation
      Get the data index table for the specified set of columns. Note that the order of columns does not matter here.
      Specified by:
      getDataIndex in interface TableLocation
      Parameters:
      columns - The key columns for the index
      Returns:
      The index table or null if one does not exist
    • loadDataIndex

      @InternalUseOnly @Nullable public abstract @Nullable BasicDataIndex loadDataIndex(@NotNull @NotNull String... columns)
      Load the data index from the location implementation. Implementations of this method should not perform any result caching.
      Parameters:
      columns - The columns to load an index for
      Returns:
      The data index, or null if none exists
      ApiNote:
      This method is public for use in delegating implementations, and should not be called directly otherwise.
    • estimatePushdownFilterCost

      public void estimatePushdownFilterCost(WhereFilter filter, RowSet selection, boolean usePrev, PushdownFilterContext context, JobScheduler jobScheduler, LongConsumer onComplete, Consumer<Exception> onError)
      Description copied from interface: PushdownFilterMatcher
      Estimate the cost of pushing down the next pushdown filter. This returns a unitless value to compare the cost of executing different filters. Common costs are listed in PushdownResult (such as PushdownResult.METADATA_STATS_COST) and should be used as a baseline for estimating the cost of newly implemented pushdown operations.

      A no-op implementation should simply complete with Long.MAX_VALUE.

      Specified by:
      estimatePushdownFilterCost in interface PushdownFilterMatcher
      Parameters:
      filter - The filter to test.
      selection - The set of rows to tests.
      usePrev - Whether to use the previous result
      context - The PushdownFilterContext to use for the pushdown operation.
      jobScheduler - The job scheduler to use for scheduling child jobs
      onComplete - Consumer of the estimated cost of the pushdown operation. 9223372036854775807L indicates that the filter cannot be pushed down.
      onError - Consumer of any exceptions that occur during the estimate operation
    • pushdownFilter

      public void pushdownFilter(WhereFilter filter, RowSet selection, boolean usePrev, PushdownFilterContext context, long costCeiling, JobScheduler jobScheduler, Consumer<PushdownResult> onComplete, Consumer<Exception> onError)
      Description copied from interface: PushdownFilterMatcher
      Push down the given filter to the underlying table and pass the result to the consumer. This method is expected to execute all pushdown filter steps that are greater than PushdownFilterContext.executedFilterCost() and less than or equal to costCeiling.

      The resulting PushdownResult (to onComplete) must only contain rows from selection. The match row set are rows that are guaranteed to match. The implicitly "missing" rows selection - match - maybeMatch are rows that are guaranteed to not match. The remaining maybe match row set are rows that may, or may not, match. The pushdown result ownership passes to onComplete.

      A no-op implementation should simply complete with PushdownResult.maybeMatch(selection).

      Specified by:
      pushdownFilter in interface PushdownFilterMatcher
      Parameters:
      filter - The filter to apply.
      selection - The set of rows to test.
      usePrev - Whether to use the previous result
      context - The PushdownFilterContext to use for the pushdown operation.
      costCeiling - Execute all possible filters with a cost less than or equal this value.
      jobScheduler - The job scheduler to use for scheduling child jobs
      onComplete - Consumer of the output rowsets for added and modified rows that pass the filter
      onError - Consumer of any exceptions that occur during the pushdown operation
    • makePushdownFilterContext

      public PushdownFilterContext makePushdownFilterContext(WhereFilter filter, List<ColumnSource<?>> filterSources)
      Description copied from interface: PushdownFilterMatcher
      Create a pushdown filter context for this entity.
      Specified by:
      makePushdownFilterContext in interface PushdownFilterMatcher
      Parameters:
      filter - the filter to use while making the context
      filterSources - the column sources that match the filter column names
      Returns:
      the created filter context
    • destroy

      protected void destroy()
      The reference count has reached zero, we can clear this location and release any resources.