Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ public int toBin(double x) {
if (binNumber < MIN_BIN_NUMBER) {
return MIN_BIN_NUMBER;
}
if (binNumber > maxBinNumber) {
return maxBinNumber;
}
return binNumber;
return Math.min(binNumber, maxBinNumber);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public class SimpleRate extends Rate {
public long windowSize(MetricConfig config, long now) {
stat.purgeObsoleteSamples(config, now);
long elapsed = now - stat.oldest(now).lastWindowMs;
return elapsed < config.timeWindowMs() ? config.timeWindowMs() : elapsed;
return Math.max(elapsed, config.timeWindowMs());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,7 @@ private static int calculateCapacity(int expectedNumElements) {
// Avoid using even-sized capacities, to get better key distribution.
int newCapacity = (2 * expectedNumElements) + 1;
// Don't use a capacity that is too small.
if (newCapacity < MIN_NONEMPTY_CAPACITY) {
return MIN_NONEMPTY_CAPACITY;
}
return newCapacity;
return Math.max(newCapacity, MIN_NONEMPTY_CAPACITY);
}

/**
Expand Down