swamirishi commented on code in PR #5454:
URL: https://github.com/apache/ozone/pull/5454#discussion_r1362553105
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java:
##########
@@ -535,42 +536,37 @@ public SnapshotDiffCleanupService
getSnapshotDiffCleanupService() {
* @param keyPrefix DB key prefix String
* @return endKey String, or null if no keys with such prefix is found
*/
- private static String findEndKeyGivenPrefix(
+ private static String performOperationGivenPrefix(
TableIterator<String, ? extends Table.KeyValue<String, ?>> keyIter,
- String keyPrefix) throws IOException {
-
- String endKey;
+ String keyPrefix, ThrowableFunction<Table.KeyValue<String, ?>,
+ Void, IOException> operationFunction) throws IOException {
+ String endKey = null;
keyIter.seek(keyPrefix);
// Continue only when there are entries of snapshot (bucket) scope
// in deletedTable in the first place
- if (!keyIter.hasNext()) {
- // No key matching keyPrefix. No need to do delete or deleteRange at all.
- endKey = null;
- } else {
- // Remember the last key with a matching prefix
- endKey = keyIter.next().getKey();
-
- // Loop until prefix mismatches.
- // TODO: [SNAPSHOT] Try to seek to next predicted bucket name instead of
- // the while-loop for a potential speed up?
- // Start performance tracking timer
- long startTime = System.nanoTime();
- while (keyIter.hasNext()) {
- Table.KeyValue<String, ?> entry = keyIter.next();
- String dbKey = entry.getKey();
- if (dbKey.startsWith(keyPrefix)) {
- endKey = dbKey;
- }
- }
- // Time took for the iterator to finish (in ns)
- long timeElapsed = System.nanoTime() - startTime;
- if (timeElapsed >= DB_TABLE_ITER_LOOP_THRESHOLD_NS) {
- // Print time elapsed
- LOG.warn("Took {} ns to find endKey. Caller is {}", timeElapsed,
- new Throwable().fillInStackTrace().getStackTrace()[1]
- .getMethodName());
+ // Loop until prefix matches.
+ // TODO: [SNAPSHOT] Try to seek to next predicted bucket name instead of
+ // the while-loop for a potential speed up?
+ // Start performance tracking timer
+ long startTime = System.nanoTime();
+ while (keyIter.hasNext()) {
+ Table.KeyValue<String, ?> entry = keyIter.next();
+ String dbKey = entry.getKey();
+ if (dbKey.startsWith(keyPrefix)) {
+ operationFunction.apply(entry);
+ endKey = dbKey;
+ } else {
+ break;
Review Comment:
yeah you are right we don't need it
--
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]