Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Support parquet RLE decoding for booleans #3477

Conversation

desmondcheongzx
Copy link
Contributor

#3329 shows that we do not currently support reading boolean values from parquet files when they are RLE-encoded.

This PR adds support for this.

@github-actions github-actions bot added the enhancement New feature or request label Dec 3, 2024
Copy link

codspeed-hq bot commented Dec 3, 2024

CodSpeed Performance Report

Merging #3477 will not alter performance

Comparing desmondcheongzx:parquet-boolean-rle-decoding (5c447f8) with main (de4fe50)

Summary

✅ 17 untouched benchmarks

Copy link

codecov bot commented Dec 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.35%. Comparing base (573f76f) to head (5c447f8).
Report is 25 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3477      +/-   ##
==========================================
- Coverage   77.49%   77.35%   -0.15%     
==========================================
  Files         687      696       +9     
  Lines       84483    84851     +368     
==========================================
+ Hits        65474    65637     +163     
- Misses      19009    19214     +205     

see 117 files with indirect coverage changes


impl Decodable for u32 {
fn from_le_bytes(pack: &[u8]) -> Self {
let mut bytes = [0u8; std::mem::size_of::<u32>()];
Copy link
Member

Choose a reason for hiding this comment

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

why do you have to do this memcpy thing?
and not just do u32::from_le_bytes(pack)

Copy link
Contributor Author

@desmondcheongzx desmondcheongzx Dec 4, 2024

Choose a reason for hiding this comment

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

Ah turns out that this was because from_le_bytes expects a fixed size array instead of a slice of bytes.

We can do

let bytes = pack.try_into().expect("Parquet should always encode u32 values");
let value = u32::from_le_bytes(bytes);

which will do a runtime check that the slice is [u8; 4], which would still be faster than copying the bytes over.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed offline, unfortunately in some cases pack contains less than 4 bytes (test_invalid_utf8_parquet_reading contains an example) so we can't do this.. reverting to the state prior that does byte-wise copying.

src/arrow2/src/io/parquet/read/deserialize/binary/basic.rs Outdated Show resolved Hide resolved
@desmondcheongzx desmondcheongzx enabled auto-merge (squash) December 4, 2024 19:40
@desmondcheongzx desmondcheongzx linked an issue Dec 4, 2024 that may be closed by this pull request
@desmondcheongzx desmondcheongzx merged commit d1d0fab into Eventual-Inc:main Dec 4, 2024
40 checks passed
@desmondcheongzx desmondcheongzx deleted the parquet-boolean-rle-decoding branch December 4, 2024 22:06
raunakab pushed a commit that referenced this pull request Dec 4, 2024
#3329 shows that we do not
currently support reading boolean values from parquet files when they
are RLE-encoded.

This PR adds support for this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parquet reader support for RLE-encoded boolean columns
2 participants