-
Notifications
You must be signed in to change notification settings - Fork 853
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
Respect Page Size Limits in ArrowWriter (#2853) #2890
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -201,6 +201,7 @@ impl<T: DataType> ColumnValueEncoder for ColumnValueEncoderImpl<T> { | |
} | ||
|
||
fn write_gather(&mut self, values: &Self::Values, indices: &[usize]) -> Result<()> { | ||
self.num_values += indices.len(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the fix for #2853 |
||
let slice: Vec<_> = indices.iter().map(|idx| values[*idx].clone()).collect(); | ||
self.write_slice(&slice) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1825,7 +1825,7 @@ mod tests { | |
let page_writer = Box::new(SerializedPageWriter::new(&mut writer)); | ||
let props = Arc::new( | ||
WriterProperties::builder() | ||
.set_data_pagesize_limit(15) // actually each page will have size 15-18 bytes | ||
.set_data_pagesize_limit(10) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand this change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The RLE size estimation has changed, and so this test needed updating |
||
.set_write_batch_size(3) // write 3 values at a time | ||
.build(), | ||
); | ||
|
@@ -1846,16 +1846,14 @@ mod tests { | |
); | ||
let mut res = Vec::new(); | ||
while let Some(page) = page_reader.get_next_page().unwrap() { | ||
res.push((page.page_type(), page.num_values())); | ||
res.push((page.page_type(), page.num_values(), page.buffer().len())); | ||
} | ||
assert_eq!( | ||
res, | ||
vec![ | ||
(PageType::DICTIONARY_PAGE, 10), | ||
(PageType::DATA_PAGE, 3), | ||
(PageType::DATA_PAGE, 3), | ||
(PageType::DATA_PAGE, 3), | ||
(PageType::DATA_PAGE, 1) | ||
(PageType::DICTIONARY_PAGE, 10, 40), | ||
(PageType::DATA_PAGE, 9, 10), | ||
(PageType::DATA_PAGE, 1, 3), | ||
] | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -888,7 +888,7 @@ mod tests { | |
// DICTIONARY | ||
// NOTE: The final size is almost the same because the dictionary entries are | ||
// preserved after encoded values have been written. | ||
run_test::<Int32Type>(Encoding::RLE_DICTIONARY, -1, &[123, 1024], 11, 68, 66); | ||
run_test::<Int32Type>(Encoding::RLE_DICTIONARY, -1, &[123, 1024], 0, 2, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you explain these changes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The RLE size estimation was updated as part of #2889 |
||
|
||
// DELTA_BINARY_PACKED | ||
run_test::<Int32Type>(Encoding::DELTA_BINARY_PACKED, -1, &[123; 1024], 0, 35, 0); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,13 +38,8 @@ pub fn max_buffer_size( | |
) -> usize { | ||
let bit_width = num_required_bits(max_level as u64); | ||
match encoding { | ||
Encoding::RLE => { | ||
RleEncoder::max_buffer_size(bit_width, num_buffered_values) | ||
+ RleEncoder::min_buffer_size(bit_width) | ||
} | ||
Encoding::BIT_PACKED => { | ||
ceil((num_buffered_values * bit_width as usize) as i64, 8) as usize | ||
} | ||
Encoding::RLE => RleEncoder::max_buffer_size(bit_width, num_buffered_values), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this different than the other estimated sizes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What other estimated sizes, I think I updated them all? |
||
Encoding::BIT_PACKED => ceil(num_buffered_values * bit_width as usize, 8), | ||
_ => panic!("Unsupported encoding type {}", encoding), | ||
} | ||
} | ||
|
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.
Without this, we would only ever have a single dictionary encoded page per column chunk. This is the other half of the fix in #2854
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.
maybe it is worth a comment
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 confusion was that we tracked num_values in two places, that is now gone so I'm not sure what to write in a comment...