Class SnapshotUtils

java.lang.Object
io.deephaven.engine.table.impl.snapshot.SnapshotUtils

public class SnapshotUtils extends Object
  • Constructor Details

    • SnapshotUtils

      public SnapshotUtils()
  • Method Details

    • createColumnSourceMap

      public static <T> Map<String,T> createColumnSourceMap(Map<String,? extends ColumnSource<?>> columns, BiFunction<Class<?>,Class<?>,T> factory)
      Creates a new columnSourceMap based on 'columns'.
    • copyStampColumns

      public static void copyStampColumns(@NotNull @NotNull Map<String,? extends ColumnSource<?>> stampColumns, long stampKey, @NotNull @NotNull Map<String,? extends WritableColumnSource<?>> destColumns, @NotNull @NotNull RowSet destRowSet)
      For each name in stampColumns: - identify a stamp source (namely 'stampColumns.get(name)') - a row in that stamp source (namely 'stampKey') - a stamp dest (namely the column identified by 'destColumns.get(name)') - a bunch of destination rows (namely all the rows defined in 'destRowSet') Then "spray" that single source value over those destination values.
      Parameters:
      stampColumns - The stamp columns that serve as the source data
      stampKey - The source key
      destColumns - The destination columns we are "spraying" to
      destRowSet - The keys in destColumns we want to write to
    • copyStampColumnsRepeated

      public static void copyStampColumnsRepeated(@NotNull @NotNull Map<String,? extends ColumnSource<?>> stampColumns, @NotNull @NotNull RowSet stampKeys, @NotNull @NotNull Map<String,? extends WritableColumnSource<?>> destColumns, long destOffset, long blockSize)
      For each name in stampColumns, write the value of each row in stampKeys to its own block of blockSize consecutive rows in destColumns.get(name). The blocks are contiguous, follow the order of stampKeys, and the first begins at row key destOffset.
      Parameters:
      stampColumns - The stamp columns that serve as the source data
      stampKeys - The source keys, one per block
      destColumns - The destination columns we are writing to, with capacity for every block
      destOffset - The first row key of the first block in destColumns
      blockSize - The number of rows in each block
    • copyStampColumns

      public static void copyStampColumns(@NotNull @NotNull Map<String,? extends ColumnSource<?>> stampColumns, long stampKey, @NotNull @NotNull Map<String,SingleValueColumnSource<?>> destColumns)
      Like the above, but with a singleton destination. For each name in stampColumns: - identify a stamp source (namely 'stampColumns.get(name)') - a row in that stamp source (namely 'stampKey') - a stamp dest (namely the column identified by 'destColumns.get(name)') - a row in the destination (namely 'destKey') Then copy the source value to the destination value.
      Parameters:
      stampColumns - The stamp columns that serve as the source data
      stampKey - The source key
      destColumns - The destination columns we are writing to
    • setNullStampColumns

      public static void setNullStampColumns(@NotNull @NotNull Map<String,? extends ColumnSource<?>> stampColumns, @NotNull @NotNull Map<String,SingleValueColumnSource<?>> destColumns)
      Like the above, but with a singleton destination that will be set to the appropriate null value.
      Parameters:
      stampColumns - The stamp columns that serve as the source data
      destColumns - The destination columns we are writing to
    • setNullStampColumns

      public static void setNullStampColumns(@NotNull @NotNull Map<String,? extends ColumnSource<?>> stampColumns, @NotNull @NotNull Map<String,? extends WritableColumnSource<?>> destColumns, @NotNull @NotNull RowSet destRowSet)
      Like the above, but sets each of the rows in destRowSet to the appropriate null value.
      Parameters:
      stampColumns - The stamp columns that serve as the source data
      destColumns - The destination columns we are writing to
      destRowSet - The keys in destColumns we want to write to
    • dataColumnCopy

      public static SnapshotUtils.DataColumnCopy dataColumnCopy(@NotNull @NotNull Map<String,ChunkSource.WithPrev<? extends Values>> srcColumns, @NotNull @NotNull Map<String,? extends WritableColumnSource<?>> destColumns)
      Pair each of srcColumns with the column of destColumns that has the same name.
      Parameters:
      srcColumns - The columns that serve as the source data
      destColumns - The destination columns, which include a column for each name in srcColumns
      Returns:
      The parallel sources and destinations, in the order of srcColumns
    • copyDataColumnsRepeated

      public static void copyDataColumnsRepeated(@NotNull @NotNull Map<String,ChunkSource.WithPrev<? extends Values>> srcColumns, @NotNull @NotNull RowSet srcRowSet, @NotNull @NotNull Map<String,? extends WritableColumnSource<?>> destColumns, long destOffset, long numCopies)
      For each name in srcColumns, copy the data at srcColumns.get(name) for the rows in srcRowSet into numCopies consecutive, contiguous blocks of destColumns.get(name), the first of which begins at row key destOffset. Each chunk of source data is read once and written to every block.
      Parameters:
      srcColumns - The columns that serve as the source data
      srcRowSet - The keys in the srcColumns we are reading from
      destColumns - The destination columns we are writing to, with capacity for every block
      destOffset - The first row key of the first block in destColumns
      numCopies - The number of blocks to write
    • objectColumns

      public static WritableColumnSource<?>[] objectColumns(@NotNull @NotNull Map<String,? extends WritableColumnSource<?>> columns)
      Find the columns with an Object chunk type, whose values must be set to null when their rows leave a result so that the columns hold no references to them.
      Parameters:
      columns - The columns to search
      Returns:
      The columns of columns with an Object chunk type
    • nullObjectColumns

      public static void nullObjectColumns(@NotNull @NotNull WritableColumnSource<?>[] objectColumns, @NotNull @NotNull RowSequence rowSequence)
      Set the rows in rowSequence of each of objectColumns to null.
      Parameters:
      objectColumns - The columns to clear, as found by objectColumns(Map)
      rowSequence - The keys in objectColumns to clear
    • generateSnapshotDataColumns

      @NotNull public static @NotNull Map<String,ChunkSource.WithPrev<? extends Values>> generateSnapshotDataColumns(Table table)
    • maybeWrapVector

      @NotNull public static ChunkSource.WithPrev<? extends Values> maybeWrapVector(@NotNull @NotNull ColumnSource<?> columnSource)
      If columnSource's type is a vector, wrap it with a VectorChunkAdapter so that copying from it produces direct arrays suitable for snapshots.
      Parameters:
      columnSource - the column source to wrap
      Returns:
      the original column source or a VectorChunkAdapter as appropriate
    • generateTriggerStampColumns

      @NotNull public static @NotNull Map<String,? extends ColumnSource<?>> generateTriggerStampColumns(Table table)
    • maybeTransformToDirectVectorColumnSource

      @NotNull public static @NotNull ColumnSource<?> maybeTransformToDirectVectorColumnSource(ColumnSource<?> columnSource)