-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[improve][broker] Get lowest PositionImpl from NavigableSet #18278
[improve][broker] Get lowest PositionImpl from NavigableSet #18278
Conversation
change signature from Set<T> to NavigableSet<T> which makes the caller to get lowest PositionImpl more efficient.
@codelipenghui @Jason918 please take a look, thank you~ |
@@ -285,7 +286,7 @@ public synchronized void readMoreEntries() { | |||
} | |||
|
|||
havePendingReplayRead = true; | |||
minReplayedPosition = messagesToReplayNow.stream().min(PositionImpl::compareTo).orElse(null); | |||
minReplayedPosition = messagesToReplayNow.pollFirst(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be first(), not pollFirst()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, thanks for review.
/pulsarbot run-failure-checks |
.../java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/pulsarbot run-failure-checks |
…osition' into direct_use_tree_map_to_get_lowest_position
Codecov Report
@@ Coverage Diff @@
## master #18278 +/- ##
============================================
+ Coverage 38.97% 39.92% +0.94%
- Complexity 8311 8591 +280
============================================
Files 683 687 +4
Lines 67325 67381 +56
Branches 7217 7217
============================================
+ Hits 26239 26899 +660
+ Misses 38079 37502 -577
+ Partials 3007 2980 -27
Flags with carried forward coverage won't be shown. Click here to find out more.
|
/pulsarbot run-failure-checks |
…8278) * [cleanup] Direct get lowest PositionImpl from TreeMap change signature from Set<T> to NavigableSet<T> which makes the caller to get lowest PositionImpl more efficient. * change poll to first when call `NavigableSet` * fix check style remove unused import Co-authored-by: wangjinlong <[email protected]>
* [cleanup] Direct get lowest PositionImpl from TreeMap change signature from Set<T> to NavigableSet<T> which makes the caller to get lowest PositionImpl more efficient. * change poll to first when call `NavigableSet` * fix check style remove unused import Co-authored-by: wangjinlong <[email protected]>
…8278) * [cleanup] Direct get lowest PositionImpl from TreeMap change signature from Set<T> to NavigableSet<T> which makes the caller to get lowest PositionImpl more efficient. * change poll to first when call `NavigableSet` * fix check style remove unused import Co-authored-by: wangjinlong <[email protected]> (cherry picked from commit 01badd2)
Fixes #18279
Motivation
change signature from
Set<T>
toNavigableSet<T>
which makes the caller to get lowest
PositionImpl
more efficient ( compare withstream().findfirst()
)Verifying this change
This change is already covered by existing tests, such as (please describe tests).
Documentation
doc
doc-required
doc-not-needed
doc-complete