Skip to content

[C++][Parquet] Reader rejects valid 96-byte split block Bloom filters #55824

Backlog

Description

@zhjwpku

Describe the bug, including details regarding any error messages, version, and platform.

Arrow C++ 25.0.1 on macOS arm64 throws ParquetException: Given length of bitset is illegal when reading a column Bloom filter written by parquet-go v0.25.1.

To reproduce, write one row group with an INT32 column named Value containing 0 through 63 and enable parquet.SplitBlockFilter(10, "Value"). This produces a 96-byte bitset (three 32-byte blocks).

auto reader = parquet::ParquetFileReader::OpenFile("sample.parquet", false);
auto filter = reader->GetBloomFilterReader().RowGroup(0)->GetColumnBloomFilter(0);

The second call throws. The reader should return a 96-byte filter that reports all 64 inserted values as present. The Parquet format permits three blocks, but the bitset overload of BlockSplitBloomFilter::Init requires its length to be a power of two. Parquet Bloom filter specification

Component(s)

C++

Activity

  1. ansh0014 commented on Nov 30, 2026

    @ansh0014

    Hi! @raulcd
    I traced this in the C++ Parquet Bloom filter implementation and wanted to confirm the fix before opening a PR.

    In cpp/src/parquet/bloom_filter.cc, BlockSplitBloomFilter::Init(const uint8_t* bitset, uint32_t num_bytes) currently rejects any size that isn't a power of two ((num_bytes & (num_bytes - 1)) != 0), throwing "Given length of bitset is illegal".

    However, FindHash, InsertHashImpl, and NumBlocks() already use fastrange (((hash >> 32) * NumBlocks()) >> 32), which works for any valid number of 32-byte blocks (num_bytes % kBytesPerFilterBlock == 0), not just powers of two.

    My plan is to:

    1. Update BlockSplitBloomFilter::Init(const uint8_t* bitset, uint32_t num_bytes) to require num_bytes % kBytesPerFilterBlock == 0 within [kMinimumBloomFilterBytes, kMaximumBloomFilterBytes] instead of requiring a power of two (keeping the writer-side Init(uint32_t num_bytes) unchanged).
    2. Update cpp/src/parquet/bloom_filter_test.cc to test initializing/deserializing and querying a 96-byte (3-block) Bloom filter, while still rejecting sizes that aren't multiples of 32 bytes.

    Does this approach look good? If so, could you please assign this issue to me?

  2. zhjwpku commented on Nov 30, 2026

    @zhjwpku
    MemberAuthor

    Hi! @raulcd I traced this in the C++ Parquet Bloom filter implementation and wanted to confirm the fix before opening a PR.

    In cpp/src/parquet/bloom_filter.cc, BlockSplitBloomFilter::Init(const uint8_t* bitset, uint32_t num_bytes) currently rejects any size that isn't a power of two ((num_bytes & (num_bytes - 1)) != 0), throwing "Given length of bitset is illegal".

    However, FindHash, InsertHashImpl, and NumBlocks() already use fastrange (((hash >> 32) * NumBlocks()) >> 32), which works for any valid number of 32-byte blocks (num_bytes % kBytesPerFilterBlock == 0), not just powers of two.

    My plan is to:

    1. Update BlockSplitBloomFilter::Init(const uint8_t* bitset, uint32_t num_bytes) to require num_bytes % kBytesPerFilterBlock == 0 within [kMinimumBloomFilterBytes, kMaximumBloomFilterBytes] instead of requiring a power of two (keeping the writer-side Init(uint32_t num_bytes) unchanged).
    2. Update cpp/src/parquet/bloom_filter_test.cc to test initializing/deserializing and querying a 96-byte (3-block) Bloom filter, while still rejecting sizes that aren't multiples of 32 bytes.

    Does this approach look good? If so, could you please assign this issue to me?

    Hi @ansh0014 , thanks for your interest in this issue, do you mind to review #55825, sorry I didn't link the PR to this issue.

  3. ansh0014 commented on Nov 30, 2026

    @ansh0014

    Hi! @raulcd I traced this in the C++ Parquet Bloom filter implementation and wanted to confirm the fix before opening a PR.
    In cpp/src/parquet/bloom_filter.cc, BlockSplitBloomFilter::Init(const uint8_t* bitset, uint32_t num_bytes) currently rejects any size that isn't a power of two ((num_bytes & (num_bytes - 1)) != 0), throwing "Given length of bitset is illegal".
    However, FindHash, InsertHashImpl, and NumBlocks() already use fastrange (((hash >> 32) * NumBlocks()) >> 32), which works for any valid number of 32-byte blocks (num_bytes % kBytesPerFilterBlock == 0), not just powers of two.
    My plan is to:

    1. Update BlockSplitBloomFilter::Init(const uint8_t* bitset, uint32_t num_bytes) to require num_bytes % kBytesPerFilterBlock == 0 within [kMinimumBloomFilterBytes, kMaximumBloomFilterBytes] instead of requiring a power of two (keeping the writer-side Init(uint32_t num_bytes) unchanged).
    2. Update cpp/src/parquet/bloom_filter_test.cc to test initializing/deserializing and querying a 96-byte (3-block) Bloom filter, while still rejecting sizes that aren't multiples of 32 bytes.

    Does this approach look good? If so, could you please assign this issue to me?

    Hi @ansh0014 , thanks for your interest in this issue, do you mind to review #55825, sorry I didn't link the PR to this issue.

    Sure, I took a look at #55825!

    The change in BlockSplitBloomFilter::Init(const uint8_t*, uint32_t) to check num_bytes % kBytesPerFilterBlock == 0 makes total sense since FindHash and InsertHashImpl already use fastrange with NumBlocks(). Also great catch updating NumFoldsForTargetFpp and Fold to handle non-power-of-two even block counts (like 6 -> 3 blocks), and the parquet-go 96-byte test + 6-block fold test cover it well.

    Everything in the PR looks solid to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions