[improve][broker] Improve cursor.getNumberOfEntries if isUnackedRangesOpenCacheSetEnabled=true - #17465
Merged
Merged
Conversation
codelipenghui
requested review from
315157973,
Technoboy-,
congbobo184,
eolivelli,
gaoran10,
lhotari,
mattisonchao,
merlimat and
michaeljmarshall
September 5, 2022 04:31
Member
|
Nice optimization |
lhotari
reviewed
Sep 5, 2022
| public int cardinality(long lowerKey, long lowerValue, long upperKey, long upperValue) { | ||
| NavigableMap<Long, BitSet> subMap = rangeBitSetMap.subMap(lowerKey, true, upperKey, true); | ||
| MutableInt v = new MutableInt(0); | ||
| subMap.forEach((ledgerId, bitset) -> { |
Member
There was a problem hiding this comment.
Since the class ConcurrentOpenLongPairRangeSet isn't specific to ledgers, would it make sense to avoid using ledgerId as the variable name?
lhotari
reviewed
Sep 5, 2022
lhotari
reviewed
Sep 5, 2022
Contributor
Author
|
@lhotari Thanks for the review. I have updated the PR according to your suggestions; please help take a look again. |
Technoboy-
approved these changes
Sep 6, 2022
Technoboy-
pushed a commit
that referenced
this pull request
Sep 8, 2022
…sOpenCacheSetEnabled=true (#17465)
Member
@codelipenghui LGTM, great improvement in this PR. |
nicoloboschi
pushed a commit
to datastax/pulsar
that referenced
this pull request
Sep 16, 2022
…sOpenCacheSetEnabled=true (apache#17465) (cherry picked from commit 09edcce) (cherry picked from commit a88ac65)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #17451
Motivation
Improve the
ManagedCursorImpl.getNumberOfEntries()ifisUnackedRangesOpenCacheSetEnabled=true.Since the
ConcurrentOpenLongPairRangeSethas the ability to get the acked count for each Ledger,the
ManagedCursorImplcan avoid iterating each range to calculate the acked count.Modifications
Make the
ConcurrentOpenLongPairRangeSetable to get acked count.Verifying this change
Unit test for the new method introduced in
ConcurrentOpenLongPairRangeSetThe
getNumberOfEntries()change is already covered by the existing testDocumentation
Check the box below or label this PR directly.
Need to update docs?
doc-not-needed(Just an improvement for the presented implementation)