LYD031106 commented on code in PR #2911:
URL:
https://github.com/apache/incubator-hugegraph/pull/2911#discussion_r2531945434
##########
hugegraph-server/hugegraph-hbase/src/main/java/org/apache/hugegraph/backend/store/hbase/HbaseStore.java:
##########
@@ -402,6 +402,8 @@ public void truncate() {
"Failed to truncate table for '%s' store", e, this.store);
}
+ this.init();
Review Comment:
Your solution is indeed a superior approach. By overriding the `truncate()`
method to exclude metadata tables, we are solving the problem at the design
level, which is far more elegant and robust than relying on a temporary
solution involving initialization calls.
I will proceed with the modifications as suggested, implementing this fix
for the HBase backend. For consistency, I will also apply the same change to
the MySQL backend in the corresponding PR
(https://github.com/apache/incubator-hugegraph/pull/2888).
Regarding the current implementation for the RocksDB backend, which uses the
direct `init()` call workaround, I believe it should also be optimized.
Adopting this unified strategy of overriding the `truncate()` method will
enhance code consistency and maintainability across all backends.Here is the
implementation of the `truncate()` method in RocksStore.
```
@Override
public synchronized void truncate() {
Lock writeLock = this.storeLock.writeLock();
writeLock.lock();
try {
this.checkOpened();
this.clear(false);
this.init();
// Clear write-batch
this.dbs.values().forEach(BackendSessionPool::forceResetSessions);
LOG.debug("Store truncated: {}", this.store);
} finally {
writeLock.unlock();
}
}
```
Thank you again for your valuable feedback. It has truly helped me arrive at
a much more elegant solution!
--
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]