codelipenghui commented on code in PR #19035:
URL: https://github.com/apache/pulsar/pull/19035#discussion_r1058688478
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java:
##########
@@ -1045,7 +1056,7 @@ public boolean trackDelayedDelivery(long ledgerId, long
entryId, MessageMetadata
}
}
- protected synchronized NavigableSet<PositionImpl>
getMessagesToReplayNow(int maxMessagesToRead) {
+ protected synchronized NavigableSet<PositionImpl>
getMessagesToReplayNow(int maxMessagesToRead) {
Review Comment:
We don't need to add a space.
##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpReadEntry.java:
##########
@@ -72,13 +76,19 @@ public void readEntriesComplete(List<Entry>
returnedEntries, Object ctx) {
}
cursor.updateReadStats(entriesCount, entriesSize);
- final PositionImpl lastPosition = (PositionImpl)
returnedEntries.get(entriesCount - 1).getPosition();
+ if (lastPosition == null || entriesCount != 0) {
+ lastPosition = (PositionImpl) returnedEntries.get(entriesCount -
1).getPosition();
+ }
Review Comment:
If the `returnedEntries` is empty and the `lastPosition` is null, we will
get an exception.
##########
managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java:
##########
@@ -4252,5 +4253,64 @@ public void
testLazyCursorLedgerCreationForSubscriptionCreation() throws Excepti
factory2.shutdown();
}
+ @Test
+ public void testReadEntriesWithFilterOut() throws ManagedLedgerException,
InterruptedException, ExecutionException {
+ int readMaxNumber = 10;
+ int sendNumber = 20;
+ ManagedLedger ledger = factory.open("testReadEntriesWithFilter");
+ ManagedCursor cursor = ledger.openCursor("c");
Review Comment:
Should be closed after the test.
##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedCursor.java:
##########
@@ -167,6 +167,18 @@ void asyncReadEntries(int numberOfEntriesToRead,
ReadEntriesCallback callback, O
void asyncReadEntries(int numberOfEntriesToRead, long maxSizeBytes,
ReadEntriesCallback callback,
Object ctx, PositionImpl maxPosition);
+ /**
+ * Asynchronously read entries from the ManagedLedger.
+ *
+ * @param numberOfEntriesToRead maximum number of entries to return
+ * @param maxSizeBytes max size in bytes of the entries to return
+ * @param callback callback object
+ * @param ctx opaque context
+ * @param maxPosition max position can read
+ */
+ void asyncReadEntriesWithSkip(int numberOfEntriesToRead, long
maxSizeBytes, ReadEntriesCallback callback,
Review Comment:
It's better to add a default implementation. Otherwise, we will break the
user's existing implementations.
--
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]