lvyanquan commented on code in PR #3904: URL: https://github.com/apache/flink-cdc/pull/3904#discussion_r2043286226
########## flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-iceberg/src/main/java/org/apache/flink/cdc/connectors/iceberg/sink/v2/WriteResultWrapper.java: ########## @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.cdc.connectors.iceberg.sink.v2; + +import org.apache.flink.cdc.common.event.TableId; + +import org.apache.iceberg.DataFile; +import org.apache.iceberg.DeleteFile; +import org.apache.iceberg.io.WriteResult; + +import java.io.Serializable; + +/** A wrapper class for {@link WriteResult} and {@link TableId}. */ +public class WriteResultWrapper implements Serializable { + + private final WriteResult writeResult; + + private final TableId tableId; + + public WriteResultWrapper(WriteResult writeResult, TableId tableId) { + this.writeResult = writeResult; + this.tableId = tableId; + } + + public WriteResult getWriteResult() { + return writeResult; + } + + public TableId getTableId() { + return tableId; + } + + /** Build a simple description for the write result. */ + public String buildDescription() { + long addCount = 0; + if (writeResult.dataFiles() != null) { + for (DataFile dataFile : writeResult.dataFiles()) { + addCount += dataFile.recordCount(); + } + } + long deleteCount = 0; + if (writeResult.deleteFiles() != null) { + for (DeleteFile dataFile : writeResult.deleteFiles()) { + deleteCount += dataFile.recordCount(); + } + } Review Comment: I don't think it's meaningful to record how many files have been added in the metrics because it's not suitable for monitoring job performance. I think printing out the logs is enough. Considering the presence of compaction, simply counting the total number of files added/deleted is not reliable. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org