Interface RowData
- All Known Implementing Classes:
BinaryRowData,ColumnarRowData,GenericRowData,JoinedRowData,NestedRowData,ProjectedRowData
RowType and other
(possibly nested) structured types such as StructuredType in the table ecosystem.
All top-level records that are travelling through Table API or SQL pipelines during runtime
are instances of this interface. Each RowData contains a RowKind which represents
the kind of change that a row describes in a changelog. The RowKind is just metadata
information of row and thus not part of the table's schema, i.e., not a dedicated field.
Note: All fields of this data structure must be internal data structures.
The RowData interface has different implementations which are designed for different
scenarios:
- The binary-oriented implementation
BinaryRowDatais backed by references toMemorySegmentinstead of using Java objects to reduce the serialization/deserialization overhead. - The object-oriented implementation
GenericRowDatais backed by an array of JavaObjectwhich is easy to construct and efficient to update.
GenericRowData is intended for public use and has stable behavior. It is recommended
to construct instances of RowData with this class if internal data structures are
required.
The mappings from Flink's Table API and SQL data types to the internal data structures are listed in the following table:
+--------------------------------+-----------------------------------------+ | SQL Data Types | Internal Data Structures | +--------------------------------+-----------------------------------------+ | BOOLEAN | boolean | +--------------------------------+-----------------------------------------+ | CHAR / VARCHAR / STRING |StringData| +--------------------------------+-----------------------------------------+ | BINARY / VARBINARY / BYTES | byte[] | +--------------------------------+-----------------------------------------+ | DECIMAL |DecimalData| +--------------------------------+-----------------------------------------+ | TINYINT | byte | +--------------------------------+-----------------------------------------+ | SMALLINT | short | +--------------------------------+-----------------------------------------+ | INT | int | +--------------------------------+-----------------------------------------+ | BIGINT | long | +--------------------------------+-----------------------------------------+ | FLOAT | float | +--------------------------------+-----------------------------------------+ | DOUBLE | double | +--------------------------------+-----------------------------------------+ | DATE | int (number of days since epoch) | +--------------------------------+-----------------------------------------+ | TIME | int (number of milliseconds of the day) | +--------------------------------+-----------------------------------------+ | TIMESTAMP |TimestampData| +--------------------------------+-----------------------------------------+ | TIMESTAMP WITH LOCAL TIME ZONE |TimestampData| +--------------------------------+-----------------------------------------+ | INTERVAL YEAR TO MONTH | int (number of months) | +--------------------------------+-----------------------------------------+ | INTERVAL DAY TO MONTH | long (number of milliseconds) | +--------------------------------+-----------------------------------------+ | ROW / structured types |RowData| +--------------------------------+-----------------------------------------+ | ARRAY |ArrayData| +--------------------------------+-----------------------------------------+ | MAP / MULTISET |MapData| +--------------------------------+-----------------------------------------+ | RAW |RawValueData| +--------------------------------+-----------------------------------------+
Nullability is always handled by the container data structure.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAccessor for getting the field of a row during runtime. -
Method Summary
Modifier and TypeMethodDescriptionstatic RowData.FieldGettercreateFieldGetter(LogicalType fieldType, int fieldPos) Creates an accessor for getting elements in an internal row data structure at the given position.intgetArity()Returns the number of fields in this row.getArray(int pos) Returns the array value at the given position.byte[]getBinary(int pos) Returns the binary value at the given position.booleangetBoolean(int pos) Returns the boolean value at the given position.bytegetByte(int pos) Returns the byte value at the given position.getDecimal(int pos, int precision, int scale) Returns the decimal value at the given position.doublegetDouble(int pos) Returns the double value at the given position.floatgetFloat(int pos) Returns the float value at the given position.intgetInt(int pos) Returns the integer value at the given position.longgetLong(int pos) Returns the long value at the given position.getMap(int pos) Returns the map value at the given position.<T> RawValueData<T>getRawValue(int pos) Returns the raw value at the given position.getRow(int pos, int numFields) Returns the row value at the given position.org.apache.flink.types.RowKindReturns the kind of change that this row describes in a changelog.shortgetShort(int pos) Returns the short value at the given position.getString(int pos) Returns the string value at the given position.getTimestamp(int pos, int precision) Returns the timestamp value at the given position.booleanisNullAt(int pos) Returns true if the field is null at the given position.voidsetRowKind(org.apache.flink.types.RowKind kind) Sets the kind of change that this row describes in a changelog.
-
Method Details
-
getArity
int getArity()Returns the number of fields in this row.The number does not include
RowKind. It is kept separately. -
getRowKind
org.apache.flink.types.RowKind getRowKind()Returns the kind of change that this row describes in a changelog.- See Also:
-
RowKind
-
setRowKind
void setRowKind(org.apache.flink.types.RowKind kind) Sets the kind of change that this row describes in a changelog.- See Also:
-
RowKind
-
isNullAt
boolean isNullAt(int pos) Returns true if the field is null at the given position. -
getBoolean
boolean getBoolean(int pos) Returns the boolean value at the given position. -
getByte
byte getByte(int pos) Returns the byte value at the given position. -
getShort
short getShort(int pos) Returns the short value at the given position. -
getInt
int getInt(int pos) Returns the integer value at the given position. -
getLong
long getLong(int pos) Returns the long value at the given position. -
getFloat
float getFloat(int pos) Returns the float value at the given position. -
getDouble
double getDouble(int pos) Returns the double value at the given position. -
getString
Returns the string value at the given position. -
getDecimal
Returns the decimal value at the given position.The precision and scale are required to determine whether the decimal value was stored in a compact representation (see
DecimalData). -
getTimestamp
Returns the timestamp value at the given position.The precision is required to determine whether the timestamp value was stored in a compact representation (see
TimestampData). -
getRawValue
Returns the raw value at the given position. -
getBinary
byte[] getBinary(int pos) Returns the binary value at the given position. -
getArray
Returns the array value at the given position. -
getMap
Returns the map value at the given position. -
getRow
Returns the row value at the given position.The number of fields is required to correctly extract the row.
-
createFieldGetter
Creates an accessor for getting elements in an internal row data structure at the given position.- Parameters:
fieldType- the element type of the rowfieldPos- the element position of the row
-