Class ReplayDatabase

java.lang.Object
io.deephaven.enterprise.replay.ReplayDatabase
All Implemented Interfaces:
Database
Direct Known Subclasses:
WritableReplayDatabase

public class ReplayDatabase extends Object implements Database
The ReplayDatabase wraps another Database implementation; applying ClockFilters to liveTables before returning them to the user. This can be used to operate a persistent query as if it were running from a prior day's data for debugging, performance testing, or demos.
  • Constructor Details

    • ReplayDatabase

      public ReplayDatabase(@NotNull @NotNull Clock replayClock, @NotNull @NotNull Database wrapped, @NotNull io.deephaven.shadow.enterprise.com.illumon.iris.db.tables.databases.ReplaySettings replaySettings, @NotNull @NotNull ReplayConfiguration replayConfiguration)
      Create a new ReplayDatabase that wraps an underlying database.

      The Database.liveTable(String, String, TableOptions) and Database.livePartitionedTable(String, String, TableOptions) are wrapped to present existing data as ticking data. The Database.historicalTable(String, String) family of methods are not changed.

      Tables must have a column of type Instant or ZonedDateTime to use as a timestamp source. If a table has multiple timestamps, then the ReplayConfigurationImpl must define the name of the Timestamp column for that table. When launched from a Persistent Query, the ReplayConfigurationImpl Timestamp columns are derived from properties of the form (in descending priority):

      • ReplayDatabase.TimestampColumn.Namespace.TableName
      • ReplayDatabase.TimestampColumn.Namespace
      • ReplayDatabase.TimestampColumn

      All historical tables are read from the historical store, for a live table the default is to read the historical store and replay the historical table. Alternatively, live tables can read from live tables on the replay date based on the ReplayConfigurationImpl. When launched from a Persistent Query, the ReplayConfigurationImpl values are derived from properties of the form (in descending priority):

      • ReplayDatabase.UseIntraday.Namespace.TableName
      • ReplayDatabase.UseIntraday.Namespace
      • ReplayDatabase.UseIntraday
      Parameters:
      replayClock - the clock for replaying data
      wrapped - the Database to wrap
      replaySettings - the replay settings from the persistent query
      replayConfiguration - the per-table replay configuration
  • Method Details

    • liveTable

      public Table liveTable(@NotNull @NotNull String namespace, @NotNull @NotNull String tableName, @NotNull @NotNull TableOptions options)
      Description copied from interface: Database
      Fetch a live Table for the specified namespace and table name.
      Specified by:
      liveTable in interface Database
      Parameters:
      namespace - the Namespace in which the table exists
      tableName - the name of the table in the Namespace.
      options - a TableOptions to set table options.
      Returns:
      a new live Table for the specified parameters.
    • livePartitionedTable

      public PartitionedTable livePartitionedTable(@NotNull @NotNull String namespace, @NotNull @NotNull String tableName, @NotNull @NotNull TableOptions options)
      Description copied from interface: Database
      Retrieve the specified live table as a PartitionedTable from the Database. The partitioned table's key columns will be its column and internal partitions.
      Specified by:
      livePartitionedTable in interface Database
      Parameters:
      namespace - the Namespace in which the table exists
      tableName - the name of the table in the Namespace.
      options - a TableOptions to set table options.
      Returns:
      a new PartitionedTable for the specified table
    • historicalTable

      public Table historicalTable(@NotNull @NotNull String namespace, @NotNull @NotNull String tableName, @NotNull @NotNull TableOptions options)
      Description copied from interface: Database
      Fetch a static historical Table from the database.
      Specified by:
      historicalTable in interface Database
      Parameters:
      namespace - the Namespace in which the table exists
      tableName - the name of the table in the Namespace.
      options - a TableOptions to set table options.
      Returns:
      a new static Table for the specified parameters.
    • historicalPartitionedTable

      public PartitionedTable historicalPartitionedTable(@NotNull @NotNull String namespace, @NotNull @NotNull String tableName, @NotNull @NotNull TableOptions options)
      Description copied from interface: Database
      Retrieve the specified historical table as a PartitionedTable from the Database. The partitioned table's key columns will be its column and internal partitions.
      Specified by:
      historicalPartitionedTable in interface Database
      Parameters:
      namespace - the Namespace in which the table exists
      tableName - the name of the table in the Namespace.
      options - a TableOptions to set table options.
      Returns:
      a new PartitionedTable for the specified table
    • getTableDefinition

      public TableDefinition getTableDefinition(@NotNull @NotNull String namespace, @NotNull @NotNull String tableName)
      Description copied from interface: Database
      Fetch a TableDefinition from the database.
      Specified by:
      getTableDefinition in interface Database
      Parameters:
      namespace - the Namespace in which the table exists
      tableName - the name of the table in the Namespace.
      Returns:
      the TableDefinition for the specified parameters.
    • getTableDefinitionTable

      public Table getTableDefinitionTable(@NotNull @NotNull String namespace, @NotNull @NotNull String tableName)
      Description copied from interface: Database
      Fetch a table's definition table from the database.
      Specified by:
      getTableDefinitionTable in interface Database
      Parameters:
      namespace - the Namespace in which the table exists
      tableName - the name of the table in the Namespace.
      Returns:
      a Table of the column definitions for the specified parameters.
    • getNamespaces

      public Collection<String> getNamespaces()
      Description copied from interface: Database
      Get the available namespaces.
      Specified by:
      getNamespaces in interface Database
      Returns:
      the list of namespaces
    • getTableNames

      public Collection<String> getTableNames(String namespace)
      Description copied from interface: Database
      Get the tables within a namespace
      Specified by:
      getTableNames in interface Database
      Parameters:
      namespace - the namespace to interrogate
      Returns:
      the list of tables within namespace
    • getCatalogTable

      public Table getCatalogTable()
      Description copied from interface: Database
      Retrieve a table containing the tables that exist in this database.

      The returned table has a column for "Namespace", "Tablename" and "NamespaceSet".

      Specified by:
      getCatalogTable in interface Database
      Returns:
      a table containing the tables that exist in this database.
    • clearLocationCache

      public void clearLocationCache()
      Description copied from interface: Database
      Clear the location cache for all tables. Use this method when some data has been replaced for a table to refresh the location cache and read the replaced data.

      Subsequent calls to Database.historicalTable(String, String), Database.liveTable(String, String) and their variants for all tables will repeat location discovery, which can have significant negative performance consequences.

      Note that you may also disable caching entirely using Database.useLocationCaches(boolean)

      Specified by:
      clearLocationCache in interface Database
    • clearLocationCache

      public void clearLocationCache(@NotNull @NotNull String namespace, @NotNull @NotNull String tableName)
      Description copied from interface: Database
      Clear the location cache for the specified table. Use this method when some data has been replaced for a table to refresh the location cache and read the replaced data.

      Subsequent calls to Database.historicalTable(String, String), Database.liveTable(String, String) and their variants for this table will repeat location discovery, which can have significant negative performance consequences

      Note that you may also disable caching entirely using Database.useLocationCaches(boolean)

      Specified by:
      clearLocationCache in interface Database
      Parameters:
      namespace - namespace of table to clear cache
      tableName - table name of table to clear cache
    • useLocationCaches

      public void useLocationCaches(boolean useCaching)
      Description copied from interface: Database
      Set whether the database should cache the result of table location discovery and re-use them. This defaults to true
      Specified by:
      useLocationCaches in interface Database
      Parameters:
      useCaching - if location caches should be used.