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 TypeMethodDescriptionbooleanstatic Row.FieldValueBuilderCreates a row builder based on the specified row.<T> @Nullable Collection<T> getArray(int idx) Get an array value by field index,IllegalStateExceptionis thrown if schema doesn't match.<T> @Nullable Collection<T> Get an array value by field name,IllegalStateExceptionis 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 aBooleanvalue by field index,ClassCastExceptionis thrown if schema doesn't match.getBoolean(String fieldName) Get aSchema.TypeName.BOOLEANvalue by field name,IllegalStateExceptionis thrown if schema doesn't match.getByte(int idx) Get aSchema.TypeName.BYTEvalue by field index,ClassCastExceptionis thrown if schema doesn't match.Get aSchema.TypeName.BYTEvalue by field name,IllegalStateExceptionis thrown if schema doesn't match.byte @Nullable []getBytes(int idx) Get aSchema.TypeName.BYTESvalue by field index,ClassCastExceptionis thrown if schema doesn't match.byte @Nullable []Get aSchema.TypeName.BYTESvalue by field name,IllegalStateExceptionis thrown if schema doesn't match.getDateTime(int idx) Get aSchema.TypeName.DATETIMEvalue by field index,IllegalStateExceptionis thrown if schema doesn't match.getDateTime(String fieldName) Get aSchema.TypeName.DATETIMEvalue by field name,IllegalStateExceptionis thrown if schema doesn't match.getDecimal(int idx) Get aBigDecimalvalue by field index,ClassCastExceptionis thrown if schema doesn't match.getDecimal(String fieldName) Get aSchema.TypeName.DECIMALvalue by field name,IllegalStateExceptionis thrown if schema doesn't match.getDouble(int idx) Get aSchema.TypeName.DOUBLEvalue by field index,ClassCastExceptionis thrown if schema doesn't match.Get aSchema.TypeName.DOUBLEvalue by field name,IllegalStateExceptionis thrown if schema doesn't match.abstract intReturn the size of data fields.getFloat(int idx) Get aSchema.TypeName.FLOATvalue by field index,ClassCastExceptionis thrown if schema doesn't match.Get aSchema.TypeName.FLOATvalue by field name,IllegalStateExceptionis thrown if schema doesn't match.getInt16(int idx) Get aSchema.TypeName.INT16value by field index,ClassCastExceptionis thrown if schema doesn't match.Get aSchema.TypeName.INT16value by field name,IllegalStateExceptionis thrown if schema doesn't match.getInt32(int idx) Get aSchema.TypeName.INT32value by field index,ClassCastExceptionis thrown if schema doesn't match.Get aSchema.TypeName.INT32value by field name,IllegalStateExceptionis thrown if schema doesn't match.getInt64(int idx) Get aSchema.TypeName.INT64value by field index,ClassCastExceptionis thrown if schema doesn't match.Get aSchema.TypeName.INT64value by field name,IllegalStateExceptionis thrown if schema doesn't match.getIterable(int idx) Get an iterable value by field index,IllegalStateExceptionis thrown if schema doesn't match.getIterable(String fieldName) Get an iterable value by field name,IllegalStateExceptionis 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,IllegalStateExceptionis thrown if schema doesn't match.Get a MAP value by field name,IllegalStateExceptionis thrown if schema doesn't match.getRow(int idx) Get aRowvalue by field index,IllegalStateExceptionis thrown if schema doesn't match.Get aSchema.TypeName.ROWvalue by field name,IllegalStateExceptionis thrown if schema doesn't match.ReturnSchemawhich describes the fields.getString(int idx) Get aStringvalue by field index,ClassCastExceptionis thrown if schema doesn't match.Get aSchema.TypeName.STRINGvalue by field name,IllegalStateExceptionis thrown if schema doesn't match.getValue(int fieldIdx) Get value by field index,ClassCastExceptionis thrown if schema doesn't match.Get value by field name,ClassCastExceptionis thrown if type doesn't match.Return the list of raw unmodified data values to enable 0-copy code.inthashCode()static RowCreates a new record filled with nulls.sorted()Returns an equivalentRowwith fields lexicographically sorted by their name.Returns an equivalentRowwith `lowerCamelCase` field names.Creates aRowfrom the list of values andgetSchema().Returns an equivalentRowwith `snake_case` field names.toString()toString(boolean includeFieldNames) Convert Row to String.static Row.BuilderwithSchema(Schema schema) Creates a row builder with specifiedgetSchema().
-
Method Details
-
getValue
Get value by field index,ClassCastExceptionis 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,ClassCastExceptionis thrown if type doesn't match. -
getByte
Get aSchema.TypeName.BYTEvalue by field name,IllegalStateExceptionis thrown if schema doesn't match. -
getBytes
Get aSchema.TypeName.BYTESvalue by field name,IllegalStateExceptionis thrown if schema doesn't match. -
getInt16
Get aSchema.TypeName.INT16value by field name,IllegalStateExceptionis thrown if schema doesn't match. -
getInt32
Get aSchema.TypeName.INT32value by field name,IllegalStateExceptionis thrown if schema doesn't match. -
getInt64
Get aSchema.TypeName.INT64value by field name,IllegalStateExceptionis thrown if schema doesn't match. -
getDecimal
Get aSchema.TypeName.DECIMALvalue by field name,IllegalStateExceptionis thrown if schema doesn't match. -
getFloat
Get aSchema.TypeName.FLOATvalue by field name,IllegalStateExceptionis thrown if schema doesn't match. -
getDouble
Get aSchema.TypeName.DOUBLEvalue by field name,IllegalStateExceptionis thrown if schema doesn't match. -
getString
Get aSchema.TypeName.STRINGvalue by field name,IllegalStateExceptionis thrown if schema doesn't match. -
getDateTime
Get aSchema.TypeName.DATETIMEvalue by field name,IllegalStateExceptionis thrown if schema doesn't match. -
getBoolean
Get aSchema.TypeName.BOOLEANvalue by field name,IllegalStateExceptionis thrown if schema doesn't match. -
getArray
Get an array value by field name,IllegalStateExceptionis thrown if schema doesn't match. -
getIterable
Get an iterable value by field name,IllegalStateExceptionis thrown if schema doesn't match. -
getMap
Get a MAP value by field name,IllegalStateExceptionis thrown if schema doesn't match. -
getLogicalTypeValue
Returns the Logical Type input type for this field.IllegalStateExceptionis 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.ROWvalue by field name,IllegalStateExceptionis thrown if schema doesn't match. -
getByte
Get aSchema.TypeName.BYTEvalue by field index,ClassCastExceptionis thrown if schema doesn't match. -
getBytes
Get aSchema.TypeName.BYTESvalue by field index,ClassCastExceptionis thrown if schema doesn't match. -
getInt16
Get aSchema.TypeName.INT16value by field index,ClassCastExceptionis thrown if schema doesn't match. -
getInt32
Get aSchema.TypeName.INT32value by field index,ClassCastExceptionis thrown if schema doesn't match. -
getFloat
Get aSchema.TypeName.FLOATvalue by field index,ClassCastExceptionis thrown if schema doesn't match. -
getDouble
Get aSchema.TypeName.DOUBLEvalue by field index,ClassCastExceptionis thrown if schema doesn't match. -
getInt64
Get aSchema.TypeName.INT64value by field index,ClassCastExceptionis thrown if schema doesn't match. -
getString
Get aStringvalue by field index,ClassCastExceptionis thrown if schema doesn't match. -
getDateTime
Get aSchema.TypeName.DATETIMEvalue by field index,IllegalStateExceptionis thrown if schema doesn't match. -
getDecimal
Get aBigDecimalvalue by field index,ClassCastExceptionis thrown if schema doesn't match. -
getBoolean
Get aBooleanvalue by field index,ClassCastExceptionis thrown if schema doesn't match. -
getArray
Get an array value by field index,IllegalStateExceptionis thrown if schema doesn't match. -
getIterable
Get an iterable value by field index,IllegalStateExceptionis thrown if schema doesn't match. -
getMap
Get a MAP value by field index,IllegalStateExceptionis thrown if schema doesn't match. -
getLogicalTypeValue
Returns the Logical Type input type for this field.IllegalStateExceptionis 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 aRowvalue by field index,IllegalStateExceptionis thrown if schema doesn't match. -
getSchema
ReturnSchemawhich 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 anIllegalArgumentExceptionif 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 aRowfrom the list of values andgetSchema(). -
nullRow
Creates a new record filled with nulls. -
sorted
Returns an equivalentRowwith fields lexicographically sorted by their name. -
toSnakeCase
Returns an equivalentRowwith `snake_case` field names. -
toCamelCase
Returns an equivalentRowwith `lowerCamelCase` field names.
-