You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2022/07/29 03:08:31 UTC

[GitHub] [bookkeeper] zymap commented on a diff in pull request #2903: ISSUE-2770: Code refactor calling ledgerExists two times.

zymap commented on code in PR #2903:
URL: https://github.com/apache/bookkeeper/pull/2903#discussion_r932829257


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/SortedLedgerStorage.java:
##########
@@ -144,9 +144,7 @@ public boolean ledgerExists(long ledgerId) throws IOException {
         // the O(1) for the ledgerCache.
         if (!interleavedLedgerStorage.ledgerExists(ledgerId)) {
             EntryKeyValue kv = memTable.getLastEntry(ledgerId);
-            if (null == kv) {
-                return interleavedLedgerStorage.ledgerExists(ledgerId);

Review Comment:
   As the comment said, checking the skip list is an O(logN) operation compared to the O(1) for the ledgerCache.
   
   Which means the `memTable.getLastEntry(ledgerId)` is time consuming operation. After check that, the ledgerCache may be filled so we check it again.



-- 
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: issues-unsubscribe@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org