yifan-c commented on code in PR #241:
URL:
https://github.com/apache/cassandra-analytics/pull/241#discussion_r4203923846
##########
cassandra-four-zero-bridge/src/main/java/org/apache/cassandra/db/commitlog/BufferingCommitLogReader.java:
##########
@@ -604,6 +617,45 @@ private void readMutationInternal(byte[] inputBuffer,
this.handleMutation(mutation, size, mutationPosition, desc);
}
+ /**
+ * Best-effort check for whether a mutation that failed to deserialize is
guaranteed not to involve any
+ * CDC-enabled table, so the failure can be safely ignored.
+ * Only reads the first {@link TableId} to make the decision, as mutations
contain single partition update in most cases.
+ * If a mutation has more than one partition update, it conservatively
assumes a CDC-enabled table is involved.
+ *
+ * @param inputBuffer raw byte array w/Mutation data
+ * @param size serialized size of the mutation
+ * @return false if the first table touched by the mutation is confirmed
CDC-enabled, or the mutation has more
+ * than one {@link PartitionUpdate} (so the rest can't be safely
checked); true otherwise, including
+ * when the table's metadata can't be found, or even the first
{@link TableId} can't be read
+ */
+ @VisibleForTesting
+ static boolean failedMutationHasNoCdcTable(byte[] inputBuffer, int size)
+ {
+ try (DataInputBuffer in = new DataInputBuffer(inputBuffer, 0, size))
+ {
+ int updateCount = (int) in.readUnsignedVInt();
+ TableId tableId = TableId.deserialize(in);
+ TableMetadata metadata = Schema.instance.getTableMetadata(tableId);
+ if (metadata != null && metadata.params.cdc)
+ {
+ return false;
+ }
+
+ if (updateCount > 1)
Review Comment:
It sounds good.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]