Class BaseTable<IMPL_TYPE extends BaseTable<IMPL_TYPE>>

All Implemented Interfaces:
TableOperations<Table,Table>, TableOperationsDefaults<Table,Table>, LogOutputAppendable, LivenessManager, LivenessNode, LivenessReferent, AttributeMap<Table>, GridAttributes<Table>, NotificationStepReceiver, NotificationStepSource, TableDefaults, Table, DynamicNode, NotificationQueue.Dependency, SystemicObject<Table>, LongSizedDataStructure, Serializable
Direct Known Subclasses:
QueryTable, UncoalescedTable

public abstract class BaseTable<IMPL_TYPE extends BaseTable<IMPL_TYPE>> extends BaseGridAttributes<Table,IMPL_TYPE> implements TableDefaults, NotificationStepReceiver, NotificationStepSource
Base abstract class all standard table implementations.
See Also:
  • Field Details

    • VALIDATE_UPDATE_OVERLAPS

      public static final boolean VALIDATE_UPDATE_OVERLAPS
    • definition

      protected final TableDefinition definition
      This table's definition.
    • description

      protected final String description
      This table's description.
    • updateGraph

      protected final UpdateGraph updateGraph
      This table's update graph.
  • Constructor Details

    • BaseTable

      public BaseTable(@NotNull @NotNull TableDefinition definition, @NotNull @NotNull String description, @Nullable @Nullable Map<String,Object> attributes)
      Parameters:
      definition - The definition for this table
      description - A description of this table
      attributes - The attributes map to use, or else null to allocate a new one
  • Method Details

    • getDefinition

      public TableDefinition getDefinition()
      Specified by:
      getDefinition in interface Table
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface Table
    • getUpdateGraph

      public UpdateGraph getUpdateGraph()
      Specified by:
      getUpdateGraph in interface NotificationQueue.Dependency
      Returns:
      the update graph that this dependency is a part of
    • toString

      public String toString()
      Overrides:
      toString in class ReferenceCounted
    • append

      public LogOutput append(@NotNull @NotNull LogOutput logOutput)
      Specified by:
      append in interface LogOutputAppendable
      Overrides:
      append in class ReferenceCounted
    • shouldCopyAttribute

      public static boolean shouldCopyAttribute(String attrName, BaseTable.CopyAttributeOperation copyType)
    • copyAttributes

      public void copyAttributes(BaseTable<?> dest, BaseTable.CopyAttributeOperation copyType)
      Copy this table's attributes to the specified table. Attributes will be copied based upon the input BaseTable.CopyAttributeOperation.
      Parameters:
      dest - The table to copy attributes to
      copyType - The operation being performed that requires attributes to be copied.
    • copyAttributes

      public void copyAttributes(BaseTable<?> dest, Predicate<String> shouldCopy)
      Copy this table's attributes to the specified table. Attributes are copied based on a predicate.
      Parameters:
      dest - The table to copy attributes to
      shouldCopy - should we copy this attribute?
    • isAddOnly

      public boolean isAddOnly()
      Returns true if this table is static, or has an attribute asserting that no modifies, shifts, or removals are generated.
      Returns:
      true if this table does not produce modifications, shifts, or removals
    • isAppendOnly

      public boolean isAppendOnly()
      Returns true if this table is append-only, or has an attribute asserting that no modifies, shifts, or removals are generated and that all new rows are added to the end of the table.
      Returns:
      true if this table may only append rows at the end of the table
    • isBlink

      public boolean isBlink()
      Returns true if this table is a blink table.
      Returns:
      Whether this table is a blink table
      See Also:
    • removeBlink

      public Table removeBlink()
      Description copied from interface: Table
      If this table is a blink table, i.e. it has Table.BLINK_TABLE_ATTRIBUTE set to true, return a child without the attribute, restoring standard semantics for aggregation operations.
      Specified by:
      removeBlink in interface Table
      Returns:
      A non-blink child table, or this table if it is not a blink table
    • addParentReference

      public final void addParentReference(@NotNull @NotNull Object parent)
      Description copied from interface: DynamicNode
      Called on a dependent node to ensure that a strong reference is maintained to any parent object that is required for the proper maintenance and functioning of the dependent. In the most common case, the parent object is a child listener to a parent node. The parent node only keeps a weak reference to its child listener, but the listener maintains a strong reference to the parent node. In this scenario, the only strong reference to the listener (and thus indirectly to the parent node itself) is the reference kept by the dependent node.
      Specified by:
      addParentReference in interface DynamicNode
      Parameters:
      parent - A parent of this node
    • satisfied

      public boolean satisfied(long step)
      Description copied from interface: NotificationQueue.Dependency
      Is this ancestor satisfied? Note that this method must be safe to call on any thread.
      Specified by:
      satisfied in interface NotificationQueue.Dependency
      Parameters:
      step - The step for which we are testing satisfaction
      Returns:
      Whether the dependency is satisfied on step (and will not fire subsequent notifications)
    • awaitUpdate

      public void awaitUpdate() throws InterruptedException
      Description copied from interface: Table

      Wait for updates to this Table. Should not be invoked from a TableListener or other notification on this Table's update graph. It may be suitable to wait from another update graph if doing so does not introduce any cycles.

      In some implementations, this call may also terminate in case of interrupt or spurious wakeup.

      Specified by:
      awaitUpdate in interface Table
      Throws:
      InterruptedException - In the event this thread is interrupted
      See Also:
    • awaitUpdate

      public boolean awaitUpdate(long timeout) throws InterruptedException
      Description copied from interface: Table

      Wait for updates to this Table. Should not be invoked from a TableListener or other notification on this Table's update graph. It may be suitable to wait from another update graph if doing so does not introduce any cycles.

      In some implementations, this call may also terminate in case of interrupt or spurious wakeup.

      Specified by:
      awaitUpdate in interface Table
      Parameters:
      timeout - The maximum time to wait in milliseconds.
      Returns:
      false if the timeout elapses without notification, true otherwise.
      Throws:
      InterruptedException - In the event this thread is interrupted
      See Also:
    • addUpdateListener

      public void addUpdateListener(ShiftObliviousListener listener, boolean replayInitialImage)
      Description copied from interface: Table
      Subscribe for updates to this table. After the optional initial image, listener will be invoked via the NotificationQueue associated with this Table.
      Specified by:
      addUpdateListener in interface Table
      Parameters:
      listener - listener for updates
      replayInitialImage - true to process updates for all initial rows in the table plus all changes; false to only process changes
    • addUpdateListener

      public void addUpdateListener(@NotNull @NotNull TableUpdateListener listener)
      Description copied from interface: Table
      Subscribe for updates to this table. listener will be invoked via the NotificationQueue associated with this Table.
      Specified by:
      addUpdateListener in interface Table
      Parameters:
      listener - listener for updates
    • addUpdateListener

      public boolean addUpdateListener(@NotNull @NotNull TableUpdateListener listener, long requiredLastNotificationStep)
      Description copied from interface: Table
      Subscribe for updates to this table if its last notification step matches requiredLastNotificationStep. listener will be invoked via the NotificationQueue associated with this Table.
      Specified by:
      addUpdateListener in interface Table
      Parameters:
      listener - listener for updates
      requiredLastNotificationStep - the expected last notification step to match
      Returns:
      true if the listener was added, false if the last notification step requirement was not met
    • removeUpdateListener

      public void removeUpdateListener(ShiftObliviousListener listenerToRemove)
      Description copied from interface: Table
      Unsubscribe the supplied listener.
      Specified by:
      removeUpdateListener in interface Table
      Parameters:
      listenerToRemove - listener for updates
    • removeUpdateListener

      public void removeUpdateListener(TableUpdateListener listenerToRemove)
      Description copied from interface: Table
      Unsubscribe the supplied listener.
      Specified by:
      removeUpdateListener in interface Table
      Parameters:
      listenerToRemove - listener for updates
    • isRefreshing

      public final boolean isRefreshing()
      Description copied from interface: DynamicNode
      Is the node updating?
      Specified by:
      isRefreshing in interface DynamicNode
      Specified by:
      isRefreshing in interface Table
      Returns:
      true if the node is updating; false otherwise.
    • setRefreshing

      public final boolean setRefreshing(boolean refreshing)
      Description copied from interface: DynamicNode
      Change the node's run mode.
      Specified by:
      setRefreshing in interface DynamicNode
      Parameters:
      refreshing - true to cause the node to update; false otherwise.
      Returns:
      new refreshing state
    • isFailed

      public boolean isFailed()
      Specified by:
      isFailed in interface Table
      Returns:
      true if this table is in a failure state.
    • hasListeners

      public boolean hasListeners()
    • notifyListeners

      public final void notifyListeners(RowSet added, RowSet removed, RowSet modified)
      Initiate update delivery to this table's listeners by enqueueing update notifications.
      Parameters:
      added - Row keys added to the table
      removed - Row keys removed from the table
      modified - Row keys modified in the table
    • notifyListeners

      public final void notifyListeners(TableUpdate update)
      Initiate update delivery to this table's listeners by enqueueing update notifications.
      Parameters:
      update - The set of table changes to propagate. The caller gives this update object away; the invocation of notifyListeners takes ownership, and will call release on it once it is not used anymore; callers should pass a copy for updates they intend to further use.
    • notifyListenersOnError

      public final void notifyListenersOnError(Throwable e, @Nullable TableListener.Entry sourceEntry)
      Initiate failure delivery to this table's listeners by enqueueing error notifications.
      Parameters:
      e - error
      sourceEntry - performance tracking
    • getNotificationQueue

      protected NotificationQueue getNotificationQueue()
      Get the notification queue to insert notifications into as they are generated by listeners during notifyListeners(io.deephaven.engine.rowset.RowSet, io.deephaven.engine.rowset.RowSet, io.deephaven.engine.rowset.RowSet) and notifyListenersOnError(Throwable, TableListener.Entry). This method may be overridden to provide a different notification queue than the table's PeriodicUpdateGraph instance for more complex behavior.
      Returns:
      The NotificationQueue to add to
    • getLastNotificationStep

      public long getLastNotificationStep()
      Description copied from interface: NotificationStepSource
      Get the last logical clock step on which this element dispatched a notification.
      Specified by:
      getLastNotificationStep in interface NotificationStepSource
      Returns:
      The last notification step
    • setLastNotificationStep

      public void setLastNotificationStep(long lastNotificationStep)
      Description copied from interface: NotificationStepReceiver
      Deliver a last notification step to this receiver.
      Specified by:
      setLastNotificationStep in interface NotificationStepReceiver
      Parameters:
      lastNotificationStep - The last notification step to be delivered
    • isSystemicObject

      public boolean isSystemicObject()
      Description copied from interface: SystemicObject
      Returns true if this is a systemically important object (see SystemicObjectTracker).
      Specified by:
      isSystemicObject in interface SystemicObject<IMPL_TYPE extends BaseTable<IMPL_TYPE>>
      Returns:
      true if this is a systemically important object, false otherwise.
    • markSystemic

      public Table markSystemic()
      Description copied from interface: SystemicObject
      Mark this object as systemically important.
      Specified by:
      markSystemic in interface SystemicObject<IMPL_TYPE extends BaseTable<IMPL_TYPE>>
    • withKeys

      public Table withKeys(String... columns)
      Description copied from interface: Table
      Set the table's key columns.
      Specified by:
      withKeys in interface Table
      Returns:
      A copy of this table with the key columns specified, or this if no change was needed
    • withUniqueKeys

      public Table withUniqueKeys(String... columns)
      Description copied from interface: Table
      Set the table's key columns and indicate that each key set will be unique.
      Specified by:
      withUniqueKeys in interface Table
      Returns:
      A copy of this table with the unique key columns specified, or this if no change was needed
    • checkAvailableColumns

      public final void checkAvailableColumns(@NotNull @NotNull Collection<String> columns)
      Description copied from class: BaseGridAttributes
      Check this grid to ensure that all columns are present.
      Specified by:
      checkAvailableColumns in class BaseGridAttributes<Table,IMPL_TYPE extends BaseTable<IMPL_TYPE>>
      Parameters:
      columns - The column names to check
    • copySortableColumns

      public void copySortableColumns(@NotNull @NotNull BaseGridAttributes<?,?> destination, @NotNull @NotNull Predicate<String> shouldCopy)
    • setTotalsTable

      public Table setTotalsTable(String directive)
      Description copied from interface: Table
      Set a totals table for this Table.
      Specified by:
      setTotalsTable in interface Table
      Parameters:
      directive - A packed string of totals table instructions
      Returns:
      A copy of this Table with the totals table attribute set
    • initializeWithSnapshot

      public static void initializeWithSnapshot(@NotNull @NotNull String logPrefix, @Nullable ConstructSnapshot.SnapshotControl snapshotControl, @NotNull ConstructSnapshot.SnapshotFunction snapshotFunction)
    • createSnapshotControlIfRefreshing

      @Nullable public <T extends OperationSnapshotControl> T createSnapshotControlIfRefreshing(BaseTable.SnapshotControlFactory<T> factory)
      If we are a refreshing table, then we should create a snapshot control to validate the snapshot.

      Otherwise, we return null.

      Returns:
      a snapshot control to snapshot this table (or null)
    • destroy

      protected void destroy()
      Description copied from class: ReferenceCountedLivenessReferent
      Attempt to release (destructively when necessary) resources held by this object. This may render the object unusable for subsequent operations. Implementations should be sure to call super.destroy().

      This is intended to only ever be used as a side effect of decreasing the reference count to 0.

      Overrides:
      destroy in class ReferenceCountedLivenessReferent