Class BaseChunkWriter<SOURCE_CHUNK_TYPE extends Chunk<Values>>

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>
  • 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 elementSize
      the size of each element in bytes if fixed
    • dhNullable

      protected final boolean dhNullable
      whether we can use the wire value as a deephaven null for clients that support dh nulls
    • fieldNullable

      protected final boolean fieldNullable
      whether the field is nullable
  • Method Details

    • getEmptyInputStream

      public final ChunkWriter.DrainableColumn getEmptyInputStream(@NotNull @NotNull BarrageOptions options) throws IOException
      Description copied from interface: ChunkWriter
      Get an input stream representing the empty wire payload for this writer.
      Specified by:
      getEmptyInputStream in interface ChunkWriter<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

      public ChunkWriter.Context makeContext(@NotNull SOURCE_CHUNK_TYPE chunk, long rowOffset)
      Description copied from interface: ChunkWriter
      Create a context for the given chunk.
      Specified by:
      makeContext in interface ChunkWriter<SOURCE_CHUNK_TYPE extends Chunk<Values>>
      Parameters:
      chunk - the chunk of data to be written
      rowOffset - the offset into the logical message potentially spread over multiple chunks
      Returns:
      a context for the given chunk
    • isFieldNullable

      public boolean isFieldNullable()
      Specified by:
      isFieldNullable in interface ChunkWriter<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 chunk
      subset - 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 chunk
      subset - the subset of rows to consider
      serContext - 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