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

PARQUET-2021: Add description of RLE/bit-packed encoder #170

Closed
wants to merge 7 commits into from
Closed

PARQUET-2021: Add description of RLE/bit-packed encoder #170

wants to merge 7 commits into from

Conversation

jorgecarleitao
Copy link
Member

@jorgecarleitao jorgecarleitao commented Apr 2, 2021

This PR adds a new page with a detailed description of the RLE-bipacked hybrid encoder.

I had to implement this recently from scratch and found the current documentation a bit cryptic. As such, decided to spend some time to do a write up of how the encoder works in detail, which hopefully helps at reducing the barrier to implement this non-trivial encoding strategy.

NOTE: this is the first time I am contributing to parquet and have basic understanding of the format. I was hoping to have someone experienced in this encoding to review this.

I only described the decoding part. The encoding can be done in a follow-up PR.

The todo below will be fulfilled if there is consensus that this is useful.

Jira

This commit adds a new page with a detailed description of the RLE-bipacked hybrid encoder.
rle-bitpacked.md Outdated Show resolved Hide resolved
@pitrou
Copy link
Member

pitrou commented Apr 3, 2021

Can you word-wrap lines to ~80 characters? That will make reviewing a bit easier (and editing later as well).

@jorgecarleitao
Copy link
Member Author

Can you word-wrap lines to ~80 characters? That will make reviewing a bit easier (and editing later as well).

Good point. Sorry about that. I've now wrapped around 80 characters.

@pitrou pitrou changed the title WIP: [Docs] Add description of RLE-bipacked encoder WIP: [Docs] Add description of RLE/bit-packed encoder Apr 3, 2021
Copy link
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

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

I agree it's a good idea to explain this in more detail, but I find the explanations a bit confusing. See comments below.

rle-bitpacked.md Outdated Show resolved Hide resolved
rle-bitpacked.md Outdated Show resolved Hide resolved
rle-bitpacked.md Outdated Show resolved Hide resolved
rle-bitpacked.md Outdated Show resolved Hide resolved
rle-bitpacked.md Outdated Show resolved Hide resolved
rle-bitpacked.md Outdated Show resolved Hide resolved
rle-bitpacked.md Outdated Show resolved Hide resolved
rle-bitpacked.md Outdated Show resolved Hide resolved
rle-bitpacked.md Outdated Show resolved Hide resolved
rle-bitpacked.md Outdated
and thus the next run is RLE-encoded. We compute the number of repetitions
via `repetitions = h1 >> 1 = 8`. The body size is `body_length = ceil(bit_width, 8) = 1`,
which is consistent with `length = 5 = 1 + 2 + 1 + 1`. Since the body is
`0b00000001 = 1`, we conclude that this run is the number 1 repeated 8 times,
Copy link
Member

Choose a reason for hiding this comment

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

Is it? h1 >> 1 is the number of repetitions divided by 8, according to the grammar.

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't only the bitpacked that is a multiple of 8?

rle-run := <rle-header> <repeated-value>
rle-header := varint-encode( (rle-run-len) << 1)
rle-run-len := *see 3 below*

@jorgecarleitao
Copy link
Member Author

I have not forgotten this. I am just making sure that this logic is right by performing different round-trips between Rust's parquet, parquet2 and pyarrow, with some control over the encodings.

@jorgecarleitao jorgecarleitao changed the title WIP: [Docs] Add description of RLE/bit-packed encoder PARQUET-2021: Add description of RLE/bit-packed encoder Apr 10, 2021
Addressed comments.

Also removed the length of the stream; the length of the stream being declared in the beginning
of the stream is V1 Page-specific; V2 pages use a different mechanism to declare the length of the stream.
@jorgecarleitao
Copy link
Member Author

Ok, I have resolved most comments except two that I have questions. I have also removed the "length of the stream" part, as that is v1 page-specific; v2 pages have a different way of specifying the length of the stream. I think we should leave that to a description of pages and what their buffers contain.

@jorgecarleitao jorgecarleitao marked this pull request as draft April 12, 2021 15:55
@jorgecarleitao jorgecarleitao marked this pull request as ready for review April 14, 2021 12:24
@jorgecarleitao
Copy link
Member Author

@pitrou @julienledem , gentle ping :)

@pitrou
Copy link
Member

pitrou commented May 12, 2021

Sorry @jorgecarleitao , I'll try to take a look in the next weeks.

@julienledem
Copy link
Member

Hey @jorgecarleitao this is great work. Sorry I didn't see your PR

@julienledem
Copy link
Member

@isnotinvain does it look good to you?

@julienledem
Copy link
Member

also @toddlipcon designed this I believe

This pull request was closed.
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.

None yet

4 participants