Skip to content

PARQUET-2251 Avoid generating Bloomfilter when all pages of a column are encoded by dictionary in parquet v1 - #1033

Merged
gszadovszky merged 2 commits into
apache:masterfrom
yabola:avoid_bloomfilter
Feb 27, 2023
Merged

PARQUET-2251 Avoid generating Bloomfilter when all pages of a column are encoded by dictionary in parquet v1#1033
gszadovszky merged 2 commits into
apache:masterfrom
yabola:avoid_bloomfilter

Conversation

@yabola

@yabola yabola commented Feb 24, 2023

Copy link
Copy Markdown
Contributor

In parquet pageV1(Spark use parquet v1 default), even all pages of a column are encoded by dictionary, it will still generate BloomFilter. Actually it is unnecessary and it costs time and occupies storage. Parquet pageV2 doesn't have this problem.

@yabola

yabola commented Feb 24, 2023

Copy link
Copy Markdown
Contributor Author

@wgtmac @gszadovszky Please take a look, thank you~
And I will update PR to skip bloomfilter when all pages are encoded in dictionary (because there are already many wrong parquet v1 files generated)

@wgtmac wgtmac left a comment

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.

LGTM.

cc @gszadovszky

@Parameterized.Parameters(name = "Run {index}: parquet {1}")
public static Collection<Object[]> params() {
return Arrays.asList(
new Object[]{FILE_V1, "pageV1"},

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.

nit: the name is a little bit confusing. file format version is not same as data page version.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks, I modified the description

@yabola yabola changed the title PARQUET-2251 Avoid generating Bloomfilter when all pages of a column are encoded by dictionary in parquet pageV1 PARQUET-2251 Avoid generating Bloomfilter when all pages of a column are encoded by dictionary in parquet v1 Feb 24, 2023

@gszadovszky gszadovszky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, @yabola, @wgtmac.

@gszadovszky
gszadovszky merged commit 4e9e79c into apache:master Feb 27, 2023
@yabola

yabola commented Feb 27, 2023

Copy link
Copy Markdown
Contributor Author

@wgtmac @gszadovszky Thank you for your review and help

alamb added a commit to apache/arrow-rs that referenced this pull request Sep 9, 2026
…hose data pages are all dictionary encoded (#10963)

# Which issue does this PR close?

- Closes #10962.

# Rationale for this change

A column chunk whose data pages are all dictionary encoded carries its
exact set of distinct values in the dictionary page, so a bloom filter
for it adds nothing a reader cannot already get exactly, while every
value is still hashed into the filter during the write and the filter is
serialized after the chunk. parquet-java stopped writing these in
PARQUET-2251 (apache/parquet-java#1033, 1.13.0), so files from Spark,
Hive and Iceberg never have a bloom filter on a dictionary-only chunk,
and there was no way to get the same output from this crate. Details in
#10962.

# What changes are included in this PR?

- `WriterProperties::bloom_filter_for_dictionary_encoded_chunks` with
`WriterPropertiesBuilder::set_bloom_filter_for_dictionary_encoded_chunks`
and `DEFAULT_BLOOM_FILTER_FOR_DICTIONARY_ENCODED_CHUNKS = true`, so the
default output is unchanged.
- In `GenericColumnWriter::close`, when the option is `false`, the bloom
filter is dropped unless `encoding_stats` records at least one
`DATA_PAGE`/`DATA_PAGE_V2` whose encoding is not `PLAIN_DICTIONARY` or
`RLE_DICTIONARY`, the same test `ParquetFileWriter.writeColumnChunk`
applies in parquet-java. `flush_bloom_filter` is still called so the
encoder state is reset as before.

# Are these changes tested?

Yes, `test_bloom_filter_for_dictionary_encoded_chunks` writes a small
dictionary-friendly Int32 column across the dictionary on/off × option
on/off matrix and asserts a filter is present in every case except
dictionary on with the option off.

# Are there any user-facing changes?

One new writer property, opt-in, documented on the setter. No breaking
changes.

---------

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants