sadanand48 commented on code in PR #4273:
URL: https://github.com/apache/ozone/pull/4273#discussion_r1115700416


##########
hadoop-hdds/rocksdb-checkpoint-differ/src/main/java/org/apache/ozone/rocksdiff/RocksDiffUtils.java:
##########
@@ -50,5 +62,48 @@ public static String constructBucketKey(String keyName) {
     return builder.toString();
   }
 
+  public static void filterRelevantSstFiles(Set<String> inputFiles,
+      Map<String, String> tableToPrefixMap) {
+    for (Iterator<String> fileIterator =
+         inputFiles.iterator(); fileIterator.hasNext();) {
+      String filepath = fileIterator.next();
+      if (!RocksDiffUtils.doesSstFileContainKeyRange(filepath,
+          tableToPrefixMap)) {
+        fileIterator.remove();
+      }
+    }
+  }
+
+  public static boolean doesSstFileContainKeyRange(String filepath,
+      Map<String, String> tableToPrefixMap) {
+    try (SstFileReader sstFileReader = new SstFileReader(new Options())) {
+      sstFileReader.open(filepath);
+      TableProperties properties = sstFileReader.getTableProperties();
+      String tableName = new String(properties.getColumnFamilyName(), UTF_8);
+      if (tableToPrefixMap.containsKey(tableName)) {
+        String prefix = tableToPrefixMap.get(tableName);
+        SstFileReaderIterator iterator =
+            sstFileReader.newIterator(new ReadOptions());
+        iterator.seekToFirst();
+        String firstKey = RocksDiffUtils.constructBucketKey(
+            new String(iterator.key(), UTF_8));
+        iterator.seekToLast();
+        String lastKey = RocksDiffUtils.constructBucketKey(
+            new String(iterator.key(), UTF_8));
+        boolean keyWithPrefixPresent =
+            RocksDiffUtils.isKeyWithPrefixPresent(prefix, firstKey, lastKey);
+        if (!keyWithPrefixPresent) {
+          return false;
+        }
+      } else {
+        // entry from other tables
+        return false;
+      }
+    } catch (RocksDBException e) {
+      e.printStackTrace();

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-unsubscr...@ozone.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org
For additional commands, e-mail: issues-h...@ozone.apache.org

Reply via email to