Class RowMutationInformation
- java.lang.Object
-
- org.apache.beam.sdk.io.gcp.bigquery.RowMutationInformation
-
public abstract class RowMutationInformation extends java.lang.ObjectThis class indicates how to apply a row update to BigQuery. A sequence number must always be supplied to order the updates. Incorrect sequence numbers will result in unexpected state in the BigQuery table.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRowMutationInformation.MutationType
-
Constructor Summary
Constructors Constructor Description RowMutationInformation()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract java.lang.StringgetChangeSequenceNumber()The value supplied to the BigQuery_CHANGE_SEQUENCE_NUMBERpseudo-column.abstract RowMutationInformation.MutationTypegetMutationType()abstract @Nullable java.lang.LonggetSequenceNumber()Deprecated.static RowMutationInformationof(RowMutationInformation.MutationType mutationType, long sequenceNumber)Deprecated.static RowMutationInformationof(RowMutationInformation.MutationType mutationType, java.lang.String changeSequenceNumber)InstantiateRowMutationInformationwithRowMutationInformation.MutationTypeand the {@param changeSequenceNumber}, which sets the BigQuery API_CHANGE_SEQUENCE_NUMBERpseudo column, enabling custom user-supplied ordering ofRowMutations.
-
-
-
Method Detail
-
getMutationType
public abstract RowMutationInformation.MutationType getMutationType()
-
getSequenceNumber
@Deprecated public abstract @Nullable java.lang.Long getSequenceNumber()
Deprecated.The sequence number used to drive the order of applied row mutations. @deprecatedgetChangeSequenceNumber()replaces this field as the BigQuery API instead supports the use of a string.
-
getChangeSequenceNumber
public abstract java.lang.String getChangeSequenceNumber()
The value supplied to the BigQuery_CHANGE_SEQUENCE_NUMBERpseudo-column. Seeof(MutationType, String)for more details.
-
of
@Deprecated public static RowMutationInformation of(RowMutationInformation.MutationType mutationType, long sequenceNumber)
Deprecated.InstantiateRowMutationInformationwithRowMutationInformation.MutationTypeand the {@param sequenceNumber}. @deprecated - instantiatesRowMutationInformationviaof(MutationType, String)forwarding the {@param sequenceNumber} value usingLong.toHexString(long). {@param sequenceNumber} values< 0will throw an error.
-
of
public static RowMutationInformation of(RowMutationInformation.MutationType mutationType, java.lang.String changeSequenceNumber)
InstantiateRowMutationInformationwithRowMutationInformation.MutationTypeand the {@param changeSequenceNumber}, which sets the BigQuery API_CHANGE_SEQUENCE_NUMBERpseudo column, enabling custom user-supplied ordering ofRowMutations.Requirements for the {@param changeSequenceNumber}:
- fixed format
Stringin hexadecimal format - do not use hexadecimals encoded from negative numbers
- each hexadecimal string separated into sections by forward slash:
/ - up to four sections allowed
- each section is limited to
16hexadecimal characters:0-9,A-F, ora-f - The allowable range supported are values between
0/0/0/0andFFFFFFFFFFFFFFFF/FFFFFFFFFFFFFFFF/FFFFFFFFFFFFFFFF/FFFFFFFFFFFFFFFF
Below are some {@param changeSequenceNumber} scenarios:
Record #1: {@param changeSequenceNumber} Record #2: {@param changeSequenceNumber} BigQuery API compares as "B""ABC"Record #2 is considered the latest record: 'ABC' > 'B' (i.e. '2748' > '11')"FFF/B""FFF/ABC"Record #2 is considered the latest record: "FFF/B" > "FFF/ABC" (i.e. "4095/2748" > "4095/11")"BA/FFFFFFFF""ABC"Record #2 is considered the latest record: "ABC" > "BA/FFFFFFFF" (i.e. "2748" > "186/4294967295")"FFF/ABC""ABC"Record #1 is considered the latest record: "FFF/ABC" > "ABC" (i.e. "4095/2748" > "2748")"FFF""FFF"Record #1 and #2 change sequence number identical; BigQuery uses system ingestion time to take precedence over previously ingested records. Below are some code examples.
RowMutationInformation.of(UPSERT, "FFF/ABC")- Using Apache Commons
Hex.encodeHexString(byte[])(Java 17+ users can useHexFormat)RowMutationInformation.of(UPSERT, Hex.encodeHexString("2024-04-30 11:19:44 UTC".getBytes(StandardCharsets.UTF_8))) - Using
Long.toHexString(long):RowMutationInformation.of(DELETE, Long.toHexString(123L))
- fixed format
-
-