asafm commented on code in PR #21816:
URL: https://github.com/apache/pulsar/pull/21816#discussion_r1439280519
##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorContainer.java:
##########
@@ -204,6 +281,24 @@ public ManagedCursor getSlowestReader() {
}
}
+ /**
+ * @return Returns the CursorInfo for the cursor with the oldest position,
+ * or null if there aren't any tracked cursors
+ */
+ public CursorInfo getCursorWithOldestPosition() {
+ long stamp = rwLock.readLock();
+ try {
+ if (heap.isEmpty()) {
+ return null;
+ } else {
+ Item item = heap.get(0);
Review Comment:
@dragosvictor answered
[here](https://github.com/apache/pulsar/pull/21816#discussion_r1437844593).
It's because removing an arbitrary object from a PriorityQueue is O(n) while in
Pulsar implementation, removing is O(1) due to the usage of Map of cursor name
to `Item` and in it, we have its index in the array.
--
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]