Package org.apache.beam.sdk.values
Class Row
java.lang.Object
org.apache.beam.sdk.values.Row
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
RowWithGetters
,RowWithStorage
Row
is an immutable tuple-like schema to represent one element in a PCollection
.
The fields are described with a Schema
.
Schema
contains the names and types for each field.
There are several ways to build a new Row object. To build a row from scratch using a schema
object, withSchema(org.apache.beam.sdk.schemas.Schema)
can be used. Schema fields can be specified by name, and nested
fields can be specified using the field selection syntax. For example:
Row row = Row.withSchema(schema)
.withFieldValue("userId", "user1)
.withFieldValue("location.city", "seattle")
.withFieldValue("location.state", "wa")
.build();
The fromRow(org.apache.beam.sdk.values.Row)
builder can be used to base a row off of another row. The builder can
be used to specify values for specific fields, and all the remaining values will be taken from
the original row. For example, the following produces a row identical to the above row except for
the location.city field.
Row modifiedRow =
Row.fromRow(row)
.withFieldValue("location.city", "tacoma")
.build();
- See Also:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionboolean
static Row.FieldValueBuilder
Creates a row builder based on the specified row.<T> @Nullable Collection
<T> getArray
(int idx) Get an array value by field index,IllegalStateException
is thrown if schema doesn't match.<T> @Nullable Collection
<T> Get an array value by field name,IllegalStateException
is thrown if schema doesn't match.getBaseValue
(int idx) Returns the base type for this field.getBaseValue
(int idx, Class<T> clazz) Returns the base type for this field.getBaseValue
(String fieldName) Returns the base type for this field.getBaseValue
(String fieldName, Class<T> clazz) Returns the base type for this field.Return a list of data values.getBoolean
(int idx) Get aBoolean
value by field index,ClassCastException
is thrown if schema doesn't match.getBoolean
(String fieldName) Get aSchema.TypeName.BOOLEAN
value by field name,IllegalStateException
is thrown if schema doesn't match.getByte
(int idx) Get aSchema.TypeName.BYTE
value by field index,ClassCastException
is thrown if schema doesn't match.Get aSchema.TypeName.BYTE
value by field name,IllegalStateException
is thrown if schema doesn't match.byte @Nullable []
getBytes
(int idx) Get aSchema.TypeName.BYTES
value by field index,ClassCastException
is thrown if schema doesn't match.byte @Nullable []
Get aSchema.TypeName.BYTES
value by field name,IllegalStateException
is thrown if schema doesn't match.getDateTime
(int idx) Get aSchema.TypeName.DATETIME
value by field index,IllegalStateException
is thrown if schema doesn't match.getDateTime
(String fieldName) Get aSchema.TypeName.DATETIME
value by field name,IllegalStateException
is thrown if schema doesn't match.getDecimal
(int idx) Get aBigDecimal
value by field index,ClassCastException
is thrown if schema doesn't match.getDecimal
(String fieldName) Get aSchema.TypeName.DECIMAL
value by field name,IllegalStateException
is thrown if schema doesn't match.getDouble
(int idx) Get aSchema.TypeName.DOUBLE
value by field index,ClassCastException
is thrown if schema doesn't match.Get aSchema.TypeName.DOUBLE
value by field name,IllegalStateException
is thrown if schema doesn't match.abstract int
Return the size of data fields.getFloat
(int idx) Get aSchema.TypeName.FLOAT
value by field index,ClassCastException
is thrown if schema doesn't match.Get aSchema.TypeName.FLOAT
value by field name,IllegalStateException
is thrown if schema doesn't match.getInt16
(int idx) Get aSchema.TypeName.INT16
value by field index,ClassCastException
is thrown if schema doesn't match.Get aSchema.TypeName.INT16
value by field name,IllegalStateException
is thrown if schema doesn't match.getInt32
(int idx) Get aSchema.TypeName.INT32
value by field index,ClassCastException
is thrown if schema doesn't match.Get aSchema.TypeName.INT32
value by field name,IllegalStateException
is thrown if schema doesn't match.getInt64
(int idx) Get aSchema.TypeName.INT64
value by field index,ClassCastException
is thrown if schema doesn't match.Get aSchema.TypeName.INT64
value by field name,IllegalStateException
is thrown if schema doesn't match.getIterable
(int idx) Get an iterable value by field index,IllegalStateException
is thrown if schema doesn't match.getIterable
(String fieldName) Get an iterable value by field name,IllegalStateException
is thrown if schema doesn't match.getLogicalTypeValue
(int idx, Class<T> clazz) Returns the Logical Type input type for this field.getLogicalTypeValue
(String fieldName, Class<T> clazz) Returns the Logical Type input type for this field.getMap
(int idx) Get a MAP value by field index,IllegalStateException
is thrown if schema doesn't match.Get a MAP value by field name,IllegalStateException
is thrown if schema doesn't match.getRow
(int idx) Get aRow
value by field index,IllegalStateException
is thrown if schema doesn't match.Get aSchema.TypeName.ROW
value by field name,IllegalStateException
is thrown if schema doesn't match.ReturnSchema
which describes the fields.getString
(int idx) Get aString
value by field index,ClassCastException
is thrown if schema doesn't match.Get aSchema.TypeName.STRING
value by field name,IllegalStateException
is thrown if schema doesn't match.getValue
(int fieldIdx) Get value by field index,ClassCastException
is thrown if schema doesn't match.Get value by field name,ClassCastException
is thrown if type doesn't match.Return the list of raw unmodified data values to enable 0-copy code.int
hashCode()
static Row
Creates a new record filled with nulls.sorted()
Returns an equivalentRow
with fields lexicographically sorted by their name.Returns an equivalentRow
with `lowerCamelCase` field names.Creates aRow
from the list of values andgetSchema()
.Returns an equivalentRow
with `snake_case` field names.toString()
toString
(boolean includeFieldNames) Convert Row to String.static Row.Builder
withSchema
(Schema schema) Creates a row builder with specifiedgetSchema()
.
-
Method Details
-
getValue
Get value by field index,ClassCastException
is thrown if schema doesn't match. -
getFieldCount
public abstract int getFieldCount()Return the size of data fields. -
getValues
Return the list of raw unmodified data values to enable 0-copy code. -
getBaseValues
Return a list of data values. Any LogicalType values are returned as base values. * -
getValue
Get value by field name,ClassCastException
is thrown if type doesn't match. -
getByte
Get aSchema.TypeName.BYTE
value by field name,IllegalStateException
is thrown if schema doesn't match. -
getBytes
Get aSchema.TypeName.BYTES
value by field name,IllegalStateException
is thrown if schema doesn't match. -
getInt16
Get aSchema.TypeName.INT16
value by field name,IllegalStateException
is thrown if schema doesn't match. -
getInt32
Get aSchema.TypeName.INT32
value by field name,IllegalStateException
is thrown if schema doesn't match. -
getInt64
Get aSchema.TypeName.INT64
value by field name,IllegalStateException
is thrown if schema doesn't match. -
getDecimal
Get aSchema.TypeName.DECIMAL
value by field name,IllegalStateException
is thrown if schema doesn't match. -
getFloat
Get aSchema.TypeName.FLOAT
value by field name,IllegalStateException
is thrown if schema doesn't match. -
getDouble
Get aSchema.TypeName.DOUBLE
value by field name,IllegalStateException
is thrown if schema doesn't match. -
getString
Get aSchema.TypeName.STRING
value by field name,IllegalStateException
is thrown if schema doesn't match. -
getDateTime
Get aSchema.TypeName.DATETIME
value by field name,IllegalStateException
is thrown if schema doesn't match. -
getBoolean
Get aSchema.TypeName.BOOLEAN
value by field name,IllegalStateException
is thrown if schema doesn't match. -
getArray
Get an array value by field name,IllegalStateException
is thrown if schema doesn't match. -
getIterable
Get an iterable value by field name,IllegalStateException
is thrown if schema doesn't match. -
getMap
Get a MAP value by field name,IllegalStateException
is thrown if schema doesn't match. -
getLogicalTypeValue
Returns the Logical Type input type for this field.IllegalStateException
is thrown if schema doesn't match. -
getBaseValue
Returns the base type for this field. If this is a logical type, we convert to the base value. Otherwise the field itself is returned. -
getBaseValue
Returns the base type for this field. If this is a logical type, we convert to the base value. Otherwise the field itself is returned. -
getRow
Get aSchema.TypeName.ROW
value by field name,IllegalStateException
is thrown if schema doesn't match. -
getByte
Get aSchema.TypeName.BYTE
value by field index,ClassCastException
is thrown if schema doesn't match. -
getBytes
Get aSchema.TypeName.BYTES
value by field index,ClassCastException
is thrown if schema doesn't match. -
getInt16
Get aSchema.TypeName.INT16
value by field index,ClassCastException
is thrown if schema doesn't match. -
getInt32
Get aSchema.TypeName.INT32
value by field index,ClassCastException
is thrown if schema doesn't match. -
getFloat
Get aSchema.TypeName.FLOAT
value by field index,ClassCastException
is thrown if schema doesn't match. -
getDouble
Get aSchema.TypeName.DOUBLE
value by field index,ClassCastException
is thrown if schema doesn't match. -
getInt64
Get aSchema.TypeName.INT64
value by field index,ClassCastException
is thrown if schema doesn't match. -
getString
Get aString
value by field index,ClassCastException
is thrown if schema doesn't match. -
getDateTime
Get aSchema.TypeName.DATETIME
value by field index,IllegalStateException
is thrown if schema doesn't match. -
getDecimal
Get aBigDecimal
value by field index,ClassCastException
is thrown if schema doesn't match. -
getBoolean
Get aBoolean
value by field index,ClassCastException
is thrown if schema doesn't match. -
getArray
Get an array value by field index,IllegalStateException
is thrown if schema doesn't match. -
getIterable
Get an iterable value by field index,IllegalStateException
is thrown if schema doesn't match. -
getMap
Get a MAP value by field index,IllegalStateException
is thrown if schema doesn't match. -
getLogicalTypeValue
Returns the Logical Type input type for this field.IllegalStateException
is thrown if schema doesn't match. -
getBaseValue
Returns the base type for this field. If this is a logical type, we convert to the base value. Otherwise the field itself is returned. -
getBaseValue
Returns the base type for this field. If this is a logical type, we convert to the base value. Otherwise the field itself is returned. -
getRow
Get aRow
value by field index,IllegalStateException
is thrown if schema doesn't match. -
getSchema
ReturnSchema
which describes the fields. -
equals
-
hashCode
public int hashCode() -
toString
-
toString
Convert Row to String. -
withSchema
Creates a row builder with specifiedgetSchema()
.Row.Builder.build()
will throw anIllegalArgumentException
if number of fields ingetSchema()
does not match the number of fields specified. If any of the arguments don't match the expected types for the schema fields,Row.Builder.build()
will throw aClassCastException
. -
fromRow
Creates a row builder based on the specified row. Field values in the new row can be explicitly set usingRow.FieldValueBuilder.withFieldValue(java.lang.String, java.lang.Object)
. Any values not so overridden will be the same as the values in the original row. -
toRow
Creates aRow
from the list of values andgetSchema()
. -
nullRow
Creates a new record filled with nulls. -
sorted
Returns an equivalentRow
with fields lexicographically sorted by their name. -
toSnakeCase
Returns an equivalentRow
with `snake_case` field names. -
toCamelCase
Returns an equivalentRow
with `lowerCamelCase` field names.
-