Open kbr- opened 3 years ago
Also until https://github.com/scylladb/scylla/issues/7825 is fixed, always bind :removed
in the above example (can bind to empty set if no elements got removed)
In general, I think that a batch of 2 can solve every case:
for cdc$operation = 1
(update):
update
for adding and removing elements from non-frozen collections and setting non-frozen UDT fields; also ensure to use scylla_timeuuid_list_index
for non-frozen lists, ALWAYS!update
for everything else: setting other fields, and setting non-frozen collections to null
if cdc$deleted_X
is True
for cdc$operation = 2
(insert):
update
for setting non-frozen list elements using scylla_timeuuid_list_index
insert
for everything else: creating the row marker, replacing non-frozen collections (including lists: we then combine setting to null
with the above update
to obtain the new list), replacing all other types of fields
https://github.com/scylladb/scylla-cdc-java/blob/24265007f5ab1fdfccefeea4fa6516ffc55d8666/scylla-cdc-replicator/src/main/java/com/scylladb/cdc/replicator/ReplicatorConsumer.java#L71-L83
We can always use prepared statements. Sometimes we may need to use a batch statement, but still. Example prepared statement that can handle any non-frozen map update:
bind the markers as needed:
:added
from the CDCv
column,:removed
fromcdc$deleted_elements_v
,:replaced
fromcdc$deleted_v
(bindnull
if it got deleted, leave unset otherwise).