tustvold commented on code in PR #2231:
URL: https://github.com/apache/arrow-rs/pull/2231#discussion_r933992108
##########
parquet/src/encodings/levels.rs:
##########
@@ -65,32 +65,32 @@ impl LevelEncoder {
/// Used to encode levels for Data Page v1.
///
/// Panics, if encoding is not supported.
- pub fn v1(encoding: Encoding, max_level: i16, byte_buffer: Vec<u8>) ->
Self {
+ pub fn v1(encoding: Encoding, max_level: i16, capacity: usize) -> Self {
+ let capacity_bytes = max_buffer_size(encoding, max_level, capacity);
+ let mut buffer = Vec::with_capacity(capacity_bytes);
let bit_width = num_required_bits(max_level as u64);
match encoding {
- Encoding::RLE => LevelEncoder::Rle(RleEncoder::new_from_buf(
- bit_width,
- byte_buffer,
- mem::size_of::<i32>(),
- )),
+ Encoding::RLE => {
+ buffer.extend_from_slice(&[0; 8]);
Review Comment:
Yes, although it occurs to me that this allocated 8 bytes instead of 4...
Something isn't right here 🤔
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]