Class ArrowValues

java.lang.Object
io.krabka.streams.columnar.ArrowValues

public final class ArrowValues extends Object
Type-coercing Arrow batch helpers for RowBridge and ColumnarProcessor implementations.

These are the same conversions the built-in operators and bridges use: a write dispatches on the vector's type and accepts natural Java values (Number, CharSequence, byte[] or ByteBuffer, Boolean, BigDecimal, java.time types, Collection for lists, Map for maps and structs), and a read returns the matching Java value with Text normalized to String, binary to a read-only ByteBuffer, and unsigned 64-bit integers to BigInteger. Using them keeps custom code consistent with the rest of the engine instead of reimplementing raw vector access.

Example

var fields = List.of(
    new Field("user", FieldType.nullable(new ArrowType.Utf8()), null));
VectorSchemaRoot root = ArrowValues.createRoot(fields, 2, allocator);
ArrowValues.set(root.getVector("user"), 0, "ada");
ArrowValues.set(root.getVector("user"), 1, null);
ArrowValues.finish(root);
Object first = ArrowValues.get(root.getVector("user"), 0); // "ada"
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.arrow.vector.VectorSchemaRoot
    createRoot(List<org.apache.arrow.vector.types.pojo.Field> fields, int rows, org.apache.arrow.memory.BufferAllocator allocator)
    Creates a batch with allocated vectors and the given row count.
    static void
    finish(org.apache.arrow.vector.VectorSchemaRoot root)
    Sets every vector's value count to the batch's row count.
    static Object
    get(org.apache.arrow.vector.FieldVector vector, int row)
    Reads one value from a vector as its natural Java representation.
    static void
    set(org.apache.arrow.vector.FieldVector vector, int row, Object value)
    Writes one value into a vector, coercing it to the vector's Arrow type.

    Methods inherited from class Object

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

    • createRoot

      public static org.apache.arrow.vector.VectorSchemaRoot createRoot(List<org.apache.arrow.vector.types.pojo.Field> fields, int rows, org.apache.arrow.memory.BufferAllocator allocator)
      Creates a batch with allocated vectors and the given row count.
      Parameters:
      fields - the columns of the batch
      rows - the number of rows the batch holds
      allocator - the allocator that owns the batch's buffers
      Returns:
      the batch; the caller must close it
    • set

      public static void set(org.apache.arrow.vector.FieldVector vector, int row, Object value)
      Writes one value into a vector, coercing it to the vector's Arrow type.
      Parameters:
      vector - the vector to write to
      row - the row index to write at
      value - the value to write; null marks the row null
      Throws:
      ColumnarException - if the vector's Arrow type is unsupported or the value does not fit it
    • get

      public static Object get(org.apache.arrow.vector.FieldVector vector, int row)
      Reads one value from a vector as its natural Java representation.
      Parameters:
      vector - the vector to read from
      row - the row index to read
      Returns:
      the value, or null if the row is null
    • finish

      public static void finish(org.apache.arrow.vector.VectorSchemaRoot root)
      Sets every vector's value count to the batch's row count.

      Call this once after the last set(FieldVector, int, Object) so readers observe every written row.

      Parameters:
      root - the batch to finish