Interface ExpansionKernel<T>
- Type Parameters:
T
- The type of data being processed by this kernel.
- All Known Subinterfaces:
ArrayExpansionKernel<T>
,VectorExpansionKernel<T>
- All Known Implementing Classes:
BooleanArrayExpansionKernel
,BooleanVectorExpansionKernel
,BoxedBooleanArrayExpansionKernel
,ByteArrayExpansionKernel
,ByteVectorExpansionKernel
,CharArrayExpansionKernel
,CharVectorExpansionKernel
,DoubleArrayExpansionKernel
,DoubleVectorExpansionKernel
,FloatArrayExpansionKernel
,FloatVectorExpansionKernel
,IntArrayExpansionKernel
,IntVectorExpansionKernel
,LongArrayExpansionKernel
,LongVectorExpansionKernel
,ObjectArrayExpansionKernel
,ObjectVectorExpansionKernel
,ShortArrayExpansionKernel
,ShortVectorExpansionKernel
public interface ExpansionKernel<T>
The
ExpansionKernel
interface provides methods for transforming chunks containing complex or nested data
structures into flattened representations, and vice versa. This enables efficient handling of columnar data in
scenarios involving arrays, or vectors
, particularly within the Deephaven Barrage
extensions for Flight/Barrage streams.
An ExpansionKernel
supports two primary operations:
- Expansion: Converts nested or multi-element data into a flattened form, along with metadata (e.g., row offsets) describing the original structure.
- Contraction: Reconstructs the original nested data structure from a flattened representation and associated metadata.
-
Method Summary
Modifier and TypeMethodDescriptiondefault int
computeSize
(int ii, int sizePerOffset, @Nullable IntChunk<ChunkPositions> offsets, @Nullable IntChunk<ChunkLengths> lengths) Computes the length of a row at the specified index, based on provided metadata (offsets and lengths).<A extends Any>
WritableObjectChunk<T,A> contract
(@NotNull Chunk<A> source, int sizePerElement, @Nullable IntChunk<ChunkPositions> offsets, @Nullable IntChunk<ChunkLengths> lengths, @Nullable WritableChunk<A> outChunk, int outOffset, int totalRows) Contracts a flattened chunk of elements (T
) back into a chunk of nested or multi-element data (T[]
orVector<T>
), using provided metadata (e.g., row offsets or lengths) to reconstruct the original structure.<A extends Any>
WritableChunk<A>expand
(@NotNull ObjectChunk<T, A> source, int fixedSizeLength, @Nullable WritableIntChunk<ChunkPositions> offsetDest) Expands a chunk of nested or multi-element data (T[]
orVector<T>
) into a flattened chunk of elements (T
), along with metadata describing the structure of the original data.
-
Method Details
-
expand
<A extends Any> WritableChunk<A> expand(@NotNull @NotNull ObjectChunk<T, A> source, int fixedSizeLength, @Nullable @Nullable WritableIntChunk<ChunkPositions> offsetDest) Expands a chunk of nested or multi-element data (T[]
orVector<T>
) into a flattened chunk of elements (T
), along with metadata describing the structure of the original data.The expansion involves unrolling arrays, or
vectors
, or other multi-element types into a single contiguous chunk. The number of elements belonging to each original row is recorded inoffsetDest
, which allows reconstructing the original structure when needed.If a non-zero
fixedSizeLength
is provided, each row will be truncated or padded with nulls to match the fixed size. A negativefixedSizeLength
will pick elements from the end of the array/vector.- Type Parameters:
A
- The attribute type of the source chunk.- Parameters:
source
- The source chunk containing nested or multi-element data to expand.fixedSizeLength
- The fixed size for each row, or 0 for variable-length rows. A negative value will pick elements from the end.offsetDest
- The destinationWritableIntChunk
to store row offsets, ornull
if not needed.- Returns:
- A flattened
WritableChunk
containing the expanded elements.
-
contract
<A extends Any> WritableObjectChunk<T,A> contract(@NotNull @NotNull Chunk<A> source, int sizePerElement, @Nullable @Nullable IntChunk<ChunkPositions> offsets, @Nullable @Nullable IntChunk<ChunkLengths> lengths, @Nullable @Nullable WritableChunk<A> outChunk, int outOffset, int totalRows) Contracts a flattened chunk of elements (T
) back into a chunk of nested or multi-element data (T[]
orVector<T>
), using provided metadata (e.g., row offsets or lengths) to reconstruct the original structure.The contraction process supports multiple configurations:
- If
offsets
isnull
, each row is assumed to have a fixed size defined bysizePerElement
. - If
lengths
isnull
, each row's size is determined by differences between adjacent elements inoffsets
. An element's length is determined by subtracting its offset from the next offset, therefore offsets must contain one more element than the number of elements. - If both
offsets
andlengths
are provided,lengths
determines the row sizes.
- Type Parameters:
A
- The attribute type of the source chunk.- Parameters:
source
- The source chunk containing flattened data to contract.sizePerElement
- The fixed size for each row, or 0 for variable-length rows.offsets
- AnIntChunk
describing row start positions, ornull
.lengths
- AnIntChunk
describing row lengths, ornull
.outChunk
- A reusableWritableChunk
to store the contracted result, ornull
.outOffset
- The starting position for writing intooutChunk
.totalRows
- The total number of rows, or 0 if unknown.- Returns:
- A
WritableObjectChunk
containing the reconstructed nested or multi-element data.
- If
-
computeSize
@FinalDefault default int computeSize(int ii, int sizePerOffset, @Nullable @Nullable IntChunk<ChunkPositions> offsets, @Nullable @Nullable IntChunk<ChunkLengths> lengths) Computes the length of a row at the specified index, based on provided metadata (offsets and lengths).The size computation follows these rules:
- If
offsets
isnull
, each row is assumed to have a fixed size ofsizePerOffset
. - If
lengths
isnull
, the size is calculated from adjacent elements inoffsets
. - If both
offsets
andlengths
are provided,lengths
determines the row size.
- If
-