Skip to content

Commit

Permalink
Defer to rescaling if values don't fit in the bucket
Browse files Browse the repository at this point in the history
- Rescaling is not frequent behaviour (for cumulative scale should normalize after initial few recording, for delta it could increase/decrease but would be mostly stable) hence we would re-try the record behaviour if the index won't fit in the value.
  • Loading branch information
lenin-jaganathan committed Dec 18, 2024
1 parent 3383e5c commit 1029615
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ else if (index < startIndex) {
startIndex = index;
}

counts.addAndGet(getRelativeIndex(index), incrementBy);
return true;
final int relativeIndex = getRelativeIndex(index);
if (relativeIndex >= 0 && relativeIndex < length) {
counts.addAndGet(relativeIndex, incrementBy);
return true;
}
return false;
}

private int getRelativeIndex(int index) {
Expand Down

0 comments on commit 1029615

Please sign in to comment.