Class SharedDictionaryWriterState

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

public final class SharedDictionaryWriterState extends Object implements 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 Details

    • SharedDictionaryWriterState

      public SharedDictionaryWriterState(@NotNull @NotNull SharedWriterDictionary shared)
  • 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()
      Not supported: the shared dictionary is compacted by calling SharedWriterDictionary.reset() directly; this per-subscriber wrapper detects that reset lazily via syncGeneration(). Calling reset() here is always a caller error.
      Specified by:
      reset in interface DictionaryWriterState