@Experimental public abstract class Row extends java.lang.Object implements java.io.Serializable
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 for each field and the coder for the whole record,
{see @link Schema#getRowCoder()}.
Modifier and Type | Class and Description |
---|---|
static class |
Row.Builder
Builder for
Row . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
<T> java.util.List<T> |
getArray(int idx)
Get an array value by field index,
IllegalStateException is thrown if schema doesn't
match. |
<T> java.util.List<T> |
getArray(java.lang.String fieldName)
Get an array value by field name,
IllegalStateException is thrown if schema doesn't
match. |
boolean |
getBoolean(int idx)
Get a
Boolean value by field index, ClassCastException is thrown if schema
doesn't match. |
boolean |
getBoolean(java.lang.String fieldName)
Get a
Schema.TypeName.BOOLEAN value by field name, IllegalStateException is thrown if
schema doesn't match. |
java.lang.Byte |
getByte(int idx)
Get a
Schema.TypeName.BYTE value by field index, ClassCastException is thrown if
schema doesn't match. |
byte |
getByte(java.lang.String fieldName)
Get a
Schema.TypeName.BYTE value by field name, IllegalStateException is thrown if
schema doesn't match. |
byte[] |
getBytes(int idx)
Get a
Schema.TypeName.BYTES value by field index, ClassCastException is thrown if
schema doesn't match. |
byte[] |
getBytes(java.lang.String fieldName)
Get a
Schema.TypeName.BYTES value by field name, IllegalStateException is thrown if
schema doesn't match. |
ReadableDateTime |
getDateTime(int idx)
Get a
Schema.TypeName.DATETIME value by field index, IllegalStateException is thrown
if schema doesn't match. |
ReadableDateTime |
getDateTime(java.lang.String fieldName)
Get a
Schema.TypeName.DATETIME value by field name, IllegalStateException is thrown if
schema doesn't match. |
java.math.BigDecimal |
getDecimal(int idx)
Get a
BigDecimal value by field index, ClassCastException is thrown if schema
doesn't match. |
java.math.BigDecimal |
getDecimal(java.lang.String fieldName)
Get a
Schema.TypeName.DECIMAL value by field name, IllegalStateException is thrown if
schema doesn't match. |
java.lang.Double |
getDouble(int idx)
Get a
Schema.TypeName.DOUBLE value by field index, ClassCastException is thrown if
schema doesn't match. |
double |
getDouble(java.lang.String fieldName)
Get a
Schema.TypeName.DOUBLE value by field name, IllegalStateException is thrown if
schema doesn't match. |
abstract int |
getFieldCount()
Return the size of data fields.
|
java.lang.Float |
getFloat(int idx)
Get a
Schema.TypeName.FLOAT value by field index, ClassCastException is thrown if
schema doesn't match. |
float |
getFloat(java.lang.String fieldName)
Get a
Schema.TypeName.FLOAT value by field name, IllegalStateException is thrown if
schema doesn't match. |
java.lang.Short |
getInt16(int idx)
Get a
Schema.TypeName.INT16 value by field index, ClassCastException is thrown if
schema doesn't match. |
short |
getInt16(java.lang.String fieldName)
Get a
Schema.TypeName.INT16 value by field name, IllegalStateException is thrown if
schema doesn't match. |
java.lang.Integer |
getInt32(int idx)
Get a
Schema.TypeName.INT32 value by field index, ClassCastException is thrown if
schema doesn't match. |
int |
getInt32(java.lang.String fieldName)
Get a
Schema.TypeName.INT32 value by field name, IllegalStateException is thrown if
schema doesn't match. |
java.lang.Long |
getInt64(int idx)
Get a
Schema.TypeName.INT64 value by field index, ClassCastException is thrown if
schema doesn't match. |
long |
getInt64(java.lang.String fieldName)
Get a
Schema.TypeName.INT64 value by field name, IllegalStateException is thrown if
schema doesn't match. |
<T1,T2> java.util.Map<T1,T2> |
getMap(int idx)
Get a MAP value by field index,
IllegalStateException is thrown if schema doesn't
match. |
<T1,T2> java.util.Map<T1,T2> |
getMap(java.lang.String fieldName)
Get a MAP value by field name,
IllegalStateException is thrown if schema doesn't match. |
Row |
getRow(int idx)
Get a
Row value by field index, IllegalStateException is thrown if schema
doesn't match. |
Row |
getRow(java.lang.String fieldName)
Get a
Schema.TypeName.ROW value by field name, IllegalStateException is thrown if
schema doesn't match. |
Schema |
getSchema()
Return
Schema which describes the fields. |
java.lang.String |
getString(int idx)
Get a
String value by field index, ClassCastException is thrown if schema
doesn't match. |
java.lang.String |
getString(java.lang.String fieldName)
Get a
Schema.TypeName.STRING value by field name, IllegalStateException is thrown if
schema doesn't match. |
abstract <T> T |
getValue(int fieldIdx)
Get value by field index,
ClassCastException is thrown if schema doesn't match. |
<T> T |
getValue(java.lang.String fieldName)
Get value by field name,
ClassCastException is thrown if type doesn't match. |
abstract java.util.List<java.lang.Object> |
getValues()
Return the list of data values.
|
int |
hashCode() |
static Row |
nullRow(Schema schema)
Creates a new record filled with nulls.
|
static <T> java.util.stream.Collector<T,java.util.List<java.lang.Object>,Row> |
toRow(Schema schema)
Creates a
Row from the list of values and getSchema() . |
java.lang.String |
toString() |
static Row.Builder |
withSchema(Schema schema)
Creates a record builder with specified
getSchema() . |
@Nullable public abstract <T> T getValue(int fieldIdx)
ClassCastException
is thrown if schema doesn't match.public abstract int getFieldCount()
public abstract java.util.List<java.lang.Object> getValues()
public <T> T getValue(java.lang.String fieldName)
ClassCastException
is thrown if type doesn't match.public byte getByte(java.lang.String fieldName)
Schema.TypeName.BYTE
value by field name, IllegalStateException
is thrown if
schema doesn't match.public byte[] getBytes(java.lang.String fieldName)
Schema.TypeName.BYTES
value by field name, IllegalStateException
is thrown if
schema doesn't match.public short getInt16(java.lang.String fieldName)
Schema.TypeName.INT16
value by field name, IllegalStateException
is thrown if
schema doesn't match.public int getInt32(java.lang.String fieldName)
Schema.TypeName.INT32
value by field name, IllegalStateException
is thrown if
schema doesn't match.public long getInt64(java.lang.String fieldName)
Schema.TypeName.INT64
value by field name, IllegalStateException
is thrown if
schema doesn't match.public java.math.BigDecimal getDecimal(java.lang.String fieldName)
Schema.TypeName.DECIMAL
value by field name, IllegalStateException
is thrown if
schema doesn't match.public float getFloat(java.lang.String fieldName)
Schema.TypeName.FLOAT
value by field name, IllegalStateException
is thrown if
schema doesn't match.public double getDouble(java.lang.String fieldName)
Schema.TypeName.DOUBLE
value by field name, IllegalStateException
is thrown if
schema doesn't match.public java.lang.String getString(java.lang.String fieldName)
Schema.TypeName.STRING
value by field name, IllegalStateException
is thrown if
schema doesn't match.public ReadableDateTime getDateTime(java.lang.String fieldName)
Schema.TypeName.DATETIME
value by field name, IllegalStateException
is thrown if
schema doesn't match.public boolean getBoolean(java.lang.String fieldName)
Schema.TypeName.BOOLEAN
value by field name, IllegalStateException
is thrown if
schema doesn't match.public <T> java.util.List<T> getArray(java.lang.String fieldName)
IllegalStateException
is thrown if schema doesn't
match.public <T1,T2> java.util.Map<T1,T2> getMap(java.lang.String fieldName)
IllegalStateException
is thrown if schema doesn't match.public Row getRow(java.lang.String fieldName)
Schema.TypeName.ROW
value by field name, IllegalStateException
is thrown if
schema doesn't match.public java.lang.Byte getByte(int idx)
Schema.TypeName.BYTE
value by field index, ClassCastException
is thrown if
schema doesn't match.public byte[] getBytes(int idx)
Schema.TypeName.BYTES
value by field index, ClassCastException
is thrown if
schema doesn't match.public java.lang.Short getInt16(int idx)
Schema.TypeName.INT16
value by field index, ClassCastException
is thrown if
schema doesn't match.public java.lang.Integer getInt32(int idx)
Schema.TypeName.INT32
value by field index, ClassCastException
is thrown if
schema doesn't match.public java.lang.Float getFloat(int idx)
Schema.TypeName.FLOAT
value by field index, ClassCastException
is thrown if
schema doesn't match.public java.lang.Double getDouble(int idx)
Schema.TypeName.DOUBLE
value by field index, ClassCastException
is thrown if
schema doesn't match.public java.lang.Long getInt64(int idx)
Schema.TypeName.INT64
value by field index, ClassCastException
is thrown if
schema doesn't match.public java.lang.String getString(int idx)
String
value by field index, ClassCastException
is thrown if schema
doesn't match.public ReadableDateTime getDateTime(int idx)
Schema.TypeName.DATETIME
value by field index, IllegalStateException
is thrown
if schema doesn't match.public java.math.BigDecimal getDecimal(int idx)
BigDecimal
value by field index, ClassCastException
is thrown if schema
doesn't match.public boolean getBoolean(int idx)
Boolean
value by field index, ClassCastException
is thrown if schema
doesn't match.public <T> java.util.List<T> getArray(int idx)
IllegalStateException
is thrown if schema doesn't
match.public <T1,T2> java.util.Map<T1,T2> getMap(int idx)
IllegalStateException
is thrown if schema doesn't
match.public Row getRow(int idx)
Row
value by field index, IllegalStateException
is thrown if schema
doesn't match.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static Row.Builder withSchema(Schema schema)
getSchema()
. Row.Builder.build()
will
throw an IllegalArgumentException
if number of fields in getSchema()
does not
match the number of fields specified.public static <T> java.util.stream.Collector<T,java.util.List<java.lang.Object>,Row> toRow(Schema schema)
Row
from the list of values and getSchema()
.