adoroszlai commented on code in PR #7676:
URL: https://github.com/apache/ozone/pull/7676#discussion_r1912393778


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OMDBCheckpointServlet.java:
##########
@@ -210,12 +216,12 @@ public static Map<Path, Path> normalizeExcludeList(
             sstBackupDir.getOriginalDir().toString().length() + 1;
         Path srcPath = Paths.get(sstBackupDir.getTmpDir().toString(),
             truncateFileName(truncateLength, destPath));
-        paths.put(srcPath, destPath);
+        paths.computeIfAbsent(fileName.toString(), (k) -> new 
HashMap<>()).put(srcPath, destPath);
       } else if (!s.startsWith(OM_SNAPSHOT_DIR)) {
         Path fixedPath = Paths.get(checkpointLocation.toString(), s);
-        paths.put(fixedPath, fixedPath);
+        paths.computeIfAbsent(fileName.toString(), (k) -> new 
HashMap<>()).put(fixedPath, fixedPath);
       } else {
-        paths.put(destPath, destPath);
+        paths.computeIfAbsent(fileName.toString(), (k) -> new 
HashMap<>()).put(destPath, destPath);

Review Comment:
   Please move common `paths.computeIfAbsent(fileName.toString(), (k) -> new 
HashMap<>())` before the `if-else` branching.



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OMDBCheckpointServlet.java:
##########
@@ -168,13 +169,14 @@ public void writeDbDataToStream(DBCheckpoint checkpoint,
           differ.getCompactionLogDir());
 
       // Files to be excluded from tarball
-      Map<Path, Path> sstFilesToExclude = normalizeExcludeList(toExcludeList,
+      Map<String, Map<Path, Path>> sstFilesToExclude = 
normalizeExcludeList(toExcludeList,
           checkpoint.getCheckpointLocation(), sstBackupDir);
       boolean completed = getFilesForArchive(checkpoint, copyFiles,
           hardLinkFiles, sstFilesToExclude, includeSnapshotData(request),
           excludedList, sstBackupDir, compactionLogDir);
-      writeFilesToArchive(copyFiles, hardLinkFiles, archiveOutputStream,
-          completed, checkpoint.getCheckpointLocation());
+      writeFilesToArchive(copyFiles.values().stream().flatMap(map -> 
map.entrySet().stream())
+              .collect(Collectors.toMap(Map.Entry::getKey, 
Map.Entry::getValue)),
+          hardLinkFiles, archiveOutputStream, completed, 
checkpoint.getCheckpointLocation());

Review Comment:
   Please move stream pipeline to a separate statement, something like:
   
   ```java
         Map<Path, Path> flatCopyFiles = copyFiles.values().stream()
             .flatMap(map -> map.entrySet().stream())
             .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
         writeFilesToArchive(flatCopyFiles, hardLinkFiles, archiveOutputStream,
             completed, checkpoint.getCheckpointLocation());
   ```



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