@PublicEvolving public final class Row extends Object implements Serializable
The main purpose of rows is to bridge between Flink's Table and SQL ecosystem and other APIs.
Therefore, a row does not only consist of a schema part (containing the fields) but also attaches
a RowKind
for encoding a change in a changelog. Thus, a row can be considered as an entry
in a changelog. For example, in regular batch scenarios, a changelog would consist of a bounded
stream of RowKind.INSERT
rows.
The fields of a row can be accessed by position (zero-based) using getField(int)
and
setField(int, Object)
. The row kind is kept separate from the fields and can be accessed
by using getKind()
and setKind(RowKind)
.
A row instance is in principle Serializable
. However, it may contain non-serializable
fields in which case serialization will fail if the row is not serialized with Flink's
serialization stack.
The equals(Object)
and hashCode()
methods of this class support all external
conversion classes of the table ecosystem.
Constructor and Description |
---|
Row(int arity)
Create a new row instance.
|
Row(RowKind kind,
int arity)
Create a new row instance.
|
Modifier and Type | Method and Description |
---|---|
static Row |
copy(Row row)
Creates a new row which is copied from another row (including its
RowKind ). |
boolean |
equals(Object o) |
int |
getArity()
Returns the number of fields in the row.
|
Object |
getField(int pos)
Returns the field's content at the specified position.
|
RowKind |
getKind()
Returns the kind of change that this row describes in a changelog.
|
int |
hashCode() |
static Row |
join(Row first,
Row... remainings)
Creates a new row with fields that are copied from the other rows and appended to the
resulting row in the given order.
|
static Row |
of(Object... values)
Creates a new row and assigns the given values to the row's fields.
|
static Row |
ofKind(RowKind kind,
Object... values)
Creates a new row with given kind and assigns the given values to the row's fields.
|
static Row |
project(Row row,
int[] fields)
Creates a new row with projected fields and identical
RowKind from another row. |
void |
setField(int pos,
Object value)
Sets the field's content at the specified position.
|
void |
setKind(RowKind kind)
Sets the kind of change that this row describes in a changelog.
|
String |
toString() |
public Row(RowKind kind, int arity)
By default, a row describes an RowKind.INSERT
change.
kind
- kind of change a row describes in a changelogarity
- The number of fields in the row.public Row(int arity)
By default, a row describes an RowKind.INSERT
change.
arity
- The number of fields in the row.public RowKind getKind()
By default, a row describes an RowKind.INSERT
change.
RowKind
public void setKind(RowKind kind)
By default, a row describes an RowKind.INSERT
change.
RowKind
public int getArity()
Note: The row kind is kept separate from the fields and is not included in this number.
@Nullable public Object getField(int pos)
pos
- The position of the field, 0-based.public void setField(int pos, @Nullable Object value)
pos
- The position of the field, 0-based.value
- The value to be assigned to the field at the specified position.public static Row of(Object... values)
For example:
Row.of("hello", true, 1L);instead of
Row row = new Row(3); row.setField(0, "hello"); row.setField(1, true); row.setField(2, 1L);
By default, a row describes an RowKind.INSERT
change.
public static Row ofKind(RowKind kind, Object... values)
For example:
Row.ofKind(RowKind.INSERT, "hello", true, 1L);instead of
Row row = new Row(3); row.setKind(RowKind.INSERT); row.setField(0, "hello"); row.setField(1, true); row.setField(2, 1L);
public static Row copy(Row row)
RowKind
).
This method does not perform a deep copy.
public static Row project(Row row, int[] fields)
RowKind
from another row.
This method does not perform a deep copy.
fields
- field indices to be projectedCopyright © 2014–2021 The Apache Software Foundation. All rights reserved.