Class SharedDictionaryWriterState
java.lang.Object
io.deephaven.extensions.barrage.chunk.SharedDictionaryWriterState
- All Implemented Interfaces:
DictionaryWriterState
Per-subscriber
DictionaryWriterState for full subscriptions (and growing subscriptions targeting a full
subscription). Delegates value-to-index lookups to a SharedWriterDictionary shared across all full
subscribers on the same table, and tracks an independent flushedOffset so each subscriber only receives
values it has not yet seen.
On first use (needsFullBatch() == true), buildDeltaChunk() returns a chunk covering the
complete current value list so the subscriber receives an isDelta=false reset batch covering all values
accumulated before it joined. After resetDelta() is called, only values added after that point are included
in future delta batches.
Thread-safety: not thread-safe; access is serialized by the barrage propagation thread (the UGP cycle).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull WritableChunk<Values> Builds and returns a typed chunk containing the current delta values (values added since the lastDictionaryWriterState.resetDelta()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()Not supported: the shared dictionary is compacted by callingSharedWriterDictionary.reset()directly; this per-subscriber wrapper detects that reset lazily viasyncGeneration().voidAdvances the delta boundary after a DictionaryBatch has been successfully emitted.intCurrent number of distinct values in the dictionary (resets to zero afterDictionaryWriterState.reset()).
-
Constructor Details
-
Method Details
-
getDictId
public long getDictId()- Specified by:
getDictIdin interfaceDictionaryWriterState
-
fillIndexChunk
public void fillIndexChunk(@NotNull @NotNull Chunk<Values> source, @Nullable @Nullable RowSet subset, @NotNull @NotNull BarrageOptions options, @NotNull @NotNull WritableIntChunk<Values> out) Description copied from interface:DictionaryWriterStateFillsoutwith 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.- Specified by:
fillIndexChunkin interfaceDictionaryWriterState- 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
public boolean hasDelta()Description copied from interface:DictionaryWriterStateReturnstrueif 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.- Specified by:
hasDeltain interfaceDictionaryWriterState
-
needsFullBatch
public boolean needsFullBatch()- Specified by:
needsFullBatchin interfaceDictionaryWriterState
-
buildDeltaChunk
Description copied from interface:DictionaryWriterStateBuilds and returns a typed chunk containing the current delta values (values added since the lastDictionaryWriterState.resetDelta()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.- Specified by:
buildDeltaChunkin interfaceDictionaryWriterState
-
resetDelta
public void resetDelta()Description copied from interface:DictionaryWriterStateAdvances the delta boundary after a DictionaryBatch has been successfully emitted. UnlikeDictionaryWriterState.reset(), 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.- Specified by:
resetDeltain interfaceDictionaryWriterState
-
totalSize
public int totalSize()Description copied from interface:DictionaryWriterStateCurrent number of distinct values in the dictionary (resets to zero afterDictionaryWriterState.reset()).- Specified by:
totalSizein interfaceDictionaryWriterState
-
reset
public void reset()Not supported: the shared dictionary is compacted by callingSharedWriterDictionary.reset()directly; this per-subscriber wrapper detects that reset lazily viasyncGeneration(). Calling reset() here is always a caller error.- Specified by:
resetin interfaceDictionaryWriterState
-