rpuch commented on code in PR #6229:
URL: https://github.com/apache/ignite-3/pull/6229#discussion_r2197651451
##########
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:
Are you asking about the defensive copy? It's to make it easier to reason
about the code, and this method will not be called often, so allocations are
not a problem
--
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]