Skip to content

Commit dec54ca

Browse files
HeidiHan0000facebook-github-bot
authored andcommitted
fix(test): Flakiness in KHLL uniqueDistribution test (#16237)
Summary: There was some flakiness in the uniqueness distribution test when the expected was 0, because it would allow 0 tolerance. Fix: use a larger tolerance (2/size which allows for error up to 2 values in that bucket) while comparing buckets with too few expected values Differential Revision: D92242037
1 parent e3dacce commit dec54ca

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

velox/functions/lib/tests/KHyperLogLogTest.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ TEST_F(KHyperLogLogTest, uniquenessDistribution) {
293293

294294
// Use 10% tolerance since the values of uniqueness distribution are a sum
295295
// of 1 / size of minHash, and not the cardinality estimates.
296-
EXPECT_NEAR(khllEstimated, expected, expected * 0.1)
296+
// Allow larger tolerance for buckets with very few values.
297+
double tolerance = std::max(2.0 / size, 0.1 * expected);
298+
EXPECT_NEAR(khllEstimated, expected, tolerance)
297299
<< "Histogram mismatch at bucket " << i;
298300
}
299301
}

0 commit comments

Comments
 (0)