ChengJie1053 commented on code in PR #3456:
URL: https://github.com/apache/flink-cdc/pull/3456#discussion_r1675565812


##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/source/reader/MySqlRecordEmitter.java:
##########
@@ -120,7 +123,31 @@ private void emitElement(SourceRecord element, 
SourceOutput<T> output) throws Ex
         debeziumDeserializationSchema.deserialize(element, outputCollector);
     }
 
-    private void reportMetrics(SourceRecord element) {
+    private void reportMetrics(SourceRecord element, MySqlSplitState 
splitState) {
+        TableId tableId = RecordUtils.getTableId(element);
+        if (splitState.isSnapshotSplitState()) {
+            sourceReaderMetrics.numRecordsOutSnapshotIncrease(tableId);
+        } else if (splitState.isBinlogSplitState()) {
+            if (RecordUtils.isDataChangeRecord(element)) {
+                Struct value = (Struct) element.value();
+                if (value != null) {
+                    Envelope.Operation operation =
+                            Envelope.Operation.forCode(
+                                    
value.getString(Envelope.FieldName.OPERATION));
+                    switch (operation) {
+                        case CREATE:
+                            
sourceReaderMetrics.numRecordsOutInsertIncrease(tableId);
+                            break;
+                        case UPDATE:
+                            
sourceReaderMetrics.numRecordsOutUpdateIncrease(tableId);
+                            break;
+                        case DELETE:
+                            
sourceReaderMetrics.numRecordsOutDeleteIncrease(tableId);
+                            break;
+                    }
+                }
+            }

Review Comment:
   Thank you very much for helping me review the code.
   I will delete the isDataChangeRecord judgment
   



-- 
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]

Reply via email to