chihsuan commented on code in PR #10879:
URL: https://github.com/apache/ozone/pull/10879#discussion_r3674775361
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/ReconDBProvider.java:
##########
@@ -111,16 +110,22 @@ public DBStore getDbStore() {
return dbStore;
}
- static void truncateTable(Table table) throws IOException {
+ static <K> void truncateTable(Table<K, ?> table) throws IOException {
if (table == null) {
return;
}
- try (TableIterator<Object, Table.KeyValue<Object, Object>> tableIterator =
table.iterator()) {
- while (tableIterator.hasNext()) {
- KeyValue<Object, Object> entry = tableIterator.next();
- table.delete(entry.getKey());
+ final K firstKey;
+ final K lastKey;
+ try (TableIterator<K, K> keyIterator = table.keyIterator()) {
+ if (!keyIterator.hasNext()) {
+ return;
}
+ firstKey = keyIterator.next();
+ keyIterator.seekToLast();
+ lastKey = keyIterator.next();
}
+ table.deleteRange(firstKey, lastKey);
+ table.delete(lastKey);
Review Comment:
Thanks @szetszwo I’ve updated the PR based on our discussion. 🙏
It now adds `Table.clear()` using the existing exclusive-end `deleteRange`,
with the javadoc clarified accordingly.
I also made `TypedTable` clear through its raw table
(fcc512e873a89675354f6e11644356cb562a9df1) so the operation uses the exact
persisted key bytes. The default implementation decodes and re-encodes the
boundary keys. In some edge cases, it can miss keys whose bytes do not
round-trip through the codec (see
`TestCodec#testStringCodecMalformedUtf8String`).
The remaining implementations, Recon call sites, and tests have also been
updated.
--
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]