@EvolvingApi public interface ChangeRecord
Each event has a key, identifying the affected record, and a value, describing the change to that record.
Most events have an operation which specifies the type of change (insert, delete or update). Events without an operation have specialized usage, for example heartbeats, and aren't supposed to affect the data model. You can observe and act upon them in a Jet CDC sink, but we discourage such usage.
All events have a timestamp specifying the moment when the change
event occurred in the database. Normally this is the timestamp recorded in
the database's change log, but since it has a finite size, the change stream
begins with virtual events that reproduce the state of the table at the start
of the change log. These events have an artificial timestamp. In principle,
it should be easy to identify them because they have a separate SYNC
operation instead of INSERT
, however some databases emit INSERT
events in both cases (a notable example is MySQL).
All events have a source-specific sequence which can be used to ensure their ordering. The sequence consists of two parts: a monotonically increasing numeric value and a source descriptor, which provides the scope of validity of the numeric value. This is needed because many CDC sources don't provide a globally valid sequence. For example, the sequence may be the offset in a write-ahead log. Then it makes sense to compare them only if they come from the same log file.
Modifier and Type | Method and Description |
---|---|
String |
database()
Returns the name of the database containing the record's table.
|
RecordPart |
key()
Returns the key part of the CDC event.
|
RecordPart |
newValue()
Returns the new value of the record.
|
RecordPart |
oldValue()
Returns the old value of the record.
|
Operation |
operation()
Returns the type of change this record describes (insert, delete or
update).
|
String |
schema()
Returns the name of the schema containing the record's table.
|
long |
sequenceSource()
Specifies the source descriptor of the record's sequence.
|
long |
sequenceValue()
Specifies the numeric value part of the record's source sequence.
|
String |
table()
Returns the name of the table this record is part of.
|
long |
timestamp()
Specifies the moment when the change event occurred in the database.
|
String |
toJson()
Returns the raw JSON string from the CDC event underlying this
ChangeRecord . |
RecordPart |
value()
Returns the value part of the CDC event.
|
long timestamp()
SYNC
operation instead of INSERT
, however some databases emit INSERT
events in both cases (a notable example is MySQL).long sequenceValue()
long sequenceSource()
@Nonnull Operation operation()
Operation.UNSPECIFIED
if this ChangeRecord
doesn't have an operation field, otherwise the appropriate Operation
that matches the CDC record's operation field@Nonnull String database()
@Nonnull String schema() throws UnsupportedOperationException
UnsupportedOperationException
@Nonnull String table()
@Nonnull RecordPart key()
@Nonnull RecordPart value()
For sync, insert and update operations the value describes the database record as it looks AFTER the event, so the latest image.
For delete operations the value describes the database record as it looked BEFORE the event, so the previous image.
@Nullable RecordPart newValue()
@Nullable RecordPart oldValue()
Copyright © 2024 Hazelcast, Inc.. All rights reserved.