Class BaseChunkWriter.ValidityBuffer

java.lang.Object
io.deephaven.extensions.barrage.chunk.BaseChunkWriter.ValidityBuffer
Enclosing class:
BaseChunkWriter<SOURCE_CHUNK_TYPE extends Chunk<Values>>

protected static final class BaseChunkWriter.ValidityBuffer extends Object
A bit per element, packed LSB-first into little-endian 64-bit words, as Arrow encodes a validity buffer: a set bit marks a valid (non-null) element. Nulls are counted as the bits are appended, so a single traversal of the row data yields both the field node's null count and the bytes of the validity buffer.

BooleanChunkWriter also uses this to pack its payload, which has the same shape, via packed(int).

  • Constructor Summary

    Constructors
    Constructor
    Description
    ValidityBuffer(int numElements)
    A validity bitmap, materialized only once a null is appended.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Finalize and return the packed bytes; exactly getValidityMapSerializationSizeFor(numElements) of them.
    int
     
    packed(int numElements)
    A bit-packed buffer that is materialized up front, for a caller that needs the bits whatever the values turn out to be.
    void
    setNextAreNull(int numElements)
    Append numElements null entries; equivalent to that many setNextIsNull(true) calls, but without visiting each element.
    void
    setNextIsNull(boolean isNull)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ValidityBuffer

      public ValidityBuffer(int numElements)
      A validity bitmap, materialized only once a null is appended. A column with no nulls sends no validity buffer at all, so asking such a buffer for its bytes() is a caller bug and throws.
  • Method Details

    • packed

      public static BaseChunkWriter.ValidityBuffer packed(int numElements)
      A bit-packed buffer that is materialized up front, for a caller that needs the bits whatever the values turn out to be. BooleanChunkWriter packs its payload this way, where a set bit means TRUE rather than non-null and an all-TRUE column must still emit a full buffer.
      Parameters:
      numElements - the number of elements to be appended
      Returns:
      a buffer whose bytes() is always available
    • setNextIsNull

      public void setNextIsNull(boolean isNull)
    • setNextAreNull

      public void setNextAreNull(int numElements)
      Append numElements null entries; equivalent to that many setNextIsNull(true) calls, but without visiting each element.
      Parameters:
      numElements - the number of null entries to append
    • nullCount

      public int nullCount()
    • bytes

      public byte[] bytes()
      Finalize and return the packed bytes; exactly getValidityMapSerializationSizeFor(numElements) of them. No element may be appended afterwards.
      Throws:
      IllegalStateException - if nothing was ever materialized, i.e. no null was appended and the buffer was not created by packed(int)