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 @@ -302,9 +302,13 @@ private void merge(
addThis = projectedW <= wLimit;
}
if (i == 1 || i == incomingCount - 1) {
// force last centroid to never merge
// force first and last centroid to never merge
addThis = false;
}
if (lastUsedCell == mean.length - 1) {
// use the last centroid, there's no more
addThis = true;
}

if (addThis) {
// next point will fit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,14 @@ public void testFill() {
i++;
}
}

public void testLargeInputSmallCompression() {
MergingDigest td = new MergingDigest(10);
for (int i = 0; i < 10_000_000; i++) {
td.add(between(0, 3_600_000));
}
assertTrue(td.centroidCount() < 100);
assertTrue(td.quantile(0.00001) < 100_000);
assertTrue(td.quantile(0.99999) > 3_000_000);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void testQuantile() {
hist2.compress();
double x1 = hist1.quantile(0.5);
double x2 = hist2.quantile(0.5);
assertEquals(Dist.quantile(0.5, data), x1, 0.2);
assertEquals(Dist.quantile(0.5, data), x1, 0.25);
assertEquals(x1, x2, 0.01);
}

Expand Down