Interface DynamicTable

All Superinterfaces:
Deflatable<Table>, DynamicNode, LivenessManager, LivenessNode, LivenessReferent, com.fishlib.base.log.LogOutputAppendable, LongSizedDataStructure, NotificationQueue.Dependency, SystemicObject, Table
All Known Implementing Classes:
AppendOnlyArrayBackedMutableTable, BaseTable, ConnectionAwareRemoteTable, DeferredViewTable, HierarchicalTable, InitialSnapshotTable, InMemoryTable, KeyedArrayBackedMutableTable, LiveQueryTable, NestedPartitionedDiskBackedTable, PartitionAwareSourceTable, PreemptiveUpdatesTable, QueryReplayGroupedTable, QueryTable, QueryTable.FilteredTable, RedefinableTable, ReplayGroupedFullTable, ReplayLastByGroupedTable, ReplayTable, ReplicatedTable, SimpleSourceTable, SourceTable, SplayedDiskBackedTable, SubscriptionSnapshotTable, TimeTable, UncoalescedTable, UpdatableTable, WrappedDelegatingTable

public interface DynamicTable
extends Table, NotificationQueue.Dependency, DynamicNode, SystemicObject
A dynamically changing table. The DynamicTable interface provides support for listening for table changes and errors.
  • Method Details

    • silent

      Table silent()

      Return an identical table that suppresses all downstream notifications

      WARNING: Use this feature responsibly. Even though updates are suppressed, that does not imply that the underlying column sources are necessarily static, and so reading data from the table may not be consistent. A safer approach is to use Table.snapshot(Table, String...) or Table.snapshotIncremental(Table, String...)

      Returns:
      a new Table that does not propagate updates downstream.
    • awaitUpdate

      void awaitUpdate() throws InterruptedException

      Wait for updates to this DynamicTable.

      In some implementations, this call may also terminate in case of interrupt or spurious wakeup (see java.util.concurrent.locks.Condition#await()).

      Throws:
      InterruptedException - In the event this thread is interrupted
    • awaitUpdate

      boolean awaitUpdate​(long timeout) throws InterruptedException

      Wait for updates to this DynamicTable.

      In some implementations, this call may also terminate in case of interrupt or spurious wakeup (see java.util.concurrent.locks.Condition#await()).

      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
    • listenForUpdates

      default void listenForUpdates​(Listener listener)
      Subscribe for updates to this table. Listener will be invoked via the LiveTableMonitor notification queue associated with this DynamicTable.
      Parameters:
      listener - listener for updates
    • listenForUpdates

      void listenForUpdates​(Listener listener, boolean replayInitialImage)
      Subscribe for updates to this table. After the optional initial image, listener will be invoked via the LiveTableMonitor notification queue associated with this DynamicTable.
      Parameters:
      listener - listener for updates
      replayInitialImage - true to process updates for all initial rows in the table plus all new row changes; false to only process new row changes
    • listenForUpdates

      void listenForUpdates​(ShiftAwareListener listener)
      Subscribe for updates to this table. Listener will be invoked via the LiveTableMonitor notification queue associated with this DynamicTable.
      Parameters:
      listener - listener for updates
    • listenForDirectUpdates

      void listenForDirectUpdates​(Listener listener)
      Subscribe for updates to this table. Direct listeners are invoked immediately when changes are published, rather than via a LiveTableMonitor notification queue.
      Parameters:
      listener - listener for updates
    • removeUpdateListener

      void removeUpdateListener​(Listener listener)
      Unsubscribe the supplied listener.
      Parameters:
      listener - listener for updates
    • removeUpdateListener

      void removeUpdateListener​(ShiftAwareListener listener)
      Unsubscribe the supplied listener.
      Parameters:
      listener - listener for updates
    • removeDirectUpdateListener

      void removeDirectUpdateListener​(Listener listener)
      Unsubscribe the supplied listener.
      Parameters:
      listener - listener for updates
    • notifyListeners

      default void notifyListeners​(Index added, Index removed, Index modified)
      Initiate update delivery to this table's listeners. Will notify direct listeners before completing, and enqueue notifications for all other listeners.
      Parameters:
      added - index values added to the table
      removed - index values removed from the table
      modified - index values modified in the table.
    • notifyListeners

      void notifyListeners​(ShiftAwareListener.Update update)
      Initiate update delivery to this table's listeners. Will notify direct listeners before completing, and enqueue notifications for all other listeners.
      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 clone for updates they intend to further use.
    • notifyListenersOnError

      void notifyListenersOnError​(Throwable e, @Nullable UpdatePerformanceTracker.Entry sourceEntry)
      Initiate failure delivery to this table's listeners. Will notify direct listeners before completing, and enqueue notifications for all other listeners.
      Parameters:
      e - error
      sourceEntry - performance tracking
    • isFailed

      default boolean isFailed()
      Returns:
      true if this table is in a failure state.
    • newModifiedColumnSet

      default ModifiedColumnSet newModifiedColumnSet​(String... columnNames)
      Retrieve the ModifiedColumnSet that will be used when propagating updates from this table.
      Parameters:
      columnNames - the columns that should belong to the resulting set.
      Returns:
      the resulting ModifiedColumnSet for the given columnNames
    • newModifiedColumnSetTransformer

      default ModifiedColumnSet.Transformer newModifiedColumnSetTransformer​(String[] columnNames, ModifiedColumnSet[] columnSets)
      Create a ModifiedColumnSet.Transformer that can be used to propagate dirty columns from this table to listeners of the table used to construct columnSets. It is an error if columnNames and columnSets are not the same length. The transformer will mark columnSets[i] as dirty if the column represented by columnNames[i] is dirty.
      Parameters:
      columnNames - the source columns
      columnSets - the destination columns in the convenient ModifiedColumnSet form
      Returns:
      a transformer that knows the dirty details
    • newModifiedColumnSetTransformer

      default ModifiedColumnSet.Transformer newModifiedColumnSetTransformer​(DynamicTable resultTable, String... columnNames)
      Create a ModifiedColumnSet.Transformer that can be used to propagate dirty columns from this table to listeners of the provided resultTable.
      Parameters:
      resultTable - the destination table
      columnNames - the columns that map one-to-one with the result table
      Returns:
      a transformer that passes dirty details via an identity mapping
    • newModifiedColumnSetTransformer

      default ModifiedColumnSet.Transformer newModifiedColumnSetTransformer​(DynamicTable resultTable, MatchPair... matchPairs)
      Create a ModifiedColumnSet.Transformer that can be used to propagate dirty columns from this table to listeners of the provided resultTable.
      Parameters:
      resultTable - the destination table
      matchPairs - the columns that map one-to-one with the result table
      Returns:
      a transformer that passes dirty details via an identity mapping
    • newModifiedColumnSetIdentityTransformer

      default ModifiedColumnSet.Transformer newModifiedColumnSetIdentityTransformer​(Map<String,​ColumnSource> newColumns)
      Create a transformer that uses an identity mapping from one ColumnSourceMap to another. The two CSMs must have equivalent column names and column ordering.
      Parameters:
      newColumns - the column source map for result table
      Returns:
      a simple Transformer that makes a cheap, but CSM compatible copy
    • newModifiedColumnSetIdentityTransformer

      default ModifiedColumnSet.Transformer newModifiedColumnSetIdentityTransformer​(DynamicTable other)
      Create a transformer that uses an identity mapping from one DynamicTable to another. The two tables must have equivalent column names and column ordering.
      Parameters:
      other - the result table
      Returns:
      a simple Transformer that makes a cheap, but CSM compatible copy