@@ -206,23 +206,33 @@ TEST_P(BloomFilterBuilderFoldingTest, RespectsOption) {
206206 ::arrow::SliceBuffer (buffer, location.offset, location.length));
207207 auto filter = parquet::BlockSplitBloomFilter::Deserialize (reader_properties, &reader);
208208
209+ const auto actual_bitset_size = filter.GetBitsetSize ();
209210 EXPECT_EQ (BlockSplitBloomFilter::OptimalNumOfBytes (test_case.expected_bitset_ndv , kFpp ),
210- filter.GetBitsetSize ());
211+ actual_bitset_size);
212+
213+ if (test_case.fold ) {
214+ EXPECT_LE (actual_bitset_size, initial_bitset_size);
215+ } else {
216+ EXPECT_EQ (actual_bitset_size, initial_bitset_size);
217+ }
218+
211219 for (uint64_t hash : hashes) {
212220 EXPECT_TRUE (filter.FindHash (hash));
213221 }
214222
215- int32_t false_positives = 0 ;
216- constexpr int32_t kNonInsertedCount = 10'000 ;
217- for (int32_t i = test_case.inserted_count ;
218- i < test_case.inserted_count + kNonInsertedCount ; ++i) {
219- false_positives += filter.FindHash (filter.Hash (i));
223+ if (test_case.fold && test_case.inserted_count > 0 ) {
224+ int32_t false_positives = 0 ;
225+ constexpr int32_t kNonInsertedCount = 10'000 ;
226+ for (int32_t i = test_case.inserted_count ;
227+ i < test_case.inserted_count + kNonInsertedCount ; ++i) {
228+ false_positives += filter.FindHash (filter.Hash (i));
229+ }
230+ const auto sample_fpp = static_cast <double >(false_positives) / kNonInsertedCount ;
231+ EXPECT_LT (sample_fpp, kFpp );
232+ // If the actual fpp, as computed on this sample, is significantly below kFpp / 2,
233+ // then we could have folded the bloom filter at least once more.
234+ EXPECT_GT (sample_fpp, kFpp / 2.1 );
220235 }
221- const auto sample_fpp = static_cast <double >(false_positives) / kNonInsertedCount ;
222- EXPECT_LT (sample_fpp, kFpp );
223- // If the actual fpp, as computed on this sample, is significantly below kFpp / 2,
224- // then we could have folded the bloom filter at least once more.
225- EXPECT_GT (sample_fpp, kFpp / 2.1 );
226236}
227237
228238INSTANTIATE_TEST_SUITE_P (
0 commit comments