Class LocalDictionaryWriterState

java.lang.Object
io.deephaven.extensions.barrage.chunk.LocalDictionaryWriterState
All Implemented Interfaces:
DictionaryWriterState

public final class LocalDictionaryWriterState extends Object implements DictionaryWriterState
DictionaryWriterState implementation for viewport subscriptions and snapshots. A single DictionaryWriterValueMap holds all distinct values in insertion order; deltaStartOffset marks the boundary between values already flushed to the subscriber and values that still need to be sent.

Thread-safety: not thread-safe; single-threaded barrage stream serialization is assumed.

  • Constructor Details

    • LocalDictionaryWriterState

      public LocalDictionaryWriterState(long dictId, ChunkType valuesChunkType)
  • Method Details

    • getDictId

      public long getDictId()
      Specified by:
      getDictId in interface DictionaryWriterState
    • 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: DictionaryWriterState
      Fills out with one dictionary index per logical row in source/subset. Null rows (in non-deephaven-nulls mode) produce QueryConstants.NULL_INT; non-null rows produce a non-negative dictionary index, registering new values as needed.
      Specified by:
      fillIndexChunk in interface DictionaryWriterState
      Parameters:
      source - the source chunk containing column values
      subset - row positions within source to include; null means all rows
      options - barrage serialization options (e.g. useDeephavenNulls)
      out - pre-sized output chunk to fill with dictionary indices
    • hasDelta

      public boolean hasDelta()
      Description copied from interface: DictionaryWriterState
      Returns true if 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:
      hasDelta in interface DictionaryWriterState
    • needsFullBatch

      public boolean needsFullBatch()
      Specified by:
      needsFullBatch in interface DictionaryWriterState
    • buildDeltaChunk

      @NotNull public @NotNull WritableChunk<Values> buildDeltaChunk()
      Description copied from interface: DictionaryWriterState
      Builds and returns a typed chunk containing the current delta values (values added since the last DictionaryWriterState.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:
      buildDeltaChunk in interface DictionaryWriterState
    • resetDelta

      public void resetDelta()
      Description copied from interface: DictionaryWriterState
      Advances the delta boundary after a DictionaryBatch has been successfully emitted. Unlike DictionaryWriterState.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:
      resetDelta in interface DictionaryWriterState
    • totalSize

      public int totalSize()
      Description copied from interface: DictionaryWriterState
      Current number of distinct values in the dictionary (resets to zero after DictionaryWriterState.reset()).
      Specified by:
      totalSize in interface DictionaryWriterState
    • reset

      public void reset()
      Description copied from interface: DictionaryWriterState
      Resets the dictionary to an empty state, as if no values had ever been seen. The next DictionaryBatch emitted will be isDelta=false with only the values encountered in the next batch. Call this when the cumulative dictionary size exceeds the live row count and compaction is needed.
      Specified by:
      reset in interface DictionaryWriterState