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 asTransforms ainvalid reference
Jsonb/ Jsonbrepresenting a change stream result into aListofChangeStreamRecordmodel. 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/ Jsonbreceived, the originating partition of the records (given by thePartitionMetadataparameter) and the stream metadata (given by theChangeStreamResultSetMetadata) are used to populate theChangeStreamRecordMetadatafor each record mapped.The
/ Jsonbis expected to have the following fields:DATA_CHANGE_RECORD_COLUMN: non-nullableStructlist of data change records or arepresenting a child partition record.invalid reference
JsonbCOMMIT_TIMESTAMP_COLUMN: non-nullableTimestamprepresenting the timestamp at which the modifications within the record were committed in Cloud Spanner.SERVER_TRANSACTION_ID_COLUMN: non-nullableStringrepresenting the unique transaction id in which the modifications for this record occurred.IS_LAST_RECORD_IN_TRANSACTION_IN_PARTITION_COLUMN: non-nullableBooleanindicating whether this record is the last emitted for the transaction.RECORD_SEQUENCE_COLUMN: non-nullableStringrepresenting the order in which this record appears within the context of a partition, commit timestamp and transaction.TABLE_NAME_COLUMN: non-nullableStringrepresenting the name of the table in which the modifications for this record occurred.COLUMN_TYPES_COLUMN: non-nullableListofStructs representing the type of the primary keys and modified columns within this record.NAME_COLUMN: non-nullableStringrepresenting the name of a column.TYPE_COLUMN: non-nullableStringrepresenting the type of a column.IS_PRIMARY_KEY_COLUMN: non-nullableBooleanindicating if the column is part of the primary key.ORDINAL_POSITION_COLUMN: non-nullableLongrepresenting the position of the column in the table it is defined.
MODS_COLUMN: non-nullableListofStructs representing the data modifications within this record.KEYS_COLUMN: non-nullableStringjson object, where keys are the primary key column names, and the values are their corresponding values.OLD_VALUES_COLUMN: nullableStringjson 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: nullableStringjson 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-nullableStringrepresenting the type of operation that caused the modifications (see alsoModType.VALUE_CAPTURE_TYPE_COLUMN: non-nullableStringrepresenting the capture type of the change stream that generated this record (see alsoValueCaptureType).NUMBER_OF_RECORDS_IN_TRANSACTION_COLUMN: non-nullableLongrepresenting the total number of data change records for the transaction in which this record occurred.NUMBER_OF_PARTITIONS_IN_TRANSACTION_COLUMN: non-nullableLongrepresenting the total number of partitions for the transaction in which this record occurred.
HEARTBEAT_RECORD_COLUMN: non-nullableStructlist of hearbeat records or arepresenting a child partition record.invalid reference
JsonbTIMESTAMP_COLUMN: non-nullableTimestamprepresenting the timestamp for which the change stream query has returned all changes (see more inHeartbeatRecord.getTimestamp().
CHILD_PARTITIONS_RECORD_COLUMN: non-nullableStructlist of child partitions records or arepresenting a child partition record.invalid reference
JsonbSTART_TIMESTAMP_COLUMN: non-nullableTimestamprepresenting the timestamp at which the new partition started being valid in Cloud Spanner.RECORD_SEQUENCE_COLUMN: non-nullableStringrepresenting the order in which this record appears within the context of a partition and commit timestamp.CHILD_PARTITIONS_COLUMN: non-nullableListofStructrepresenting 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
ListofChangeStreamRecordsubclasses
-