Class DictionaryChunkWriter
- All Implemented Interfaces:
ChunkWriter<Chunk<Values>>
The RecordBatch for this column contains only the index buffer (an Int16/Int32/Int64 array mapping each row
to a position in the dictionary). The dictionary values are shipped separately as
DictionaryBatch messages by
BarrageMessageWriterImpl using the DictionaryWriterState tracked by
this writer.
Multiple columns may share the same dictionary id; they will all reference the same DictionaryWriterState
instance (managed by a DictionaryWriterRegistry held on the stream view). A single DictionaryBatch is
emitted per id per update, covering all new values introduced by any sharing column.
-
Nested Class Summary
Nested classes/interfaces inherited from class io.deephaven.extensions.barrage.chunk.BaseChunkWriter
BaseChunkWriter.ChunkTransformer<SOURCE_CHUNK_TYPE extends Chunk<Values>>, BaseChunkWriter.SerContextNested classes/interfaces inherited from interface io.deephaven.extensions.barrage.chunk.ChunkWriter
ChunkWriter.BufferListener, ChunkWriter.Context, ChunkWriter.DrainableColumn, ChunkWriter.Factory, ChunkWriter.FieldNodeInfo, ChunkWriter.FieldNodeListener -
Field Summary
Fields inherited from class io.deephaven.extensions.barrage.chunk.BaseChunkWriter
BULK_WRITE_BUFFER_BYTES, dhNullable, elementSize, fieldNullable, PADDING_BUFFER, REMAINDER_MOD_8_MASK -
Constructor Summary
ConstructorsConstructorDescriptionDictionaryChunkWriter(long dictId, @NotNull ChunkWriter<IntChunk<Values>> indexWriter, @NotNull ChunkWriter<Chunk<Values>> valuesWriter, int indexBitWidth, @NotNull ChunkType valuesChunkType, boolean fieldNullable) -
Method Summary
Modifier and TypeMethodDescriptionprotected intcomputeNullCount(ChunkWriter.Context context, @NotNull RowSequence subset) Compute the number of nulls in the subset.longgetEmptyIndexStream(@NotNull BarrageOptions options) Returns theChunkWriter.DrainableColumnfor an empty (0-row) dictionary-encoded column batch.getInputStream(ChunkWriter.Context context, @Nullable RowSet subset, @NotNull BarrageOptions options) Get an input stream optionally position-space filtered using the provided RowSet.getInputStream(ChunkWriter.Context context, @Nullable RowSet subset, @NotNull BarrageOptions options, @NotNull DictionaryWriterState state) Builds the index-column stream for the current batch.getInputStream(ChunkWriter.Context context, @Nullable RowSet subset, @NotNull BarrageOptions options, @Nullable DictionaryWriterRegistry dictionaryRegistry) Get an input stream, threading aDictionaryWriterRegistrydown to any dictionary-encoded writers nested within this writer (e.g.protected voidwriteValidityBufferInternal(ChunkWriter.Context context, @NotNull RowSequence subset, @NotNull BaseChunkWriter.SerContext serContext) Update the validity buffer for the subset.Methods inherited from class io.deephaven.extensions.barrage.chunk.BaseChunkWriter
getEmptyInputStream, getEmptyInputStream, getNumLongsForBitPackOfSize, getValidityMapSerializationSizeFor, isFieldNullable, makeContext
-
Constructor Details
-
DictionaryChunkWriter
public DictionaryChunkWriter(long dictId, @NotNull @NotNull ChunkWriter<IntChunk<Values>> indexWriter, @NotNull @NotNull ChunkWriter<Chunk<Values>> valuesWriter, int indexBitWidth, @NotNull @NotNull ChunkType valuesChunkType, boolean fieldNullable)
-
-
Method Details
-
getDictId
public long getDictId() -
getValuesWriter
-
getValuesChunkType
-
computeNullCount
protected int computeNullCount(@NotNull ChunkWriter.Context context, @NotNull @NotNull RowSequence subset) Description copied from class:BaseChunkWriterCompute the number of nulls in the subset.- Specified by:
computeNullCountin classBaseChunkWriter<Chunk<Values>>- Parameters:
context- the context for the chunksubset- the subset of rows to consider- Returns:
- the number of nulls in the subset
-
writeValidityBufferInternal
protected void writeValidityBufferInternal(@NotNull ChunkWriter.Context context, @NotNull @NotNull RowSequence subset, @NotNull @NotNull BaseChunkWriter.SerContext serContext) Description copied from class:BaseChunkWriterUpdate the validity buffer for the subset.- Specified by:
writeValidityBufferInternalin classBaseChunkWriter<Chunk<Values>>- Parameters:
context- the context for the chunksubset- the subset of rows to considerserContext- the serialization context
-
getInputStream
public ChunkWriter.DrainableColumn getInputStream(@NotNull ChunkWriter.Context context, @Nullable @Nullable RowSet subset, @NotNull @NotNull BarrageOptions options) throws IOException Get an input stream optionally position-space filtered using the provided RowSet.Always throws; callers must use
getInputStream(Context, RowSet, BarrageOptions, DictionaryWriterState).- Parameters:
context- the chunk writer context holding the data to be drained to the clientsubset- if provided, is a position-space filter of source dataoptions- options for writing to the stream- Returns:
- a single-use DrainableColumn ready to be drained via grpc
- Throws:
IOException
-
getInputStream
public ChunkWriter.DrainableColumn getInputStream(@NotNull ChunkWriter.Context context, @Nullable @Nullable RowSet subset, @NotNull @NotNull BarrageOptions options, @NotNull @NotNull DictionaryWriterState state) throws IOException Builds the index-column stream for the current batch.Each logical row in
subsetis mapped to its 0-based dictionary index usingstate. Null rows produce a null-sentinel index value (so the returned stream's validity bitmap has 0 for those positions). Newly encountered non-null values are appended to the dictionary; callers can inspectDictionaryWriterState.hasDelta()after this call to determine whether aDictionaryBatchmessage must be emitted.- Parameters:
context- the chunk context holding the source datasubset- the row offsets (positions within the source chunk) to include;nullmeans all rowsoptions- barrage serialization optionsstate- the per-stream/per-id dictionary state; updated in place with any new values encountered- Throws:
IOException
-
getInputStream
public ChunkWriter.DrainableColumn getInputStream(@NotNull ChunkWriter.Context context, @Nullable @Nullable RowSet subset, @NotNull @NotNull BarrageOptions options, @Nullable @Nullable DictionaryWriterRegistry dictionaryRegistry) throws IOException Get an input stream, threading aDictionaryWriterRegistrydown to any dictionary-encoded writers nested within this writer (e.g. thevalueschild of a run-end-encoded column). Writers that contain no dictionary encoding ignore the registry and behave identically toChunkWriter.getInputStream(Context, RowSet, BarrageOptions).A
DictionaryChunkWriteruses the registry to obtain (and register) its per-idDictionaryWriterState, so that the enclosing message writer emits the correspondingDictionaryBatch. Composite writers forward the registry to their children.Resolves this writer's
DictionaryWriterStatefromdictionaryRegistry(registering it on first use) and builds the index stream. This is the entry point used when a dictionary-encoded column is nested inside another writer (e.g. thevalueschild of a run-end-encoded column), where the enclosing writer forwards the registry rather than pre-resolving the state.The state is registered even for an empty batch (as long as a registry is supplied), so that the enclosing message writer emits an initial
isDelta=falseDictionaryBatch defining this field's id before the referencing RecordBatch, as strict Arrow consumers require. An empty batch adds no dictionary values, so that initial batch is empty. Anullregistry is only tolerated for an empty batch, which then produces the empty index stream directly.- Parameters:
context- the chunk writer context holding the data to be drained to the clientsubset- if provided, is a position-space filter of source dataoptions- options for writing to the streamdictionaryRegistry- the per-stream dictionary registry; may benullwhen the caller does not support dictionary encoding (a nested dictionary-encoded writer will then throw)- Returns:
- a single-use DrainableColumn ready to be drained via grpc
- Throws:
IOException
-
getEmptyIndexStream
public ChunkWriter.DrainableColumn getEmptyIndexStream(@NotNull @NotNull BarrageOptions options) throws IOException Returns theChunkWriter.DrainableColumnfor an empty (0-row) dictionary-encoded column batch. The column's validity and index buffers are both empty. This does not touch theDictionaryWriterState; callers register the state separately (seegetInputStream(Context, RowSet, BarrageOptions, DictionaryWriterRegistry)) when an initial emptyDictionaryBatchis required for this id.- Throws:
IOException
-