Class GenericRecordData
- java.lang.Object
-
- org.apache.flink.cdc.common.data.GenericRecordData
-
- All Implemented Interfaces:
RecordData
@PublicEvolving public final class GenericRecordData extends Object implements RecordData
An internal data structure representing data ofRecordData.GenericRecordDatais a generic implementation ofRecordDatawhich is backed by an array of JavaObject. AGenericRecordDatacan have an arbitrary number of fields of different types. The fields in a row can be accessed by position (0-based) using either the genericgetField(int)or type-specific getters (such asgetInt(int)). A field can be updated by the genericsetField(int, Object).Note: All fields of this data structure must be internal data structures. See
RecordDatafor more information about internal data structures.The fields in
GenericRecordDatacan be null for representing nullability.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.cdc.common.data.RecordData
RecordData.FieldGetter
-
-
Constructor Summary
Constructors Constructor Description GenericRecordData(int arity)Creates an instance ofGenericRecordDatawith given number of fields.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)intgetArity()Returns the number of fields in this record.ArrayDatagetArray(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.DateDatagetDate(int pos)Returns the Date data at the given position.DecimalDatagetDecimal(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.ObjectgetField(int pos)Returns the field 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.LocalZonedTimestampDatagetLocalZonedTimestampData(int pos, int precision)Returns the local zoned timestamp value at the given position.longgetLong(int pos)Returns the long value at the given position.MapDatagetMap(int pos)Returns the map value at the given position.RecordDatagetRow(int pos, int numFields)Returns the row value at the given position.shortgetShort(int pos)Returns the short value at the given position.StringDatagetString(int pos)Returns the string value at the given position.TimeDatagetTime(int pos)Returns the Time data at the given position.TimestampDatagetTimestamp(int pos, int precision)Returns the timestamp value at the given position.VariantgetVariant(int pos)Returns the variant value at the given position.ZonedTimestampDatagetZonedTimestamp(int pos, int precision)Returns the zoned timestamp value at the given position.inthashCode()booleanisNullAt(int pos)Returns true if the field is null at the given position.static GenericRecordDataof(Object... values)Creates an instance ofGenericRecordDatawith given field values.voidsetField(int pos, Object value)Sets the field value at the given position.StringtoString()
-
-
-
Constructor Detail
-
GenericRecordData
public GenericRecordData(int arity)
Creates an instance ofGenericRecordDatawith given number of fields.Initially, all fields are set to null.
Note: All fields of the row must be internal data structures.
- Parameters:
arity- number of fields
-
-
Method Detail
-
setField
public void setField(int pos, Object value)Sets the field value at the given position.Note: The given field value must be an internal data structures. Otherwise the
GenericRecordDatais corrupted and may throw exception when processing. SeeRecordDatafor more information about internal data structures.The field value can be null for representing nullability.
-
getField
public Object getField(int pos)
Returns the field value at the given position.Note: The returned value is in internal data structure. See
RecordDatafor more information about internal data structures.The returned field value can be null for representing nullability.
-
getArity
public int getArity()
Description copied from interface:RecordDataReturns the number of fields in this record.- Specified by:
getArityin interfaceRecordData
-
isNullAt
public boolean isNullAt(int pos)
Description copied from interface:RecordDataReturns true if the field is null at the given position.- Specified by:
isNullAtin interfaceRecordData
-
getBoolean
public boolean getBoolean(int pos)
Description copied from interface:RecordDataReturns the boolean value at the given position.- Specified by:
getBooleanin interfaceRecordData
-
getByte
public byte getByte(int pos)
Description copied from interface:RecordDataReturns the byte value at the given position.- Specified by:
getBytein interfaceRecordData
-
getShort
public short getShort(int pos)
Description copied from interface:RecordDataReturns the short value at the given position.- Specified by:
getShortin interfaceRecordData
-
getInt
public int getInt(int pos)
Description copied from interface:RecordDataReturns the integer value at the given position.- Specified by:
getIntin interfaceRecordData
-
getLong
public long getLong(int pos)
Description copied from interface:RecordDataReturns the long value at the given position.- Specified by:
getLongin interfaceRecordData
-
getFloat
public float getFloat(int pos)
Description copied from interface:RecordDataReturns the float value at the given position.- Specified by:
getFloatin interfaceRecordData
-
getDouble
public double getDouble(int pos)
Description copied from interface:RecordDataReturns the double value at the given position.- Specified by:
getDoublein interfaceRecordData
-
getString
public StringData getString(int pos)
Description copied from interface:RecordDataReturns the string value at the given position.- Specified by:
getStringin interfaceRecordData
-
getDecimal
public DecimalData getDecimal(int pos, int precision, int scale)
Description copied from interface:RecordDataReturns 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).- Specified by:
getDecimalin interfaceRecordData
-
getTimestamp
public TimestampData getTimestamp(int pos, int precision)
Description copied from interface:RecordDataReturns 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).- Specified by:
getTimestampin interfaceRecordData
-
getZonedTimestamp
public ZonedTimestampData getZonedTimestamp(int pos, int precision)
Description copied from interface:RecordDataReturns the zoned timestamp value at the given position.The precision is required to determine whether the zoned timestamp value was stored in a compact representation (see
ZonedTimestampData).- Specified by:
getZonedTimestampin interfaceRecordData
-
getLocalZonedTimestampData
public LocalZonedTimestampData getLocalZonedTimestampData(int pos, int precision)
Description copied from interface:RecordDataReturns the local zoned timestamp value at the given position.The precision is required to determine whether the local zoned timestamp value was stored in a compact representation (see
LocalZonedTimestampData).- Specified by:
getLocalZonedTimestampDatain interfaceRecordData
-
getBinary
public byte[] getBinary(int pos)
Description copied from interface:RecordDataReturns the binary value at the given position.- Specified by:
getBinaryin interfaceRecordData
-
getArray
public ArrayData getArray(int pos)
Description copied from interface:RecordDataReturns the array value at the given position.- Specified by:
getArrayin interfaceRecordData
-
getMap
public MapData getMap(int pos)
Description copied from interface:RecordDataReturns the map value at the given position.- Specified by:
getMapin interfaceRecordData
-
getRow
public RecordData getRow(int pos, int numFields)
Description copied from interface:RecordDataReturns the row value at the given position.The number of fields is required to correctly extract the record.
- Specified by:
getRowin interfaceRecordData
-
getDate
public DateData getDate(int pos)
Description copied from interface:RecordDataReturns the Date data at the given position.- Specified by:
getDatein interfaceRecordData
-
getTime
public TimeData getTime(int pos)
Description copied from interface:RecordDataReturns the Time data at the given position.- Specified by:
getTimein interfaceRecordData
-
getVariant
public Variant getVariant(int pos)
Description copied from interface:RecordDataReturns the variant value at the given position.- Specified by:
getVariantin interfaceRecordData
-
of
public static GenericRecordData of(Object... values)
Creates an instance ofGenericRecordDatawith given field values.Note: All fields of the row must be internal data structures.
-
-