n3nash commented on a change in pull request #2300:
URL: https://github.com/apache/hudi/pull/2300#discussion_r549059039



##########
File path: 
hudi-common/src/main/java/org/apache/hudi/common/model/HoodieDeltaWriteStat.java
##########
@@ -44,4 +49,24 @@ public void setLogOffset(long logOffset) {
   public long getLogOffset() {
     return logOffset;
   }
+
+  public void setBaseFile(String baseFile) {
+    this.baseFile = baseFile;
+  }
+
+  public String getBaseFile() {
+    return baseFile;
+  }
+
+  public void setLogFiles(List<String> logFiles) {
+    this.logFiles = logFiles;
+  }
+
+  public void appendLogFiles(String logFile) {

Review comment:
       Nit: addLogFile or appendLogFile

##########
File path: 
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/HoodieAppendHandle.java
##########
@@ -203,31 +213,136 @@ private void init(HoodieRecord record) {
     return Option.empty();
   }
 
+  private void initNewStatus() {

Review comment:
       High level question - it looks like you are passing the information from 
the previous WriteStatus and HoodieWriteStat for one log file to the new one if 
rolled over, what is the need to return list of write statuses ?

##########
File path: 
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/HoodieAppendHandle.java
##########
@@ -203,31 +213,136 @@ private void init(HoodieRecord record) {
     return Option.empty();
   }
 
+  private void initNewStatus() {
+    HoodieDeltaWriteStat prevStat = (HoodieDeltaWriteStat) 
this.writeStatus.getStat();
+    // Make a new write status and copy basic fields over.
+    HoodieDeltaWriteStat stat = new HoodieDeltaWriteStat();
+    stat.setFileId(fileId);
+    stat.setPartitionPath(partitionPath);
+    stat.setPrevCommit(prevStat.getPrevCommit());
+    stat.setBaseFile(prevStat.getBaseFile());
+    stat.setLogFiles(new ArrayList<>(prevStat.getLogFiles()));
+
+    this.writeStatus = (WriteStatus) 
ReflectionUtils.loadClass(config.getWriteStatusClassName(),
+        !hoodieTable.getIndex().isImplicitWithStorage(), 
config.getWriteStatusFailureFraction());
+    this.writeStatus.setFileId(fileId);
+    this.writeStatus.setPartitionPath(partitionPath);
+    this.writeStatus.setStat(stat);
+  }
+
+  private String makeFilePath(HoodieLogFile logFile) {
+    return partitionPath.length() == 0
+        ? new Path(logFile.getFileName()).toString()
+        : new Path(partitionPath, logFile.getFileName()).toString();
+  }
+
+  private void resetWriteCounts() {
+    recordsWritten = 0;
+    updatedRecordsWritten = 0;
+    insertRecordsWritten = 0;
+    recordsDeleted = 0;
+  }
+
+  private void updateWriteCounts(HoodieDeltaWriteStat stat, AppendResult 
result) {
+    stat.setNumWrites(recordsWritten);
+    stat.setNumUpdateWrites(updatedRecordsWritten);
+    stat.setNumInserts(insertRecordsWritten);
+    stat.setNumDeletes(recordsDeleted);
+    stat.setTotalWriteBytes(result.size());
+  }
+
+  private void accumulateWriteCounts(HoodieDeltaWriteStat stat, AppendResult 
result) {
+    stat.setNumWrites(stat.getNumWrites() + recordsWritten);
+    stat.setNumUpdateWrites(stat.getNumUpdateWrites() + updatedRecordsWritten);
+    stat.setNumInserts(stat.getNumInserts() + insertRecordsWritten);
+    stat.setNumDeletes(stat.getNumDeletes() + recordsDeleted);
+    stat.setTotalWriteBytes(stat.getTotalWriteBytes() + result.size());
+  }
+
+  private void updateWriteStat(HoodieDeltaWriteStat stat, AppendResult result) 
{
+    stat.setPath(makeFilePath(result.logFile()));
+    stat.setLogOffset(result.offset());

Review comment:
       Will this offset contain the offset of the last log file the append 
handle writes to ?




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to