poorbarcode commented on code in PR #24089:
URL: https://github.com/apache/pulsar/pull/24089#discussion_r2000440358


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java:
##########
@@ -3826,9 +3826,19 @@ static long estimateEntryCountBySize(long bytesSize, 
Position readPosition, Mana
         long result = 0;
         long remainingBytesSize = bytesSize;
 
+        Position previousPosToRead = null;
         while (remainingBytesSize > 0) {
-            // Last ledger.
-            if (posToRead.getLedgerId() == ml.getCurrentLedger().getId()) {

Review Comment:
   I think the following predicate is better
   
   ```java
   (ml.getCurrentLedger() != null && posToRead.getLedgerId() == 
ml.getCurrentLedger().getId())
   || (ml.getCurrentLedger() == null && posToRead.getLedgerId() == 
ml.ledgers.lastEntry().getKey())
   ```



-- 
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: commits-unsubscr...@pulsar.apache.org

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

Reply via email to