Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In managed ledger ReadOnlyCursor, optimize for when there's a new led…
…ger created (apache#3148) ### Motivation In managed ledger, the check `Cursor.hasMoreEntries()` is very cheap when the last ledger has at least some entries (eg: just longs comparison). If it's empty, we need to do a more expensive check that involve looking at the ledgers list to make sure the answer is always correct. When creating a read-only cursor, we get a snapshot of the current state. If the topic was left with a new ledger created and no entry into that, the `hasMoreEntries()` will be always expensive. To avoid that, if the last ledger is empty, initialize the last written position on the last entry of previous ledger.
- Loading branch information