swamirishi commented on code in PR #9169:
URL: https://github.com/apache/ozone/pull/9169#discussion_r2441246988


##########
hadoop-hdds/rocksdb-checkpoint-differ/src/main/java/org/apache/ozone/rocksdiff/RocksDBCheckpointDiffer.java:
##########
@@ -1426,6 +1431,79 @@ public static void invalidateCacheEntry(String cacheKey) 
{
     }
   }
 
+  public List<String> getCompactionLogSstFiles(Path checkpointPath)
+      throws IOException {
+    List<String> sstFiles = new ArrayList<>();
+    List<ColumnFamilyDescriptor> cfDescriptors = new ArrayList<>();
+    List<byte[]> cfs;
+    try (Options options = new Options()) {
+      cfs = RocksDB.listColumnFamilies(options, checkpointPath.toString());
+    } catch (RocksDBException e) {
+      throw new IOException(e);
+    }
+
+    if (cfs == null || cfs.isEmpty()) {
+      cfs = Collections.singletonList(RocksDB.DEFAULT_COLUMN_FAMILY);
+    }
+
+    List<ColumnFamilyOptions> cfOptions = new ArrayList<>();
+    try {
+      for (byte[] cf : cfs) {
+        ColumnFamilyOptions opts = new ColumnFamilyOptions();
+        cfOptions.add(opts);
+        cfDescriptors.add(new ColumnFamilyDescriptor(cf, opts));
+      }
+
+      List<ColumnFamilyHandle> cfHandles = new ArrayList<>();
+      try (DBOptions dbOptions = new DBOptions()
+          .setCreateIfMissing(false).setCreateMissingColumnFamilies(true);
+          RocksDB db = RocksDB.openReadOnly(dbOptions,
+              checkpointPath.toString(), cfDescriptors, cfHandles)) {
+
+        ColumnFamilyHandle compactionLogCf = null;
+        for (int i = 0; i < cfs.size(); i++) {
+          if (Arrays.equals(cfs.get(i),
+              "compactionLogTable".getBytes(UTF_8))) {
+            compactionLogCf = cfHandles.get(i);
+            break;
+          }
+        }
+
+        if (compactionLogCf != null) {
+          try (RocksIterator iterator = db.newIterator(compactionLogCf)) {
+            for (iterator.seekToFirst(); iterator.isValid(); iterator.next()) {
+              try {
+                CompactionLogEntry logEntry = 
CompactionLogEntry.getFromProtobuf(
+                    CompactionLogEntryProto.parseFrom(iterator.value()));
+                logEntry.getInputFileInfoList().forEach(f ->
+                    sstFiles.add(f.getFileName()));
+                logEntry.getOutputFileInfoList().forEach(f ->
+                    sstFiles.add(f.getFileName()));

Review Comment:
   I don't think we should add output files in the sst files to the list. We 
only create hardlinks for inputSstFiles



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