You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/02/01 23:33:17 UTC

[GitHub] [iceberg] izchen commented on a change in pull request #4020: Spark 3.0: Reports bytesWritten and recordsWritten to metrics

izchen commented on a change in pull request #4020:
URL: https://github.com/apache/iceberg/pull/4020#discussion_r797146504



##########
File path: spark/v3.0/spark/src/main/java/org/apache/iceberg/spark/source/SparkWrite.java
##########
@@ -492,9 +495,26 @@ public void doCommit(long epochId, WriterCommitMessage[] messages) {
 
   public static class TaskCommit implements WriterCommitMessage {
     private final DataFile[] taskFiles;
+    private long bytesWritten = 0L;
+    private long recordsWritten = 0L;
 
     TaskCommit(DataFile[] taskFiles) {
       this.taskFiles = taskFiles;
+      for (DataFile dataFile : taskFiles) {
+        this.bytesWritten += dataFile.fileSizeInBytes();
+        this.recordsWritten += dataFile.recordCount();
+      }

Review comment:
       done

##########
File path: spark/v3.0/spark/src/main/java/org/apache/iceberg/spark/source/SparkWrite.java
##########
@@ -492,9 +495,26 @@ public void doCommit(long epochId, WriterCommitMessage[] messages) {
 
   public static class TaskCommit implements WriterCommitMessage {
     private final DataFile[] taskFiles;
+    private long bytesWritten = 0L;
+    private long recordsWritten = 0L;
 
     TaskCommit(DataFile[] taskFiles) {
       this.taskFiles = taskFiles;
+      for (DataFile dataFile : taskFiles) {
+        this.bytesWritten += dataFile.fileSizeInBytes();
+        this.recordsWritten += dataFile.recordCount();
+      }
+    }
+
+    // Reports bytesWritten and recordsWritten to the Spark output metrics.
+    // Can only be called in executor.
+    void reportsToOutputMetrics() {

Review comment:
       done




-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org