Class BinaryRow

java.lang.Object
io.fury.format.row.binary.BinaryRow
All Implemented Interfaces:
Getters, Row, Setters

public class BinaryRow extends Object implements Row
A binary implementation of Row backed by binary buffer instead of java objects.
  • Validity Bit Set Bitmap Region (1 bit/field) for tracking null values. Primitive type is always considered to be not null. Set bit to 1 indicate the value is not null, Set bit to 0 indicate null
  • Fixed-Length 8-byte Values Region. if field isn't aligned, read any length-gt-1 value may need read multi times cache.
  • Variable-Length Data Section

Equality comparison and hashing of rows can be performed on raw bytes since if two rows are identical so should be their bit-wise representation.

    BinaryRow is inspired by Apache Spark tungsten UnsafeRow, the differences are
  • Use arrow schema to describe meta.
  • String support latin/utf16/utf8 encoding.
  • Decimal use arrow decimal format.
  • Variable-size field can be inline in fixed-size region if small enough.
  • Allow skip padding by generate Row using aot to put offsets in generated code.
  • The implementation support java/C++/python/etc..
  • Support adding fields without breaking compatibility
  • Constructor Details

    • BinaryRow

      public BinaryRow(org.apache.arrow.vector.types.pojo.Schema schema)
  • Method Details

    • pointTo

      public void pointTo(MemoryBuffer buffer, int offset, int sizeInBytes)
    • getSchema

      public org.apache.arrow.vector.types.pojo.Schema getSchema()
      Specified by:
      getSchema in interface Row
    • numFields

      public int numFields()
      Specified by:
      numFields in interface Row
    • getSizeInBytes

      public int getSizeInBytes()
    • getBaseOffset

      public int getBaseOffset()
    • getBuffer

      public MemoryBuffer getBuffer()
    • getOffset

      public int getOffset(int ordinal)
    • assertIndexIsValid

      public void assertIndexIsValid(int index)
    • isNullAt

      public boolean isNullAt(int ordinal)
      Specified by:
      isNullAt in interface Getters
    • anyNull

      public boolean anyNull()
      Specified by:
      anyNull in interface Row
    • setNullAt

      public void setNullAt(int ordinal)
      Specified by:
      setNullAt in interface Setters
    • setNotNullAt

      public void setNotNullAt(int ordinal)
    • getDecimal

      public BigDecimal getDecimal(int ordinal)
      Specified by:
      getDecimal in interface Getters
    • getStruct

      public BinaryRow getStruct(int ordinal)
      Specified by:
      getStruct in interface Getters
    • getArray

      public BinaryArray getArray(int ordinal)
      Specified by:
      getArray in interface Getters
    • getMap

      public BinaryMap getMap(int ordinal)
      Specified by:
      getMap in interface Getters
    • copy

      public Row copy()
      Specified by:
      copy in interface Row
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toDebugString

      public String toDebugString()
    • toMap

      public Map<String,Object> toMap()
    • toBytes

      public byte[] toBytes()
    • isFixedLength

      public static boolean isFixedLength(org.apache.arrow.vector.types.pojo.ArrowType type)
      If it is a fixed-length field, we can call this BinaryRow's setXX method for in-place updates. If it is variable-length field, can't use this method, because the underlying data is stored continuously.
    • getBuffer

      public MemoryBuffer getBuffer(int ordinal)
      Specified by:
      getBuffer in interface Getters
    • getBoolean

      public boolean getBoolean(int ordinal)
      Specified by:
      getBoolean in interface Getters
    • getByte

      public byte getByte(int ordinal)
      Specified by:
      getByte in interface Getters
    • getShort

      public short getShort(int ordinal)
      Specified by:
      getShort in interface Getters
    • getInt

      public int getInt(int ordinal)
      Specified by:
      getInt in interface Getters
    • getLong

      public long getLong(int ordinal)
      Specified by:
      getLong in interface Getters
    • getFloat

      public float getFloat(int ordinal)
      Specified by:
      getFloat in interface Getters
    • getDouble

      public double getDouble(int ordinal)
      Specified by:
      getDouble in interface Getters
    • getDate

      public int getDate(int ordinal)
      Specified by:
      getDate in interface Getters
    • getTimestamp

      public long getTimestamp(int ordinal)
      Specified by:
      getTimestamp in interface Getters
    • getString

      public String getString(int ordinal)
      Specified by:
      getString in interface Getters
    • getBinary

      public byte[] getBinary(int ordinal)
      Specified by:
      getBinary in interface Getters
    • setBoolean

      public void setBoolean(int ordinal, boolean value)
      Specified by:
      setBoolean in interface Setters
    • setByte

      public void setByte(int ordinal, byte value)
      Specified by:
      setByte in interface Setters
    • setShort

      public void setShort(int ordinal, short value)
      Specified by:
      setShort in interface Setters
    • setInt

      public void setInt(int ordinal, int value)
      Specified by:
      setInt in interface Setters
    • setLong

      public void setLong(int ordinal, long value)
      Specified by:
      setLong in interface Setters
    • setFloat

      public void setFloat(int ordinal, float value)
      Specified by:
      setFloat in interface Setters
    • setDouble

      public void setDouble(int ordinal, double value)
      Specified by:
      setDouble in interface Setters
    • setDate

      public void setDate(int ordinal, int value)
      Specified by:
      setDate in interface Setters
    • setTimestamp

      public void setTimestamp(int ordinal, long value)
      Specified by:
      setTimestamp in interface Setters