Class SnapshotUtils
java.lang.Object
io.deephaven.engine.table.impl.snapshot.SnapshotUtils
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe parallel sources and destinations of acopyof data columns into result columns. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcopyDataColumnsRepeated(@NotNull Map<String, ChunkSource.WithPrev<? extends Values>> srcColumns, @NotNull RowSet srcRowSet, @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 intonumCopiesconsecutive, contiguous blocks of destColumns.get(name), the first of which begins at row keydestOffset.static voidcopyStampColumns(@NotNull Map<String, ? extends ColumnSource<?>> stampColumns, long stampKey, @NotNull Map<String, ? extends WritableColumnSource<?>> destColumns, @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.static voidcopyStampColumns(@NotNull Map<String, ? extends ColumnSource<?>> stampColumns, long stampKey, @NotNull Map<String, SingleValueColumnSource<?>> destColumns) Like the above, but with a singleton destination.static voidcopyStampColumnsRepeated(@NotNull Map<String, ? extends ColumnSource<?>> stampColumns, @NotNull RowSet stampKeys, @NotNull Map<String, ? extends WritableColumnSource<?>> destColumns, long destOffset, long blockSize) For each name in stampColumns, write the value of each row instampKeysto its own block ofblockSizeconsecutive rows in destColumns.get(name).createColumnSourceMap(Map<String, ? extends ColumnSource<?>> columns, BiFunction<Class<?>, Class<?>, T> factory) Creates a new columnSourceMap based on 'columns'.static SnapshotUtils.DataColumnCopydataColumnCopy(@NotNull Map<String, ChunkSource.WithPrev<? extends Values>> srcColumns, @NotNull Map<String, ? extends WritableColumnSource<?>> destColumns) Pair each ofsrcColumnswith the column ofdestColumnsthat has the same name.static @NotNull Map<String, ChunkSource.WithPrev<? extends Values>> generateSnapshotDataColumns(Table table) static @NotNull Map<String, ? extends ColumnSource<?>> generateTriggerStampColumns(Table table) static @NotNull ColumnSource<?> maybeTransformToDirectVectorColumnSource(ColumnSource<?> columnSource) static ChunkSource.WithPrev<? extends Values> maybeWrapVector(@NotNull ColumnSource<?> columnSource) If columnSource's type is a vector, wrap it with aVectorChunkAdapterso that copying from it produces direct arrays suitable for snapshots.static voidnullObjectColumns(@NotNull WritableColumnSource<?>[] objectColumns, @NotNull RowSequence rowSequence) Set the rows inrowSequenceof each ofobjectColumnstonull.static WritableColumnSource<?>[]objectColumns(@NotNull Map<String, ? extends WritableColumnSource<?>> columns) Find the columns with anObjectchunk type, whose values must be set tonullwhen their rows leave a result so that the columns hold no references to them.static voidsetNullStampColumns(@NotNull Map<String, ? extends ColumnSource<?>> stampColumns, @NotNull Map<String, ? extends WritableColumnSource<?>> destColumns, @NotNull RowSet destRowSet) Like the above, but sets each of the rows indestRowSetto the appropriatenullvalue.static voidsetNullStampColumns(@NotNull Map<String, ? extends ColumnSource<?>> stampColumns, @NotNull Map<String, SingleValueColumnSource<?>> destColumns) Like the above, but with a singleton destination that will be set to the appropriatenullvalue.
-
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 datastampKey- The source keydestColumns- The destination columns we are "spraying" todestRowSet- 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 instampKeysto its own block ofblockSizeconsecutive rows in destColumns.get(name). The blocks are contiguous, follow the order ofstampKeys, and the first begins at row keydestOffset.- Parameters:
stampColumns- The stamp columns that serve as the source datastampKeys- The source keys, one per blockdestColumns- The destination columns we are writing to, with capacity for every blockdestOffset- The first row key of the first block in destColumnsblockSize- 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 datastampKey- The source keydestColumns- 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 appropriatenullvalue.- Parameters:
stampColumns- The stamp columns that serve as the source datadestColumns- 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 indestRowSetto the appropriatenullvalue.- Parameters:
stampColumns- The stamp columns that serve as the source datadestColumns- The destination columns we are writing todestRowSet- 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 ofsrcColumnswith the column ofdestColumnsthat has the same name.- Parameters:
srcColumns- The columns that serve as the source datadestColumns- 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 intonumCopiesconsecutive, contiguous blocks of destColumns.get(name), the first of which begins at row keydestOffset. Each chunk of source data is read once and written to every block.- Parameters:
srcColumns- The columns that serve as the source datasrcRowSet- The keys in the srcColumns we are reading fromdestColumns- The destination columns we are writing to, with capacity for every blockdestOffset- The first row key of the first block in destColumnsnumCopies- The number of blocks to write
-
objectColumns
public static WritableColumnSource<?>[] objectColumns(@NotNull @NotNull Map<String, ? extends WritableColumnSource<?>> columns) Find the columns with anObjectchunk type, whose values must be set tonullwhen their rows leave a result so that the columns hold no references to them.- Parameters:
columns- The columns to search- Returns:
- The columns of
columnswith an Object chunk type
-
nullObjectColumns
public static void nullObjectColumns(@NotNull @NotNull WritableColumnSource<?>[] objectColumns, @NotNull @NotNull RowSequence rowSequence) Set the rows inrowSequenceof each ofobjectColumnstonull.- Parameters:
objectColumns- The columns to clear, as found byobjectColumns(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 aVectorChunkAdapterso 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)
-