Skip to content

Commit f589e2c

Browse files
committed
SPARK-47547 BloomFilter fpp degradation: counting discarded odd items in random test + test formatting
1 parent d912b66 commit f589e2c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

common/sketch/src/test/java/org/apache/spark/util/sketch/TestSparkBloomFilter.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,16 @@ public static void afterAll() {
5151
}
5252

5353
@BeforeEach
54-
public void beforeEach() {
54+
public void beforeEach(TestInfo testInfo) {
5555
start = Instant.now();
56+
System.err.println("---");
57+
System.err.println(testInfo.getTestMethod().get().getName() + " " + testInfo.getDisplayName());
5658
}
5759

5860
@AfterEach
5961
public void afterEach(TestInfo testInfo) {
6062
Duration duration = Duration.between(start, Instant.now());
61-
System.err.println(duration + " " + testInfo.getDisplayName());
63+
System.err.println(duration );
6264
}
6365

6466
/**
@@ -236,6 +238,7 @@ public void testAccuracyRandom(
236238

237239
long mightContainEvenIndexed = 0;
238240
long mightContainOddIndexed = 0;
241+
long discardedOddIndexed = 0;
239242

240243
pseudoRandom.setSeed(deterministicSeed);
241244
for (long i = 0; i < iterationCount; i++) {
@@ -255,6 +258,8 @@ public void testAccuracyRandom(
255258
// (mitigating duplicates in input sequence)
256259
if (!bloomFilterSecondary.mightContainLong(candidate)) {
257260
mightContainOddIndexed++;
261+
} else {
262+
discardedOddIndexed++;
258263
}
259264
}
260265
}
@@ -266,9 +271,11 @@ public void testAccuracyRandom(
266271
"mightContainLong must return true for all inserted numbers"
267272
);
268273

269-
double actualFpp = (double) mightContainOddIndexed / numItems;
274+
double actualFpp = (double) mightContainOddIndexed / (numItems - discardedOddIndexed);
270275
double acceptableFpp = expectedFpp * (1 + FPP_RANDOM_ERROR_FACTOR);
271276

277+
System.err.printf("numItems: %10d\n", numItems);
278+
System.err.printf("discardedOddIndexed: %10d\n", discardedOddIndexed);
272279
System.err.printf("expectedFpp: %f %%\n", 100 * expectedFpp);
273280
System.err.printf("acceptableFpp: %f %%\n", 100 * acceptableFpp);
274281
System.err.printf("actualFpp: %f %%\n", 100 * actualFpp);

0 commit comments

Comments
 (0)