rdhabalia commented on a change in pull request #14330:
URL: https://github.com/apache/pulsar/pull/14330#discussion_r809305997
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java
##########
@@ -282,7 +282,7 @@ public boolean readCompacted() {
// calculate avg message per entry
int tmpAvgMessagesPerEntry = AVG_MESSAGES_PER_ENTRY.get(this);
- tmpAvgMessagesPerEntry = (int) Math.round(tmpAvgMessagesPerEntry *
avgPercent
+ tmpAvgMessagesPerEntry = (int) Math.floor(tmpAvgMessagesPerEntry *
avgPercent
Review comment:
no, we should not use double which will not solve it.
floor solves it. mathematically `round` was calculating higher value for
`5.5 to -> 6` and formula `(tmpAvgMessagesPerEntry * avgPercent + (1 -
avgPercent) * totalMessages / entries.size())` always results into `6 -> 5.5`.
therefore, result always stays the same`6`.
`floor` returns the largest less than or equal to the argument which makes
value keep going down and eventually becomes 1. It fixes the issue into the
right way.
Please test and unblock the PR.
--
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]