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

Refine FixedSizeListBuilder #1988

Merged
merged 3 commits into from
Jul 5, 2022

Conversation

HaoYang670
Copy link
Contributor

@HaoYang670 HaoYang670 commented Jul 2, 2022

Signed-off-by: remzi 13716567376yh@gmail.com

Which issue does this PR close?

None.
Fixed some minor things when I read the code of FixedSizeListBuilder.

What changes are included in this PR?

Commented in the PR.

Are there any user-facing changes?

Yes. Renaming length to value_length which I think is minor.

Signed-off-by: remzi <13716567376yh@gmail.com>
@github-actions github-actions bot added the arrow Changes to the arrow crate label Jul 2, 2022
@@ -230,22 +219,20 @@ mod tests {
}

#[test]
fn test_fixed_size_binary_builder() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Move this test to fixed_size_binary_builder.rs

pub fn new(values_builder: T, length: i32) -> Self {
/// Creates a new [`FixedSizeListBuilder`] from a given values array builder
/// `value_length` is the number of values within each array
pub fn new(values_builder: T, value_length: i32) -> Self {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

value_length is less confusing

#[derive(Debug)]
pub struct FixedSizeListBuilder<T: ArrayBuilder> {
bitmap_builder: BooleanBufferBuilder,
values_builder: T,
len: usize,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove this field because self.len is always equal to self.bitmap_builder.len

// check that values_data length is multiple of len if we have data
if len != 0 {
assert!(
values_data.len() / len == self.list_len as usize,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was a bug when values_data.len() / len == self.list_len but values_data.len() % len != 0.
Checking values_data.len() == len * self.list_len is more straightforward.

#[should_panic(
expected = "Length of the child array (10) must be the multiple of the value length (3) and the array length (3)."
)]
fn test_fixed_size_list_array_builder_fail() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test the checking in finish

/// `capacity` is the number of items to pre-allocate space for in this builder
pub fn with_capacity(values_builder: T, length: i32, capacity: usize) -> Self {
let mut offsets_builder = Int32BufferBuilder::new(capacity + 1);
offsets_builder.append(0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is unused.

Signed-off-by: remzi <13716567376yh@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented Jul 4, 2022

Codecov Report

Merging #1988 (0136cc3) into master (7ae97c9) will increase coverage by 0.00%.
The diff coverage is 93.93%.

@@           Coverage Diff           @@
##           master    #1988   +/-   ##
=======================================
  Coverage   83.58%   83.58%           
=======================================
  Files         222      222           
  Lines       57495    57557   +62     
=======================================
+ Hits        48056    48109   +53     
- Misses       9439     9448    +9     
Impacted Files Coverage Δ
arrow/src/array/builder/fixed_size_list_builder.rs 89.00% <90.47%> (+1.38%) ⬆️
...row/src/array/builder/fixed_size_binary_builder.rs 64.10% <100.00%> (+15.95%) ⬆️
arrow/src/array/array_map.rs 83.07% <0.00%> (-1.74%) ⬇️
arrow/src/array/array_decimal.rs 92.88% <0.00%> (-0.79%) ⬇️
arrow/src/array/array_union.rs 90.14% <0.00%> (-0.78%) ⬇️
...row/src/array/builder/string_dictionary_builder.rs 90.64% <0.00%> (-0.72%) ⬇️
arrow/src/datatypes/datatype.rs 65.42% <0.00%> (-0.38%) ⬇️
arrow/src/array/array.rs 92.05% <0.00%> (-0.16%) ⬇️
arrow/src/json/reader.rs 84.58% <0.00%> (ø)
arrow/src/array/array_string.rs 97.76% <0.00%> (ø)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7ae97c9...0136cc3. Read the comment docs.

Signed-off-by: remzi <13716567376yh@gmail.com>
Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

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

LGTM, thank you 👍

@tustvold tustvold merged commit 2309157 into apache:master Jul 5, 2022
@HaoYang670 HaoYang670 deleted the clean_up_fixedSizeListBuilder branch July 5, 2022 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants