java.lang.Object
io.deephaven.extensions.barrage.chunk.BaseChunkWriter<SOURCE_CHUNK_TYPE>
- All Implemented Interfaces:
ChunkWriter<SOURCE_CHUNK_TYPE>
- Direct Known Subclasses:
BooleanChunkWriter,ByteChunkWriter,CharChunkWriter,DoubleChunkWriter,FixedWidthChunkWriter,FloatChunkWriter,IntChunkWriter,ListChunkWriter,LongChunkWriter,MapChunkWriter,NullChunkWriter,ShortChunkWriter,UnionChunkWriter,VarBinaryChunkWriter
public abstract class BaseChunkWriter<SOURCE_CHUNK_TYPE extends Chunk<Values>>
extends Object
implements ChunkWriter<SOURCE_CHUNK_TYPE>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceprotected static final classNested classes/interfaces inherited from interface io.deephaven.extensions.barrage.chunk.ChunkWriter
ChunkWriter.BufferListener, ChunkWriter.Context, ChunkWriter.DrainableColumn, ChunkWriter.Factory, ChunkWriter.FieldNodeInfo, ChunkWriter.FieldNodeListener -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanwhether we can use the wire value as a deephaven null for clients that support dh nullsprotected final intthe size of each element in bytes if fixedprotected final booleanwhether the field is nullablestatic final byte[]static final int -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract intcomputeNullCount(@NotNull ChunkWriter.Context context, @NotNull RowSequence subset) Compute the number of nulls in the subset.getEmptyInputStream(@NotNull BarrageOptions options) Get an input stream representing the empty wire payload for this writer.protected static intgetNumLongsForBitPackOfSize(int numElements) Returns the number of longs needed to represent a single bit per element.protected static intgetValidityMapSerializationSizeFor(int numElements) Returns expected size of validity map in bytes.booleanmakeContext(SOURCE_CHUNK_TYPE chunk, long rowOffset) Create a context for the given chunk.protected abstract voidwriteValidityBufferInternal(@NotNull ChunkWriter.Context context, @NotNull RowSequence subset, @NotNull BaseChunkWriter.SerContext serContext) Update the validity buffer for the subset.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.deephaven.extensions.barrage.chunk.ChunkWriter
getInputStream
-
Field Details
-
PADDING_BUFFER
public static final byte[] PADDING_BUFFER -
REMAINDER_MOD_8_MASK
public static final int REMAINDER_MOD_8_MASK- See Also:
-
elementSize
protected final int elementSizethe size of each element in bytes if fixed -
dhNullable
protected final boolean dhNullablewhether we can use the wire value as a deephaven null for clients that support dh nulls -
fieldNullable
protected final boolean fieldNullablewhether the field is nullable
-
-
Method Details
-
getEmptyInputStream
public final ChunkWriter.DrainableColumn getEmptyInputStream(@NotNull @NotNull BarrageOptions options) throws IOException Description copied from interface:ChunkWriterGet an input stream representing the empty wire payload for this writer.- Specified by:
getEmptyInputStreamin interfaceChunkWriter<SOURCE_CHUNK_TYPE extends Chunk<Values>>- Parameters:
options- options for writing to the stream- Returns:
- a single-use DrainableColumn ready to be drained via grpc
- Throws:
IOException
-
makeContext
Description copied from interface:ChunkWriterCreate a context for the given chunk.- Specified by:
makeContextin interfaceChunkWriter<SOURCE_CHUNK_TYPE extends Chunk<Values>>- Parameters:
chunk- the chunk of data to be writtenrowOffset- the offset into the logical message potentially spread over multiple chunks- Returns:
- a context for the given chunk
-
isFieldNullable
public boolean isFieldNullable()- Specified by:
isFieldNullablein interfaceChunkWriter<SOURCE_CHUNK_TYPE extends Chunk<Values>>- Returns:
- whether the wire format for this writer might include a validity buffer
-
computeNullCount
protected abstract int computeNullCount(@NotNull @NotNull ChunkWriter.Context context, @NotNull @NotNull RowSequence subset) Compute the number of nulls in the subset.- Parameters:
context- the context for the chunksubset- the subset of rows to consider- Returns:
- the number of nulls in the subset
-
writeValidityBufferInternal
protected abstract void writeValidityBufferInternal(@NotNull @NotNull ChunkWriter.Context context, @NotNull @NotNull RowSequence subset, @NotNull @NotNull BaseChunkWriter.SerContext serContext) Update the validity buffer for the subset.- Parameters:
context- the context for the chunksubset- the subset of rows to considerserContext- the serialization context
-
getValidityMapSerializationSizeFor
protected static int getValidityMapSerializationSizeFor(int numElements) Returns expected size of validity map in bytes.- Parameters:
numElements- the number of rows- Returns:
- number of bytes to represent the validity buffer for numElements
-
getNumLongsForBitPackOfSize
protected static int getNumLongsForBitPackOfSize(int numElements) Returns the number of longs needed to represent a single bit per element.- Parameters:
numElements- the number of rows- Returns:
- number of longs needed to represent numElements bits rounded up to the nearest long
-