ashishkumar50 commented on code in PR #10067:
URL: https://github.com/apache/ozone/pull/10067#discussion_r3083970718


##########
hadoop-ozone/iceberg/src/main/java/org/apache/hadoop/ozone/iceberg/RewriteTablePathOzoneAction.java:
##########
@@ -184,8 +206,106 @@ private boolean versionInFilePath(String path, String 
version) {
   }
 
   private String rebuildMetadata() {
-    //TODO need to implement rewrite of metadata files , manifest list , 
manifest files and position delete files.
-    return null;
+    //TODO need to implement rewrite of manifest list , manifest files and 
position delete files.
+    TableMetadata startMetadata = startVersionName != null

Review Comment:
   `startMetadata` is not used, Later when this is required we can add it.



##########
hadoop-ozone/iceberg/src/main/java/org/apache/hadoop/ozone/iceberg/RewriteTablePathOzoneAction.java:
##########
@@ -184,8 +206,106 @@ private boolean versionInFilePath(String path, String 
version) {
   }
 
   private String rebuildMetadata() {
-    //TODO need to implement rewrite of metadata files , manifest list , 
manifest files and position delete files.
-    return null;
+    //TODO need to implement rewrite of manifest list , manifest files and 
position delete files.
+    TableMetadata startMetadata = startVersionName != null
+        ? ((HasTableOperations) newStaticTable(startVersionName, table.io()))
+        .operations()
+        .current()
+        : null;
+    TableMetadata endMetadata =
+        ((HasTableOperations) newStaticTable(endVersionName, 
table.io())).operations().current();
+
+    List<PartitionStatisticsFile> partitionStats = 
endMetadata.partitionStatisticsFiles();
+    if (partitionStats != null && !partitionStats.isEmpty()) {
+      throw new IllegalArgumentException("Partition statistics files are not 
supported yet.");
+    }
+
+    RewriteResult<Snapshot> rewriteVersionResult = 
rewriteVersionFiles(endMetadata);
+
+    Set<Pair<String, String>> copyPlan = new HashSet<>();
+    copyPlan.addAll(rewriteVersionResult.copyPlan());
+
+    return saveFileList(copyPlan);
+  }
+
+  private String saveFileList(Set<Pair<String, String>> filesToMove) {
+    String fileListPath = stagingDir + RESULT_LOCATION;
+    OutputFile fileList = table.io().newOutputFile(fileListPath);
+    writeAsCsv(filesToMove, fileList);
+    return fileListPath;
+  }
+
+  private void writeAsCsv(Set<Pair<String, String>> rows, OutputFile 
outputFile) {
+    try (BufferedWriter writer = new BufferedWriter(
+        new OutputStreamWriter(outputFile.createOrOverwrite(), 
StandardCharsets.UTF_8))) {
+      for (Pair<String, String> pair : rows) {
+        writer.write(String.join(",", pair.first(), pair.second()));

Review Comment:
   Use `writer.append(first).append(',').append(second);`



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

Reply via email to