Skip to content
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
8 changes: 6 additions & 2 deletions arrow-array/src/array/fixed_size_binary_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ impl FixedSizeBinaryArray {
/// * `size < 0`
/// * `size * len` would overflow `usize`
pub fn new_null(size: i32, len: usize) -> Self {
let capacity = size.to_usize().unwrap().checked_mul(len).unwrap();
let capacity_in_bytes = size.to_usize().unwrap().checked_mul(len).unwrap();
Self {
data_type: DataType::FixedSizeBinary(size),
value_data: MutableBuffer::new(capacity).into(),
value_data: MutableBuffer::new_null(capacity_in_bytes * 8).into(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does the 8 come from?

Copy link
Contributor

Choose a reason for hiding this comment

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

MutableBuffer::new_null is in bits.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
value_data: MutableBuffer::new_null(capacity_in_bytes * 8).into(),
// MutableBuffer::new_null is in bits.
value_data: MutableBuffer::new_null(capacity_in_bytes * 8).into(),

nulls: Some(NullBuffer::new_null(len)),
value_length: size,
len,
Expand Down Expand Up @@ -983,6 +983,10 @@ mod tests {
let nulls = NullBuffer::new_null(5);
FixedSizeBinaryArray::new(2, buffer.clone(), Some(nulls));

let null_array = FixedSizeBinaryArray::new_null(4, 3);
assert_eq!(null_array.len(), 3);
assert_eq!(null_array.values().len(), 12);
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 reported 0 before this change.


let a = FixedSizeBinaryArray::new(3, buffer.clone(), None);
assert_eq!(a.len(), 3);

Expand Down
Loading