gaoran10 commented on code in PR #19138:
URL: https://github.com/apache/pulsar/pull/19138#discussion_r1066610154
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketDelayedDeliveryTracker.java:
##########
@@ -243,6 +263,53 @@ public synchronized boolean addMessage(long ledgerId, long
entryId, long deliver
return true;
}
+ private synchronized CompletableFuture<Void> asyncMergeBucketSnapshot() {
+ List<ImmutableBucket> values =
immutableBuckets.asMapOfRanges().values().stream().toList();
+ long minNumberMessages = Long.MAX_VALUE;
+ int minIndex = -1;
+ for (int i = 0; i + 1 < values.size(); i++) {
+ ImmutableBucket bucketL = values.get(i);
+ ImmutableBucket bucketR = values.get(i + 1);
+ long numberMessages = bucketL.numberBucketDelayedMessages +
bucketR.numberBucketDelayedMessages;
+ if (numberMessages < minNumberMessages) {
+ minNumberMessages = (int) numberMessages;
+ minIndex = i;
+ }
+ }
+ return asyncMergeBucketSnapshot(values.get(minIndex),
values.get(minIndex + 1));
Review Comment:
Must We merge buckets that are contiguous? Could we find the two smallest
buckets and merge them?
--
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]