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


##########
hadoop-hdds/rocksdb-checkpoint-differ/src/main/java/org/apache/ozone/rocksdiff/RocksDiffUtils.java:
##########
@@ -35,20 +52,53 @@ public static boolean isKeyWithPrefixPresent(String 
prefixForColumnFamily,
   }
 
   public static String constructBucketKey(String keyName) {
-    if (!keyName.startsWith(OzoneConsts.OM_KEY_PREFIX)) {
-      keyName = OzoneConsts.OM_KEY_PREFIX.concat(keyName);
+    if (!keyName.startsWith(OM_KEY_PREFIX)) {
+      keyName = OM_KEY_PREFIX.concat(keyName);
     }
-    String[] elements = keyName.split(OzoneConsts.OM_KEY_PREFIX);
+    String[] elements = keyName.split(OM_KEY_PREFIX);
     String volume = elements[1];
     String bucket = elements[2];
     StringBuilder builder =
-        new StringBuilder().append(OzoneConsts.OM_KEY_PREFIX).append(volume);
+        new StringBuilder().append(OM_KEY_PREFIX).append(volume);
 
     if (StringUtils.isNotBlank(bucket)) {
-      builder.append(OzoneConsts.OM_KEY_PREFIX).append(bucket);
+      builder.append(OM_KEY_PREFIX).append(bucket);
     }
     return builder.toString();
   }
 
+  public static void filterRelevantSstFiles(Set<String> inputFiles,
+      Map<String, String> tableToPrefixMap) throws RocksDBException {
+    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) throws RocksDBException {
+    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) + OM_KEY_PREFIX;
+        SstFileReaderIterator iterator =
+            sstFileReader.newIterator(new ReadOptions());

Review Comment:
   We cannot use ManagedSstFileReader here since most managed rocks objects are 
defined in hdds module for which we need dependency.



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