Class DictionaryWriterRegistryImpl
java.lang.Object
io.deephaven.extensions.barrage.chunk.DictionaryWriterRegistryImpl
- All Implemented Interfaces:
DictionaryWriterRegistry
The server-side
DictionaryWriterRegistry implementation, backed by fastutil maps.
Two construction modes:
- Local (default constructor) — for viewport subscriptions and snapshots. Each registry creates
LocalDictionaryWriterStateinstances that are fully private to this stream. - Shared-backed (
DictionaryWriterRegistryImpl(Long2ObjectOpenHashMap)constructor) — for full subscriptions and growing subscriptions targeting a full subscription. Each registry createsSharedDictionaryWriterStateinstances that delegate index lookups to the table-levelSharedWriterDictionary, so all full subscribers share the same value-to-index mapping.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.deephaven.extensions.barrage.chunk.DictionaryWriterRegistry
DictionaryWriterRegistry.Entry -
Constructor Summary
ConstructorsConstructorDescriptionCreates a local registry for viewport subscriptions and snapshots.DictionaryWriterRegistryImpl(@NotNull it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<SharedWriterDictionary> sharedDictionaries) Creates a shared-backed registry for full subscriptions and growing subscriptions targeting a full subscription. -
Method Summary
Modifier and TypeMethodDescription@NotNull Collection<DictionaryWriterRegistry.Entry> entries()Returns all registered entries.@Nullable DictionaryWriterRegistry.EntrygetEntry(long dictId) Returns the entry registered fordictId, ornullif there is none yet.@NotNull DictionaryWriterStategetOrCreate(long dictId, @NotNull ChunkWriter<Chunk<Values>> valuesWriter, @NotNull ChunkType valuesChunkType) Returns (or creates) theDictionaryWriterStatefor the given dictionary id.booleanReturnstrueif any registered dictionary has a pending delta that needs a DictionaryBatch message.voidmaybeResetEntries(@NotNull LongUnaryOperator maxSizeForDictId) Resets each registeredDictionaryWriterStatewhosetotalSizeexceeds the limitmaxSizeForDictIdgives for its dictionary id, so the next DictionaryBatch will beisDelta=falsewith a compacted dictionary.voidAccepts the batch just written, callingDictionaryWriterState.resetDelta()on every registered state, whether or not the batch carried a DictionaryBatch for it.@Nullable it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<SharedWriterDictionary> The producer's shared dictionaries that this registry's states are backed by, ornullfor a local registry.
-
Constructor Details
-
DictionaryWriterRegistryImpl
public DictionaryWriterRegistryImpl()Creates a local registry for viewport subscriptions and snapshots. -
DictionaryWriterRegistryImpl
public DictionaryWriterRegistryImpl(@NotNull @NotNull it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<SharedWriterDictionary> sharedDictionaries) Creates a shared-backed registry for full subscriptions and growing subscriptions targeting a full subscription. ThesharedDictionariesmap is owned by theio.deephaven.server.barrage.BarrageMessageProducerand lives for the lifetime of the table's producer; it is never cleared. Registries over the same map are used by different subscribers simultaneously, and add to it only while holding its lock. The producer resets dictionaries that have outgrown the table *before* a propagation phase's writes begin, when no registry is adding to it.
-
-
Method Details
-
getOrCreate
@NotNull public @NotNull DictionaryWriterState getOrCreate(long dictId, @NotNull @NotNull ChunkWriter<Chunk<Values>> valuesWriter, @NotNull @NotNull ChunkType valuesChunkType) Description copied from interface:DictionaryWriterRegistryReturns (or creates) theDictionaryWriterStatefor the given dictionary id.The first call for a given
dictIdregisters thevaluesWriterfor that id and creates the appropriate state type. Subsequent calls for the same id return the existing state.- Specified by:
getOrCreatein interfaceDictionaryWriterRegistry
-
getEntry
Returns the entry registered fordictId, ornullif there is none yet. -
entries
Description copied from interface:DictionaryWriterRegistryReturns all registered entries.- Specified by:
entriesin interfaceDictionaryWriterRegistry
-
hasAnyDelta
public boolean hasAnyDelta()Description copied from interface:DictionaryWriterRegistryReturnstrueif any registered dictionary has a pending delta that needs a DictionaryBatch message.- Specified by:
hasAnyDeltain interfaceDictionaryWriterRegistry
-
resetDeltas
public void resetDeltas()Description copied from interface:DictionaryWriterRegistryAccepts the batch just written, callingDictionaryWriterState.resetDelta()on every registered state, whether or not the batch carried a DictionaryBatch for it.- Specified by:
resetDeltasin interfaceDictionaryWriterRegistry
-
maybeResetEntries
Description copied from interface:DictionaryWriterRegistryResets each registeredDictionaryWriterStatewhosetotalSizeexceeds the limitmaxSizeForDictIdgives for its dictionary id, so the next DictionaryBatch will beisDelta=falsewith a compacted dictionary. This applies to local (viewport/snapshot) registries only; a shared-backed registry ignores this call, as itsSharedWriterDictionaryis reset externally.- Specified by:
maybeResetEntriesin interfaceDictionaryWriterRegistry- Parameters:
maxSizeForDictId- the most values the dictionary with a given id may hold before it is reset; typically no more than the live row count visible to the subscription
-