public final class BinaryRow extends BinarySection implements BaseRow
MemorySegment instead of Object. It can significantly
reduce the serialization/deserialization of Java objects.
A Row has two part: Fixed-length part and variable-length part.
Fixed-length part contains 1 byte header and null bit set and field values. Null bit set is used for null tracking and is aligned to 8-byte word boundaries. `Field values` holds fixed-length primitive types and variable-length values which can be stored in 8 bytes inside. If it do not fit the variable-length field, then store the length and offset of variable-length part.
Fixed-length part will certainly fall into a MemorySegment, which will speed up the read and write of field. During the write phase, if the target memory segment has less space than fixed length part size, we will skip the space. So the number of fields in a single Row cannot exceed the capacity of a single MemorySegment, if there are too many fields, we suggest that user set a bigger pageSize of MemorySegment.
Variable-length part may fall into multiple MemorySegments.
BinaryRow are influenced by Apache Spark UnsafeRow in project tungsten.
The difference is that BinaryRow is placed on a discontinuous memory, and the variable length
type can also be placed on a fixed length area (If it's short enough).
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
HEADER_SIZE_IN_BITS |
static boolean |
LITTLE_ENDIAN |
offset, segments, sizeInBytesHIGHEST_FIRST_BIT, HIGHEST_SECOND_TO_EIGHTH_BIT, MAX_FIX_PART_DATA_SIZE| 构造器和说明 |
|---|
BinaryRow(int arity) |
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
anyNull()
The bit is 1 when the field is null.
|
boolean |
anyNull(int[] fields) |
static int |
calculateBitSetWidthInBytes(int arity) |
static int |
calculateFixPartSizeInBytes(int arity) |
void |
clear() |
BinaryRow |
copy() |
BinaryRow |
copy(BinaryRow reuse) |
boolean |
equalsWithoutHeader(BaseRow o) |
int |
getArity()
Get the number of fields in the BaseRow.
|
BaseArray |
getArray(int pos)
Get array value, internal format is BaseArray.
|
byte[] |
getBinary(int pos)
Get binary value, internal format is byte[].
|
boolean |
getBoolean(int pos)
Get boolean value.
|
byte |
getByte(int pos)
Get byte value.
|
Decimal |
getDecimal(int pos,
int precision,
int scale)
Get decimal value, internal format is Decimal.
|
double |
getDouble(int pos)
Get double value.
|
int |
getFixedLengthPartSize() |
float |
getFloat(int pos)
Get float value.
|
<T> BinaryGeneric<T> |
getGeneric(int pos)
Get generic value, internal format is BinaryGeneric.
|
byte |
getHeader()
The header represents the type of this Row.
|
int |
getInt(int pos)
Get int value.
|
long |
getLong(int pos)
Get long value.
|
BaseMap |
getMap(int pos)
Get map value, internal format is BaseMap.
|
BaseRow |
getRow(int pos,
int numFields)
Get row value, internal format is BaseRow.
|
short |
getShort(int pos)
Get short value.
|
BinaryString |
getString(int pos)
Get string value, internal format is BinaryString.
|
SqlTimestamp |
getTimestamp(int pos,
int precision)
Get Timestamp value, internal format is SqlTimestamp.
|
int |
hashCode() |
static boolean |
isInFixedLengthPart(org.apache.flink.table.types.logical.LogicalType type)
If it is a fixed-length field, we can call this BinaryRow's setXX method for in-place updates.
|
static boolean |
isMutable(org.apache.flink.table.types.logical.LogicalType type) |
boolean |
isNullAt(int pos)
Because the specific row implementation such as BinaryRow uses the binary format.
|
void |
setBoolean(int pos,
boolean value)
Set boolean value.
|
void |
setByte(int pos,
byte value)
Set byte value.
|
void |
setDecimal(int pos,
Decimal value,
int precision)
Set the decimal column value.
|
void |
setDouble(int pos,
double value)
Set double value.
|
void |
setFloat(int pos,
float value)
Set float value.
|
void |
setHeader(byte header)
Set the byte header.
|
void |
setInt(int pos,
int value)
Set int value.
|
void |
setLong(int pos,
long value)
Set long value.
|
void |
setNullAt(int i)
Set null to this field.
|
void |
setShort(int pos,
short value)
Set short value.
|
void |
setTimestamp(int pos,
SqlTimestamp value,
int precision)
Set Timestamp value.
|
void |
setTotalSize(int sizeInBytes) |
static String |
toOriginString(BaseRow row,
org.apache.flink.table.types.logical.LogicalType[] types) |
String |
toOriginString(org.apache.flink.table.types.logical.LogicalType... types) |
equals, getOffset, getSegments, getSizeInBytes, pointTo, pointTogetreadBinaryFieldFromSegments, readBinaryStringFieldFromSegmentspublic static final boolean LITTLE_ENDIAN
public static final int HEADER_SIZE_IN_BITS
public static int calculateBitSetWidthInBytes(int arity)
public static int calculateFixPartSizeInBytes(int arity)
public static boolean isInFixedLengthPart(org.apache.flink.table.types.logical.LogicalType type)
public static boolean isMutable(org.apache.flink.table.types.logical.LogicalType type)
public int getFixedLengthPartSize()
public int getArity()
BaseRowpublic byte getHeader()
BaseRowpublic void setHeader(byte header)
BaseRowpublic void setTotalSize(int sizeInBytes)
public boolean isNullAt(int pos)
TypeGetterSettersisNullAt 在接口中 TypeGetterSetterspublic void setNullAt(int i)
TypeGetterSetterssetNullAt 在接口中 TypeGetterSetterspublic void setInt(int pos,
int value)
TypeGetterSetterssetInt 在接口中 TypeGetterSetterspublic void setLong(int pos,
long value)
TypeGetterSetterssetLong 在接口中 TypeGetterSetterspublic void setDouble(int pos,
double value)
TypeGetterSetterssetDouble 在接口中 TypeGetterSetterspublic void setDecimal(int pos,
Decimal value,
int precision)
TypeGetterSettersNote: Precision is compact: can call setNullAt when decimal is null. Precision is not compact: can not call setNullAt when decimal is null, must call setDecimal(i, null, precision) because we need update var-length-part.
setDecimal 在接口中 TypeGetterSetterspublic void setTimestamp(int pos,
SqlTimestamp value,
int precision)
TypeGetterSettersNote: If precision is compact: can call setNullAt when SqlTimestamp value is null. Otherwise: can not call setNullAt when SqlTimestamp value is null, must call setTimestamp(ordinal, null, precision) because we need to update var-length-part.
setTimestamp 在接口中 TypeGetterSetterspublic void setBoolean(int pos,
boolean value)
TypeGetterSetterssetBoolean 在接口中 TypeGetterSetterspublic void setShort(int pos,
short value)
TypeGetterSetterssetShort 在接口中 TypeGetterSetterspublic void setByte(int pos,
byte value)
TypeGetterSetterssetByte 在接口中 TypeGetterSetterspublic void setFloat(int pos,
float value)
TypeGetterSetterssetFloat 在接口中 TypeGetterSetterspublic boolean getBoolean(int pos)
TypeGetterSettersgetBoolean 在接口中 TypeGetterSetterspublic byte getByte(int pos)
TypeGetterSettersgetByte 在接口中 TypeGetterSetterspublic short getShort(int pos)
TypeGetterSettersgetShort 在接口中 TypeGetterSetterspublic int getInt(int pos)
TypeGetterSettersgetInt 在接口中 TypeGetterSetterspublic long getLong(int pos)
TypeGetterSettersgetLong 在接口中 TypeGetterSetterspublic float getFloat(int pos)
TypeGetterSettersgetFloat 在接口中 TypeGetterSetterspublic double getDouble(int pos)
TypeGetterSettersgetDouble 在接口中 TypeGetterSetterspublic BinaryString getString(int pos)
TypeGetterSettersgetString 在接口中 TypeGetterSetterspublic Decimal getDecimal(int pos, int precision, int scale)
TypeGetterSettersgetDecimal 在接口中 TypeGetterSetterspublic SqlTimestamp getTimestamp(int pos, int precision)
TypeGetterSettersgetTimestamp 在接口中 TypeGetterSetterspublic <T> BinaryGeneric<T> getGeneric(int pos)
TypeGetterSettersgetGeneric 在接口中 TypeGetterSetterspublic byte[] getBinary(int pos)
TypeGetterSettersgetBinary 在接口中 TypeGetterSetterspublic BaseArray getArray(int pos)
TypeGetterSettersgetArray 在接口中 TypeGetterSetterspublic BaseMap getMap(int pos)
TypeGetterSettersgetMap 在接口中 TypeGetterSetterspublic BaseRow getRow(int pos, int numFields)
TypeGetterSettersgetRow 在接口中 TypeGetterSetterspublic boolean anyNull()
public boolean anyNull(int[] fields)
public BinaryRow copy()
public void clear()
public int hashCode()
hashCode 在类中 BinarySectionpublic String toOriginString(org.apache.flink.table.types.logical.LogicalType... types)
public static String toOriginString(BaseRow row, org.apache.flink.table.types.logical.LogicalType[] types)
public boolean equalsWithoutHeader(BaseRow o)
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.