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

refactor(rust): Simplify compressed_chunk_size calculation and leave comments to explain for rle encode #14634

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ fn bitpacked_encode_u32<W: Write, I: Iterator<Item = u32>>(
let remainder = length - chunks * U32_BLOCK_LEN;
let mut buffer = [0u32; U32_BLOCK_LEN];

let compressed_chunk_size = ceil8(U32_BLOCK_LEN * num_bits);
// simplified from ceil8(U32_BLOCK_LEN * num_bits) since U32_BLOCK_LEN = 32
let compressed_chunk_size = 4 * num_bits;

for _ in 0..chunks {
iterator
Expand All @@ -58,6 +59,9 @@ fn bitpacked_encode_u32<W: Write, I: Iterator<Item = u32>>(
// Must be careful here to ensure we write a multiple of `num_bits`
// (the bit width) to align with the spec. Some readers also rely on
// this - see https://github.com/pola-rs/polars/pull/13883.

// this is ceil8(remainder * num_bits), but we ensure the output is a
// multiple of num_bits by rewriting it as ceil8(remainder) * num_bits
let compressed_remainder_size = ceil8(remainder) * num_bits;
iterator
.by_ref()
Expand Down
Loading