Class BarrageMessageWriterImpl
- All Implemented Interfaces:
BarrageMessageWriter,SafeCloseable,AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis factory writes data in Arrow's IPC format which has a terse header and no room for metadata.static classstatic classstatic classstatic classstatic classA view that writes a message as RecordBatches, each preceded by the DictionaryBatches its rows need: the rows and columns that one subscription or snapshot is sent.static classstatic classprotected static classA view of a message that may be visited only once: visiting it writes the message, and releases what the message was written from.protected classprotected classNested classes/interfaces inherited from interface io.deephaven.extensions.barrage.BarrageMessageWriter
BarrageMessageWriter.MessageView, BarrageMessageWriter.WriteMetricsConsumer -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBarrageMessageWriterImpl(@NotNull BarrageMessage message, @NotNull ChunkWriter<Chunk<Values>>[] chunkWriters, BarrageMessageWriter.WriteMetricsConsumer writeConsumer) Create a barrage stream writer that can slice and dice the barrage message for delivery to clients. -
Method Summary
Modifier and TypeMethodDescriptionprotected static ChunkWriter.DrainableColumnaddDict(BarrageMessageWriterImpl.RecordBatchMessageView view, ChunkWriter.FieldNodeListener fieldNodeListener, ChunkWriter.BufferListener bufferListener, ColumnChunksWriter<Chunk<Values>> chunkListWriter, int chunkIdx, long shift, WritableRowSet myAddedOffsets, RowSet adjustedOffsets, @NotNull DictionaryChunkWriter dictWriter, @NotNull DictionaryWriterState state) protected static ChunkWriter.DrainableColumnaddEmpty(BarrageMessageWriterImpl.RecordBatchMessageView view, ChunkWriter.FieldNodeListener fieldNodeListener, ChunkWriter.BufferListener bufferListener, ColumnChunksWriter<Chunk<Values>> chunkListWriter) protected static ChunkWriter.DrainableColumnaddNonEmpty(BarrageMessageWriterImpl.RecordBatchMessageView view, ChunkWriter.FieldNodeListener fieldNodeListener, ChunkWriter.BufferListener bufferListener, ColumnChunksWriter<Chunk<Values>> chunkListWriter, int chunkIdx, long shift, WritableRowSet myAddedOffsets, RowSet adjustedOffsets) protected intappendAddColumns(BarrageMessageWriterImpl.RecordBatchMessageView view, long startRange, int targetBatchSize, Consumer<DefensiveDrainable> addStream, ChunkWriter.FieldNodeListener fieldNodeListener, ChunkWriter.BufferListener bufferListener) protected intappendAddColumns(BarrageMessageWriterImpl.RecordBatchMessageView view, long startRange, int targetBatchSize, Consumer<DefensiveDrainable> addStream, ChunkWriter.FieldNodeListener fieldNodeListener, ChunkWriter.BufferListener bufferListener, ColumnChunksWriter<Chunk<Values>>[] addColumnData) protected intappendModColumns(BarrageMessageWriterImpl.RecordBatchMessageView view, long startRange, int targetBatchSize, Consumer<DefensiveDrainable> addStream, ChunkWriter.FieldNodeListener fieldNodeListener, ChunkWriter.BufferListener bufferListener) voidclose()protected static intfindWriterForOffset(ChunkWriter.Context[] chunks, long offset) getDictionaryBatchView(BarrageOptions options, long dictId, ChunkWriter<Chunk<Values>> valuesWriter, WritableChunk<Values> values, boolean isDelta) Obtain aBarrageMessageWriter.MessageViewof standalone DictionaryBatches carryingvaluesfor dictionarydictId, framed like this writer's other messages.getSnapshotView(BarrageSnapshotOptions options) Obtain a Full-SnapshotBarrageMessageWriter.MessageViewof thisBarrageMessageWriterthat can be sent to a single requestor.getSnapshotView(BarrageSnapshotOptions options, @Nullable RowSet viewport, boolean reverseViewport, @Nullable RowSet keyspaceViewport, @Nullable BitSet snapshotColumns) Obtain aBarrageMessageWriter.MessageViewof thisBarrageMessageWriterthat can be sent to a single requestor.getSnapshotView(BarrageSnapshotOptions options, @Nullable RowSet viewport, boolean reverseViewport, @Nullable RowSet keyspaceViewport, @Nullable BitSet snapshotColumns, @Nullable DictionaryWriterRegistry dictionaryRegistry) Obtain aBarrageMessageWriter.MessageViewof thisBarrageMessageWriterthat can be sent to a single requestor, with aDictionaryWriterRegistryfor any dictionary-encoded columns in the snapshot.getSubView(BarrageSubscriptionOptions options, boolean isInitialSnapshot) Obtain a Full-SubscriptionBarrageMessageWriter.MessageViewof thisBarrageMessageWriterthat can be sent to a single subscriber.getSubView(BarrageSubscriptionOptions options, boolean isInitialSnapshot, boolean isFullSubscription, @Nullable RowSet viewport, boolean reverseViewport, @Nullable RowSet keyspaceViewportPrev, @Nullable RowSet keyspaceViewport, @Nullable BitSet subscribedColumns) Obtain aBarrageMessageWriter.MessageViewof thisBarrageMessageWriterthat can be sent to a single subscriber.getSubView(BarrageSubscriptionOptions options, boolean isInitialSnapshot, boolean isFullSubscription, @Nullable RowSet viewport, boolean reverseViewport, @Nullable RowSet keyspaceViewportPrev, @Nullable RowSet keyspaceViewport, @Nullable BitSet subscribedColumns, @Nullable DictionaryWriterRegistry dictionaryRegistry) Obtain aBarrageMessageWriter.MessageViewof thisBarrageMessageWriterthat can be sent to a single subscriber, with a persistent per-subscriptionDictionaryWriterRegistrythat survives across multiple ticking updates.protected voidsetRecordBatchLength(BarrageMessageWriterImpl.RecordBatchMessageView view, com.google.flatbuffers.FlatBufferBuilder header, int numRows) protected voidwriteHeader(ByteBuffer metadata, MutableInt size, com.google.flatbuffers.FlatBufferBuilder header, ExposedByteArrayOutputStream baos) This implementation prepares the protobuf FlightData header.
-
Field Details
-
DEFAULT_BATCH_SIZE
public static final int DEFAULT_BATCH_SIZE
-
-
Constructor Details
-
BarrageMessageWriterImpl
public BarrageMessageWriterImpl(@NotNull @NotNull BarrageMessage message, @NotNull @NotNull ChunkWriter<Chunk<Values>>[] chunkWriters, @NotNull BarrageMessageWriter.WriteMetricsConsumer writeConsumer) Create a barrage stream writer that can slice and dice the barrage message for delivery to clients.- Parameters:
message- the writer takes ownership of the message and its internal objectschunkWriters- the chunk chunkWriterswriteConsumer- a method that can be used to record write time
-
-
Method Details
-
getMessage
- Specified by:
getMessagein interfaceBarrageMessageWriter- Returns:
- the
BarrageMessagethat this writer is operating on
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSafeCloseable
-
getSubView
public BarrageMessageWriter.MessageView getSubView(BarrageSubscriptionOptions options, boolean isInitialSnapshot, boolean isFullSubscription, @Nullable @Nullable RowSet viewport, boolean reverseViewport, @Nullable @Nullable RowSet keyspaceViewportPrev, @Nullable @Nullable RowSet keyspaceViewport, @Nullable @Nullable BitSet subscribedColumns) Description copied from interface:BarrageMessageWriterObtain aBarrageMessageWriter.MessageViewof thisBarrageMessageWriterthat can be sent to a single subscriber.Note that all passed in arguments are owned by the caller and may be modified external to this method.
- Specified by:
getSubViewin interfaceBarrageMessageWriter- Parameters:
options- serialization options for this specific viewisInitialSnapshot- indicates whether this is the first snapshot for the listenerisFullSubscription- whether this is a full subscription (possibly a growing viewport)viewport- is the position-space viewportreverseViewport- is the viewport reversed (relative to end of table instead of beginning)keyspaceViewportPrev- is the key-space viewport prior to applying the updatekeyspaceViewport- is the key-space viewportsubscribedColumns- are the columns subscribed for this view- Returns:
- a MessageView filtered by the subscription properties that can be sent to that subscriber
-
getSubView
public BarrageMessageWriter.MessageView getSubView(BarrageSubscriptionOptions options, boolean isInitialSnapshot, boolean isFullSubscription, @Nullable @Nullable RowSet viewport, boolean reverseViewport, @Nullable @Nullable RowSet keyspaceViewportPrev, @Nullable @Nullable RowSet keyspaceViewport, @Nullable @Nullable BitSet subscribedColumns, @Nullable @Nullable DictionaryWriterRegistry dictionaryRegistry) Description copied from interface:BarrageMessageWriterObtain aBarrageMessageWriter.MessageViewof thisBarrageMessageWriterthat can be sent to a single subscriber, with a persistent per-subscriptionDictionaryWriterRegistrythat survives across multiple ticking updates.Note that all passed in arguments are owned by the caller and may be modified external to this method.
- Specified by:
getSubViewin interfaceBarrageMessageWriter- Parameters:
options- serialization options for this specific viewisInitialSnapshot- indicates whether this is the first snapshot for the listenerisFullSubscription- whether this is a full subscription (possibly a growing viewport)viewport- is the position-space viewportreverseViewport- is the viewport reversed (relative to end of table instead of beginning)keyspaceViewportPrev- is the key-space viewport prior to applying the updatekeyspaceViewport- is the key-space viewportsubscribedColumns- are the columns subscribed for this viewdictionaryRegistry- the persistent dictionary registry for this subscription, ornullif unused- Returns:
- a MessageView filtered by the subscription properties that can be sent to that subscriber
-
getSubView
public BarrageMessageWriter.MessageView getSubView(BarrageSubscriptionOptions options, boolean isInitialSnapshot) Description copied from interface:BarrageMessageWriterObtain a Full-SubscriptionBarrageMessageWriter.MessageViewof thisBarrageMessageWriterthat can be sent to a single subscriber.- Specified by:
getSubViewin interfaceBarrageMessageWriter- Parameters:
options- serialization options for this specific viewisInitialSnapshot- indicates whether this is the first snapshot for the listener- Returns:
- a MessageView filtered by the subscription properties that can be sent to that subscriber
-
getSnapshotView
public BarrageMessageWriter.MessageView getSnapshotView(BarrageSnapshotOptions options, @Nullable @Nullable RowSet viewport, boolean reverseViewport, @Nullable @Nullable RowSet keyspaceViewport, @Nullable @Nullable BitSet snapshotColumns) Description copied from interface:BarrageMessageWriterObtain aBarrageMessageWriter.MessageViewof thisBarrageMessageWriterthat can be sent to a single requestor.Note that all passed in arguments are owned by the caller and may be modified external to this method.
- Specified by:
getSnapshotViewin interfaceBarrageMessageWriter- Parameters:
options- serialization options for this specific viewviewport- is the position-space viewportreverseViewport- is the viewport reversed (relative to end of table instead of beginning)snapshotColumns- are the columns included for this view- Returns:
- a MessageView filtered by the snapshot properties that can be sent to that requestor
-
getSnapshotView
public BarrageMessageWriter.MessageView getSnapshotView(BarrageSnapshotOptions options, @Nullable @Nullable RowSet viewport, boolean reverseViewport, @Nullable @Nullable RowSet keyspaceViewport, @Nullable @Nullable BitSet snapshotColumns, @Nullable @Nullable DictionaryWriterRegistry dictionaryRegistry) Description copied from interface:BarrageMessageWriterObtain aBarrageMessageWriter.MessageViewof thisBarrageMessageWriterthat can be sent to a single requestor, with aDictionaryWriterRegistryfor any dictionary-encoded columns in the snapshot.Note that all passed in arguments are owned by the caller and may be modified external to this method.
- Specified by:
getSnapshotViewin interfaceBarrageMessageWriter- Parameters:
options- serialization options for this specific viewviewport- is the position-space viewportreverseViewport- is the viewport reversed (relative to end of table instead of beginning)snapshotColumns- are the columns included for this viewdictionaryRegistry- the dictionary registry for this snapshot, ornullif unused- Returns:
- a MessageView filtered by the snapshot properties that can be sent to that requestor
-
getSnapshotView
Description copied from interface:BarrageMessageWriterObtain a Full-SnapshotBarrageMessageWriter.MessageViewof thisBarrageMessageWriterthat can be sent to a single requestor.- Specified by:
getSnapshotViewin interfaceBarrageMessageWriter- Parameters:
options- serialization options for this specific view- Returns:
- a MessageView filtered by the snapshot properties that can be sent to that requestor
-
getDictionaryBatchView
public BarrageMessageWriter.MessageView getDictionaryBatchView(BarrageOptions options, long dictId, ChunkWriter<Chunk<Values>> valuesWriter, WritableChunk<Values> values, boolean isDelta) Description copied from interface:BarrageMessageWriterObtain aBarrageMessageWriter.MessageViewof standalone DictionaryBatches carryingvaluesfor dictionarydictId, framed like this writer's other messages. A producer that writes one message for several subscribers sends these first, to bring each subscriber's dictionary level with the others'.The values make one DictionaryBatch, or several when one would reach the maximum message size
optionsallow or carry more values than their batch size, as a message's rows are split into record batches. Only the first replaces the dictionary whenisDeltaisfalse; the rest append to it.Takes ownership of
values. The returned view must be visited exactly once.- Specified by:
getDictionaryBatchViewin interfaceBarrageMessageWriter- Parameters:
options- serialization options for the values, including the maximum message sizedictId- the dictionary idvaluesWriter- the writer for the dictionary's valuesvalues- the values to sendisDelta- whether the values append to the dictionary the subscriber holds, rather than replace it- Returns:
- a MessageView of the DictionaryBatches, one stream each
-
setRecordBatchLength
protected void setRecordBatchLength(BarrageMessageWriterImpl.RecordBatchMessageView view, com.google.flatbuffers.FlatBufferBuilder header, int numRows) -
writeHeader
protected void writeHeader(ByteBuffer metadata, MutableInt size, com.google.flatbuffers.FlatBufferBuilder header, ExposedByteArrayOutputStream baos) throws IOException This implementation prepares the protobuf FlightData header.- Throws:
IOException
-
findWriterForOffset
-
appendAddColumns
protected int appendAddColumns(BarrageMessageWriterImpl.RecordBatchMessageView view, long startRange, int targetBatchSize, Consumer<DefensiveDrainable> addStream, ChunkWriter.FieldNodeListener fieldNodeListener, ChunkWriter.BufferListener bufferListener) throws IOException - Throws:
IOException
-
appendAddColumns
protected int appendAddColumns(BarrageMessageWriterImpl.RecordBatchMessageView view, long startRange, int targetBatchSize, Consumer<DefensiveDrainable> addStream, ChunkWriter.FieldNodeListener fieldNodeListener, ChunkWriter.BufferListener bufferListener, ColumnChunksWriter<Chunk<Values>>[] addColumnData) throws IOException - Throws:
IOException
-
addDict
@NotNull protected static ChunkWriter.DrainableColumn addDict(BarrageMessageWriterImpl.RecordBatchMessageView view, ChunkWriter.FieldNodeListener fieldNodeListener, ChunkWriter.BufferListener bufferListener, ColumnChunksWriter<Chunk<Values>> chunkListWriter, int chunkIdx, long shift, WritableRowSet myAddedOffsets, RowSet adjustedOffsets, @NotNull @NotNull DictionaryChunkWriter dictWriter, @NotNull @NotNull DictionaryWriterState state) throws IOException - Throws:
IOException
-
addNonEmpty
@NotNull protected static ChunkWriter.DrainableColumn addNonEmpty(BarrageMessageWriterImpl.RecordBatchMessageView view, ChunkWriter.FieldNodeListener fieldNodeListener, ChunkWriter.BufferListener bufferListener, ColumnChunksWriter<Chunk<Values>> chunkListWriter, int chunkIdx, long shift, WritableRowSet myAddedOffsets, RowSet adjustedOffsets) throws IOException - Throws:
IOException
-
addEmpty
@NotNull protected static ChunkWriter.DrainableColumn addEmpty(BarrageMessageWriterImpl.RecordBatchMessageView view, ChunkWriter.FieldNodeListener fieldNodeListener, ChunkWriter.BufferListener bufferListener, ColumnChunksWriter<Chunk<Values>> chunkListWriter) throws IOException - Throws:
IOException
-
appendModColumns
protected int appendModColumns(BarrageMessageWriterImpl.RecordBatchMessageView view, long startRange, int targetBatchSize, Consumer<DefensiveDrainable> addStream, ChunkWriter.FieldNodeListener fieldNodeListener, ChunkWriter.BufferListener bufferListener) throws IOException - Throws:
IOException
-