imbajin commented on code in PR #3299:
URL: https://github.com/apache/hugegraph/pull/3299#discussion_r4231249190


##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/unit/rocksdb/RocksDBSessionsTest.java:
##########
@@ -226,6 +228,87 @@ protected Map<String, RocksDBSessions> tableDBMapping() {
         }
     }
 
+    @Test
+    public void testToplingOlapClearKeepsHandleAndOtherTables() throws 
Exception {
+        this.assertOlapClear(true, false);
+    }
+
+    @Test
+    public void testToplingOlapClearRoutesIndependentDatabase() throws 
Exception {
+        this.assertOlapClear(true, true);
+    }
+
+    @Test
+    public void testStandardOlapClearRecreatesTable() throws Exception {
+        this.assertOlapClear(false, false);
+    }
+
+    private void assertOlapClear(boolean topling, boolean separate) throws 
Exception {
+        Id id = IdGenerator.of(123L);
+        String path = DB_PATH + "/olap-clear-" + topling + "-" + separate;
+        RocksDBSessions olap = new RocksDBStdSessions(FakeObjects.newConfig(), 
"db", "olap", path, path);
+        RocksDBStore.RocksDBGraphStore store = new 
RocksDBStore.RocksDBGraphStore(
+                new RocksDBStoreProvider(), "db", "store") {
+            @Override
+            protected RocksDBSessions db(HugeType type) {
+                return type == HugeType.OLAP ? olap : super.db(type);
+            }
+        };
+        Whitebox.setInternalState(store, "sessions", separate ? this.rocks : 
olap);
+        Whitebox.setInternalState(store, "toplingProvider", topling);
+        try {
+            olap.session();
+            store.createOlapTable(id);
+            String table = "store+ap_123";
+            olap.createTable(TABLE, "other-olap");
+            RocksDBSessions.Session session = olap.session();
+            session.put(table, getBytes("m"), getBytes("old"));
+            session.put(table, getBytes("n"), getBytes("old"));
+            session.put("other-olap", getBytes("other"), getBytes("retained"));
+            session.commit();
+            session.put(TABLE, getBytes("main"), getBytes("retained main"));
+            session.commit();
+            Object opened = Whitebox.getInternalState(olap, "rocksdb");
+            Map<String, ?> handles = Whitebox.getInternalState(opened, 
"cfHandles");

Review Comment:
   Integration note for #3293, not a defect in this head: this fixture reads 
`rocksdb` as the owner directly. At `2d335c9889e73e08a2c08a077e002d1294b0f601`, 
#3293 changes that field to `AtomicReference<OpenedRocksDB>` and updates the 
existing fixtures to call `owner.get()`. When combining these changes, please 
apply the same dereference here before reading `cfHandles`; otherwise the three 
new OLAP-clear tests will reflect on `AtomicReference`. This is a source-level 
integration finding; no combined-tree test run was performed.



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