Package io.fury.format.row.binary
Class BinaryRow
java.lang.Object
io.fury.format.row.binary.BinaryRow
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleananyNull()voidassertIndexIsValid(int index) copy()getArray(int ordinal) intbyte[]getBinary(int ordinal) booleangetBoolean(int ordinal) getBuffer(int ordinal) bytegetByte(int ordinal) intgetDate(int ordinal) getDecimal(int ordinal) doublegetDouble(int ordinal) floatgetFloat(int ordinal) intgetInt(int ordinal) longgetLong(int ordinal) getMap(int ordinal) intgetOffset(int ordinal) org.apache.arrow.vector.types.pojo.SchemashortgetShort(int ordinal) intgetString(int ordinal) getStruct(int ordinal) longgetTimestamp(int ordinal) static booleanisFixedLength(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.booleanisNullAt(int ordinal) intvoidpointTo(MemoryBuffer buffer, int offset, int sizeInBytes) voidsetBoolean(int ordinal, boolean value) voidsetByte(int ordinal, byte value) voidsetDate(int ordinal, int value) voidsetDouble(int ordinal, double value) voidsetFloat(int ordinal, float value) voidsetInt(int ordinal, int value) voidsetLong(int ordinal, long value) voidsetNotNullAt(int ordinal) voidsetNullAt(int ordinal) voidsetShort(int ordinal, short value) voidsetTimestamp(int ordinal, long value) byte[]toBytes()toMap()toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
BinaryRow
public BinaryRow(org.apache.arrow.vector.types.pojo.Schema schema)
-
-
Method Details
-
pointTo
-
getSchema
public org.apache.arrow.vector.types.pojo.Schema getSchema() -
numFields
public int numFields() -
getSizeInBytes
public int getSizeInBytes() -
getBaseOffset
public int getBaseOffset() -
getBuffer
-
getOffset
public int getOffset(int ordinal) -
assertIndexIsValid
public void assertIndexIsValid(int index) -
isNullAt
public boolean isNullAt(int ordinal) -
anyNull
public boolean anyNull() -
setNullAt
public void setNullAt(int ordinal) -
setNotNullAt
public void setNotNullAt(int ordinal) -
getDecimal
- Specified by:
getDecimalin interfaceGetters
-
getStruct
-
getArray
-
getMap
-
copy
-
toString
-
toDebugString
-
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
-
getBoolean
public boolean getBoolean(int ordinal) - Specified by:
getBooleanin interfaceGetters
-
getByte
public byte getByte(int ordinal) -
getShort
public short getShort(int ordinal) -
getInt
public int getInt(int ordinal) -
getLong
public long getLong(int ordinal) -
getFloat
public float getFloat(int ordinal) -
getDouble
public double getDouble(int ordinal) -
getDate
public int getDate(int ordinal) -
getTimestamp
public long getTimestamp(int ordinal) - Specified by:
getTimestampin interfaceGetters
-
getString
-
getBinary
public byte[] getBinary(int ordinal) -
setBoolean
public void setBoolean(int ordinal, boolean value) - Specified by:
setBooleanin interfaceSetters
-
setByte
public void setByte(int ordinal, byte value) -
setShort
public void setShort(int ordinal, short value) -
setInt
public void setInt(int ordinal, int value) -
setLong
public void setLong(int ordinal, long value) -
setFloat
public void setFloat(int ordinal, float value) -
setDouble
public void setDouble(int ordinal, double value) -
setDate
public void setDate(int ordinal, int value) -
setTimestamp
public void setTimestamp(int ordinal, long value) - Specified by:
setTimestampin interfaceSetters
-