Class Replayer

java.lang.Object
io.deephaven.engine.table.impl.replay.Replayer
All Implemented Interfaces:
ReplayerInterface, Runnable
Direct Known Subclasses:
DataDrivenReplayer, FixedStepReplayer

public class Replayer extends Object implements ReplayerInterface, Runnable
Replay historical data as simulated real-time data.
  • Field Details

    • startTime

      protected Instant startTime
    • endTime

      protected Instant endTime
  • Constructor Details

    • Replayer

      public Replayer(Instant startTime, Instant endTime)
      Creates a new replayer.
      Parameters:
      startTime - start time
      endTime - end time
  • Method Details

    • start

      public void start()
      Starts replaying data.
      Specified by:
      start in interface ReplayerInterface
    • isDone

      public boolean isDone()
      Has the replayer finished replaying all data.
      Specified by:
      isDone in interface ReplayerInterface
      Returns:
      true if the replayer has finished replaying all data; false otherwise.
    • shutdown

      public void shutdown()
      Shuts down the replayer.
      Specified by:
      shutdown in interface ReplayerInterface
    • waitDone

      public void waitDone(long maxTimeMillis)
      Wait a specified interval for the replayer to complete. If the replayer has not completed by the end of the interval, the method returns.
      Specified by:
      waitDone in interface ReplayerInterface
      Parameters:
      maxTimeMillis - maximum number of milliseconds to wait.
      Throws:
      CancellationException - thread was interrupted.
    • schedule

      public void schedule(TimerTask task, long delayMillis, long periodMillis)
      Schedule a task to execute.
      Specified by:
      schedule in interface ReplayerInterface
      Parameters:
      task - task to execute
      delayMillis - delay in milliseconds before first executing the task
      periodMillis - frequency in milliseconds to execute the task.
    • getClock

      public static Clock getClock(ReplayerInterface replayer)
      Gets a time provider for the replayer. The time provider returns the current replay time.
      Parameters:
      replayer - replayer
      Returns:
      time provider that returns the current replay time.
    • setTime

      public void setTime(long updatedTime)
      Sets the current replay time.
      Specified by:
      setTime in interface ReplayerInterface
      Parameters:
      updatedTime - new replay time.
    • replay

      public Table replay(Table dataSource, String timeColumn)
      Prepares a historical table for replaying.
      Specified by:
      replay in interface ReplayerInterface
      Parameters:
      dataSource - historical table to replay
      timeColumn - column in the table containing timestamps
      Returns:
      dynamic, replayed version of the table.
    • replayGrouped

      public Table replayGrouped(Table dataSource, String timeColumn, String groupingColumn)
      Prepares a grouped historical table for replaying. This method can be faster than the ungrouped replay, but the performance increase comes with a cost. Within a group, the data ordering is maintained. Between groups, data ordering is not maintained for a time interval.
      Specified by:
      replayGrouped in interface ReplayerInterface
      Parameters:
      dataSource - historical table to replay
      timeColumn - column in the table containing timestamps
      Returns:
      dynamic, replayed version of the table.
    • replayGroupedLastBy

      public Table replayGroupedLastBy(Table dataSource, String timeColumn, String... groupingColumns)
      Prepares a grouped historical table for replaying as a last-by table.
      Specified by:
      replayGroupedLastBy in interface ReplayerInterface
      Parameters:
      dataSource - historical table to replay
      timeColumn - column in the table containing timestamps
      groupingColumns - columns used as the key in computing last-by
      Returns:
      dynamic, replayed version of the last-by table.
    • registerTimeSource

      public void registerTimeSource(RowSet rowSet, ColumnSource<Instant> timestampSource)
      Register the time column and row set from a new table to replay. Most users will use replay, replayGrouped, or replayGroupedLastBy instead of this function.
      Parameters:
      rowSet - table row set
      timestampSource - column source containing time information.
    • run

      public void run()
      Refresh the simulated live tables.
      Specified by:
      run in interface Runnable
    • getHandle

      public ReplayerHandle getHandle()
      Gets a handle to the replayer.
      Specified by:
      getHandle in interface ReplayerInterface
      Returns:
      handle to the replayer.
    • clock

      public Clock clock()
      Specified by:
      clock in interface ReplayerInterface