Class SharedWriterDictionary

java.lang.Object
io.deephaven.extensions.barrage.chunk.SharedWriterDictionary

public final class SharedWriterDictionary extends Object
Shared per-table dictionary state for full subscriptions. Holds the authoritative value-to-index mapping and the ordered list of all values ever added. Multiple SharedDictionaryWriterState instances (one per active full subscriber) delegate their index lookups here, so all full subscribers observe the same index assignments.

The value list only grows, until reset() discards it. Each per-subscriber wrapper tracks an independent flushedOffset into this list so it knows which values have already been sent to that subscriber.

Thread-safety: the producer writes to its subscribers in parallel, so full subscribers fill, measure and read this dictionary from different threads at once. Filling and copying hold the dictionary's monitor, once per chunk filled and once per batch copied, since a fill may grow the value list while a copy reads it; the values are read only under the monitor. Measuring does not hold it: the size is a volatile field, so getTotalSize() gives the subscribers' hasDelta() and totalSize() checks an up-to-date count without blocking, and because values are only appended, a range of the list that a subscriber has measured stays valid however many values are added afterwards. reset() must be called only while no subscriber is writing.

  • Constructor Details

    • SharedWriterDictionary

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

    • getDictId

      public long getDictId()
    • getValuesChunkType

      @InternalUseOnly @NotNull public @NotNull ChunkType getValuesChunkType()
      The chunk type of the dictionary's values.
    • getTotalSize

      public int getTotalSize()
      Total number of distinct values currently in the dictionary (reset to 0 after reset()).
    • buildDeltaChunk

      @InternalUseOnly @NotNull public @NotNull WritableChunk<Values> buildDeltaChunk(int fromOffset, int toOffset)
      Builds and returns a typed chunk containing the values in [fromOffset, toOffset). The returned chunk is owned by the caller and must be closed when no longer needed.
    • getGeneration

      public int getGeneration()
      Returns the current generation counter. Increments each time reset() is called.
    • reset

      public void reset()
      Discards all accumulated values and increments the generation counter. SharedDictionaryWriterState instances that reference this shared dictionary will detect the reset on their next query and re-emit an isDelta=false DictionaryBatch.