-
Notifications
You must be signed in to change notification settings - Fork 784
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
Refine FixedSizeListBuilder
#1988
Conversation
Signed-off-by: remzi <[email protected]>
@@ -230,22 +219,20 @@ mod tests { | |||
} | |||
|
|||
#[test] | |||
fn test_fixed_size_binary_builder() { |
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.
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 { |
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.
value_length
is less confusing
#[derive(Debug)] | ||
pub struct FixedSizeListBuilder<T: ArrayBuilder> { | ||
bitmap_builder: BooleanBufferBuilder, | ||
values_builder: T, | ||
len: usize, |
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.
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, |
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.
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() { |
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.
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); |
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.
This is unused.
Signed-off-by: remzi <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #1988 +/- ##
=======================================
Coverage 83.58% 83.58%
=======================================
Files 222 222
Lines 57495 57557 +62
=======================================
+ Hits 48056 48109 +53
- Misses 9439 9448 +9
Continue to review full report at Codecov.
|
Signed-off-by: remzi <[email protected]>
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.
LGTM, thank you 👍
Signed-off-by: remzi [email protected]
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
tovalue_length
which I think is minor.