-
Notifications
You must be signed in to change notification settings - Fork 689
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
Implement dictionary support for reading ByteView from parquet #5973
Conversation
cef542d
to
e1f53df
Compare
e1f53df
to
ed0e34a
Compare
I rebased this branch so it only had the changes to support dictionary reading |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @XiangpengHao -- this looks very clever 👌
I wonder if there is some way this code should be tested? Or will be be tested as part of a larger end to end parquet reading exercise later?
} | ||
|
||
// Check if the last few buffer of `output`` are the same as the `dict` buffer | ||
// This is to avoid creating a new buffers if the same dictionary is used for multiple `read` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a clever optimization
}; | ||
|
||
self.decoder.read(len, |keys| { | ||
for k in keys { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know for sure k
are valid dictionary indices (aka since this is from untrusted input, do we have to verify that k is within the bound of the dictionary)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The input is untrusted, but I think we can do very little to make it safer, e.g., if the view is maliciously crafted we can easily run into memory issues due to too large offset or invalid buffer idx.
But I agree that having this early check is useful, if it doesn't make the code significantly slower. I added the check here, will come back to this when I file the PR to optimize the performance.
The code to enable and test dictionary encoding is here: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me -- thanks @XiangpengHao
Which issue does this PR close?
Part of #5904 , sequel to #5968 and #5970 and #5972
This PR is not ready to review until the above PRs are merged.Rationale for this change
Implement dictionary encoding support for reading ByteView from parquet.
To show that reading ByteViewArray is faster than reading ByteArray:
We should get something like (~3x faster than ByteArray, many times faster than current implementation):
This is expected as the new implementation never copies data; it tries its best to reuse the buffer from the parquet decoder.
What changes are included in this PR?
This PR is (even) less straightforward than the previous ones, mostly because we need to map the dictionary view buffer indexes to the output view buffer indexes. Please let me know if any point of the code is too difficult to maintain!
Are there any user-facing changes?