Skip to content

Commit

Permalink
fix: bug when allAll bucket (apache#13467)
Browse files Browse the repository at this point in the history
(cherry picked from commit 1235162)
  • Loading branch information
leizhiyuan authored and codelipenghui committed Dec 30, 2021
1 parent c9c48d2 commit cac6942
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void addAll(StatsBuckets other) {
buckets[i].add(other.values[i]);
}

sumCounter.add(other.count);
sumCounter.add(other.sum);
}

private boolean isSorted(long[] array) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,17 @@ public void test() {
assertEquals(stats.getCount(), 3);
assertEquals(stats.getBuckets(), new long[] { 1, 0, 1, 1 });
}

@Test
public void testAddAll() {
StatsBuckets stats = new StatsBuckets(10, 20, 30);
stats.addValue(1);
stats.addValue(2);
stats.refresh();
StatsBuckets stats2 = new StatsBuckets(10, 20, 30);
stats2.addAll(stats);
stats2.refresh();
assertEquals(stats2.getSum(),3);
assertEquals(stats2.getCount(),2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void addAll(StatsBuckets other) {
for (int i = 0; i < buckets.length; i++) {
buckets[i].add(other.values[i]);
}
sumCounter.add(other.count);
sumCounter.add(other.sum);
}


Expand Down

0 comments on commit cac6942

Please sign in to comment.