Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions cpp/src/parquet/bloom_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
namespace parquet {
constexpr uint32_t BlockSplitBloomFilter::SALT[kBitsSetPerBlock];

BlockSplitBloomFilter::BlockSplitBloomFilter()
: pool_(::arrow::default_memory_pool()),
BlockSplitBloomFilter::BlockSplitBloomFilter(::arrow::MemoryPool* pool)
: pool_(pool),
hash_strategy_(HashStrategy::XXHASH),
algorithm_(Algorithm::BLOCK),
compression_strategy_(CompressionStrategy::UNCOMPRESSED) {}
Expand Down
10 changes: 8 additions & 2 deletions cpp/src/parquet/bloom_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PARQUET_EXPORT BloomFilter {
public:
// Maximum Bloom filter size, it sets to HDFS default block size 128MB
// This value will be reconsidered when implementing Bloom filter producer.
static constexpr uint32_t kMaximumBloomFilterBytes = 128 * 1024 * 1024;
static constexpr uint64_t kMaximumBloomFilterBytes = 128 * 1024 * 1024;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the return type of OptimalNumOfBits be changed to uint64_t as well?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently just keep it uint32_t is ok, since it could support 4G. For Bits, its 1G Bytes, and it's 8 times greater than kMaximumBloomFilterBytes.


/// Determine whether an element exist in set or not.
///
Expand Down Expand Up @@ -122,7 +122,7 @@ class PARQUET_EXPORT BloomFilter {
class PARQUET_EXPORT BlockSplitBloomFilter : public BloomFilter {
public:
/// The constructor of BlockSplitBloomFilter. It uses XXH64 as hash function.
BlockSplitBloomFilter();
BlockSplitBloomFilter(::arrow::MemoryPool* pool = ::arrow::default_memory_pool());

/// Initialize the BlockSplitBloomFilter. The range of num_bytes should be within
/// [kMinimumBloomFilterBytes, kMaximumBloomFilterBytes], it will be
Expand All @@ -145,6 +145,12 @@ class PARQUET_EXPORT BlockSplitBloomFilter : public BloomFilter {
/// Minimum Bloom filter size, it sets to 32 bytes to fit a tiny Bloom filter.
static constexpr uint32_t kMinimumBloomFilterBytes = 32;

static uint32_t OptimalNumOfBytes(uint32_t ndv, double fpp) {
uint32_t optimal_num_of_bits = OptimalNumOfBits(ndv, fpp);
DCHECK(::arrow::bit_util::IsMultipleOf8(optimal_num_of_bits));
return optimal_num_of_bits >> 3;
}

/// Calculate optimal size according to the number of distinct values and false
/// positive probability.
///
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/parquet/bloom_filter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ TEST(FPPTest, TestBloomFilter) {

std::vector<std::string> members;
BlockSplitBloomFilter bloom_filter;
bloom_filter.Init(BlockSplitBloomFilter::OptimalNumOfBits(total_count, fpp));
bloom_filter.Init(BlockSplitBloomFilter::OptimalNumOfBytes(total_count, fpp));

// Insert elements into the Bloom filter
for (int i = 0; i < total_count; i++) {
Expand Down