rpuch commented on code in PR #6229:
URL: https://github.com/apache/ignite-3/pull/6229#discussion_r2197826927


##########
modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/instance/SharedRocksDbInstance.java:
##########
@@ -443,4 +448,44 @@ private void destroyColumnFamily(ColumnFamily 
columnFamily) {
             );
         }
     }
+
+    /**
+     * Returns IDs of all tables for which there are storages in the 
underlying RocksDB.
+     */
+    public Set<Integer> tableIdsInRocksDb() {
+        Set<Integer> tableIds = new HashSet<>();
+
+        try (
+                var upperBound = new 
Slice(incrementPrefix(PARTITION_META_PREFIX));
+                var readOptions = new 
ReadOptions().setIterateUpperBound(upperBound);
+                RocksIterator it = meta.columnFamily().newIterator(readOptions)
+        ) {
+            it.seek(PARTITION_META_PREFIX);
+
+            while (it.isValid()) {
+                byte[] key = it.key();
+                int tableId = ByteUtils.bytesToInt(key, 
PARTITION_META_PREFIX.length);
+                tableIds.add(tableId);
+
+                it.next();
+            }
+
+            // Doing this to make an exception thrown if the iteration was 
stopped due to an error and not due to exhausting
+            // the iteration space.
+            it.status();
+        } catch (RocksDBException e) {
+            throw new IgniteInternalException(INTERNAL_ERR, "Cannot get table 
IDs", e);
+        }
+
+        return Set.copyOf(tableIds);

Review Comment:
   It's not about protecting internal state, that's true; but the collection is 
not intended for being modified by the caller, so immutability seems to be a 
good thing here.



-- 
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: notifications-unsubscr...@ignite.apache.org

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

Reply via email to