Interface DictionaryWriterState
- All Known Implementing Classes:
LocalDictionaryWriterState,SharedDictionaryWriterState
public interface DictionaryWriterState
Tracks the cumulative dictionary for one Arrow dictionary id within a barrage stream. Shared by all
DictionaryChunkWriter instances that reference the same id.
fillIndexChunk(io.deephaven.chunk.Chunk<io.deephaven.chunk.attributes.Values>, io.deephaven.engine.rowset.RowSet, io.deephaven.extensions.barrage.BarrageOptions, io.deephaven.chunk.WritableIntChunk<io.deephaven.chunk.attributes.Values>) is called once per batch (non-null rows only) while building a batch. After the batch's
DictionaryBatch has been emitted, call resetDelta() to advance the delta
boundary.
Two concrete implementations exist:
LocalDictionaryWriterState— for viewport subscriptions and snapshots.resetDelta()clears the delta list entirely; only newly-seen values since the last reset are tracked.SharedDictionaryWriterState— for full subscriptions and growing subscriptions. The full cumulative value list is retained so that a new subscriber joining mid-stream can receive all current values as an initialisDelta=falsebatch.
Thread-safety: not thread-safe; single-threaded barrage stream serialization is assumed.
-
Method Summary
Modifier and TypeMethodDescription@NotNull WritableChunk<Values> Builds and returns a typed chunk containing the current delta values (values added since the lastresetDelta()call, or all values if this is the first batch for this subscriber).voidfillIndexChunk(@NotNull Chunk<Values> source, @Nullable RowSet subset, @NotNull BarrageOptions options, @NotNull WritableIntChunk<Values> out) Fillsoutwith one dictionary index per logical row insource/subset.longbooleanhasDelta()Returnstrueif a DictionaryBatch message needs to be emitted before the current RecordBatch — either because this is the first batch for this subscriber (isDelta=false) or because new values have been added since the last reset.booleanvoidreset()Resets the dictionary to an empty state, as if no values had ever been seen.voidAdvances the delta boundary after a DictionaryBatch has been successfully emitted.intCurrent number of distinct values in the dictionary (resets to zero afterreset()).
-
Method Details
-
getDictId
long getDictId() -
fillIndexChunk
void fillIndexChunk(@NotNull @NotNull Chunk<Values> source, @Nullable @Nullable RowSet subset, @NotNull @NotNull BarrageOptions options, @NotNull @NotNull WritableIntChunk<Values> out) Fillsoutwith one dictionary index per logical row insource/subset. Null rows (in non-deephaven-nulls mode) produceQueryConstants.NULL_INT; non-null rows produce a non-negative dictionary index, registering new values as needed.- Parameters:
source- the source chunk containing column valuessubset- row positions withinsourceto include;nullmeans all rowsoptions- barrage serialization options (e.g.useDeephavenNulls)out- pre-sized output chunk to fill with dictionary indices
-
hasDelta
boolean hasDelta()Returnstrueif a DictionaryBatch message needs to be emitted before the current RecordBatch — either because this is the first batch for this subscriber (isDelta=false) or because new values have been added since the last reset. -
needsFullBatch
boolean needsFullBatch() -
buildDeltaChunk
Builds and returns a typed chunk containing the current delta values (values added since the lastresetDelta()call, or all values if this is the first batch for this subscriber). The returned chunk is owned by the caller and must be closed when no longer needed. -
resetDelta
void resetDelta()Advances the delta boundary after a DictionaryBatch has been successfully emitted. Unlikereset(), this does not discard the accumulated value-to-index mapping — it only moves the boundary so that already-sent values are excluded from future delta batches. The client's cached dictionary remains valid after this call. -
totalSize
int totalSize()Current number of distinct values in the dictionary (resets to zero afterreset()). -
reset
void reset()Resets the dictionary to an empty state, as if no values had ever been seen. The next DictionaryBatch emitted will beisDelta=falsewith only the values encountered in the next batch. Call this when the cumulative dictionary size exceeds the live row count and compaction is needed.
-