Class ChangeStreamRecordMapper
java.lang.Object
org.apache.beam.sdk.io.gcp.spanner.changestreams.mapper.ChangeStreamRecordMapper
This class is responsible for transforming a
Struct
to a List
of ChangeStreamRecord
models.
The change stream full specification can be seen in the internal documentation https://docs.google.com/document/d/1nLlMGvQLIeUSDNmtoLT9vaQo0hVGl4CIf6iCSOkdIbA/edit#bookmark=id.fxgtygh8eony
-
Method Summary
Modifier and TypeMethodDescriptiontoChangeStreamRecords
(PartitionMetadata partition, ChangeStreamResultSet resultSet, ChangeStreamResultSetMetadata resultSetMetadata) In GoogleSQL, change stream records are returned as an array ofStruct
.
-
Method Details
-
toChangeStreamRecords
public List<ChangeStreamRecord> toChangeStreamRecords(PartitionMetadata partition, ChangeStreamResultSet resultSet, ChangeStreamResultSetMetadata resultSetMetadata) In GoogleSQL, change stream records are returned as an array ofStruct
. In PostgresQL, change stream records are returned asinvalid reference
Jsonb
/ Jsonb
representing a change stream result into aList
ofChangeStreamRecord
model. The type of the change stream record will be identified and one of the following subclasses can be returned within the resultingList
: Additionally to the/ Jsonb
received, the originating partition of the records (given by thePartitionMetadata
parameter) and the stream metadata (given by theChangeStreamResultSetMetadata
) are used to populate theChangeStreamRecordMetadata
for each record mapped.The
/ Jsonb
is expected to have the following fields:DATA_CHANGE_RECORD_COLUMN
: non-nullableStruct
list of data change records or ainvalid reference
Jsonb
COMMIT_TIMESTAMP_COLUMN
: non-nullableTimestamp
representing the timestamp at which the modifications within the record were committed in Cloud Spanner.SERVER_TRANSACTION_ID_COLUMN
: non-nullableString
representing the unique transaction id in which the modifications for this record occurred.IS_LAST_RECORD_IN_TRANSACTION_IN_PARTITION_COLUMN
: non-nullableBoolean
indicating whether this record is the last emitted for the transaction.RECORD_SEQUENCE_COLUMN
: non-nullableString
representing the order in which this record appears within the context of a partition, commit timestamp and transaction.TABLE_NAME_COLUMN
: non-nullableString
representing the name of the table in which the modifications for this record occurred.COLUMN_TYPES_COLUMN
: non-nullableList
ofStruct
s representing the type of the primary keys and modified columns within this record.NAME_COLUMN
: non-nullableString
representing the name of a column.TYPE_COLUMN
: non-nullableString
representing the type of a column.IS_PRIMARY_KEY_COLUMN
: non-nullableBoolean
indicating if the column is part of the primary key.ORDINAL_POSITION_COLUMN
: non-nullableLong
representing the position of the column in the table it is defined.
MODS_COLUMN
: non-nullableList
ofStruct
s representing the data modifications within this record.KEYS_COLUMN
: non-nullableString
json object, where keys are the primary key column names, and the values are their corresponding values.OLD_VALUES_COLUMN
: nullableString
json object displaying the old state of the columns modified, where keys are the column names, and the values are their corresponding values.NEW_VALUES_COLUMN
: nullableString
json object displaying the new state of the columns modified, where keys are the column names, and the values are their corresponding values.
MOD_TYPE_COLUMN
: non-nullableString
representing the type of operation that caused the modifications (see alsoModType
.VALUE_CAPTURE_TYPE_COLUMN
: non-nullableString
representing the capture type of the change stream that generated this record (see alsoValueCaptureType
).NUMBER_OF_RECORDS_IN_TRANSACTION_COLUMN
: non-nullableLong
representing the total number of data change records for the transaction in which this record occurred.NUMBER_OF_PARTITIONS_IN_TRANSACTION_COLUMN
: non-nullableLong
representing the total number of partitions for the transaction in which this record occurred.
HEARTBEAT_RECORD_COLUMN
: non-nullableStruct
list of hearbeat records or ainvalid reference
Jsonb
TIMESTAMP_COLUMN
: non-nullableTimestamp
representing the timestamp for which the change stream query has returned all changes (see more inHeartbeatRecord.getTimestamp()
.
CHILD_PARTITIONS_RECORD_COLUMN
: non-nullableStruct
list of child partitions records or ainvalid reference
Jsonb
START_TIMESTAMP_COLUMN
: non-nullableTimestamp
representing the timestamp at which the new partition started being valid in Cloud Spanner.RECORD_SEQUENCE_COLUMN
: non-nullableString
representing the order in which this record appears within the context of a partition and commit timestamp.CHILD_PARTITIONS_COLUMN
: non-nullableList
ofStruct
representing the new child partitions.
- Parameters:
partition
- the partition metadata from which the row was generatedresultSet
- the change stream result setresultSetMetadata
- the metadata generated when reading the change stream row- Returns:
- a
List
ofChangeStreamRecord
subclasses
-