Skip to content

Commit 08dee63

Browse files
authored
[minor] Name Magic Number "8" in FixedSizeBinaryArray::new_null (#8914)
# Which issue does this PR close? - Follow-up on #8901 # Rationale for this change It's non-obvious why the number "8" appears here. # What changes are included in this PR? Name the number such that it's more obvious that this is a conversion from bytes to bits. @alamb I can also include the [suggested comment](#8901 (comment)) if you prefer it. I thought the constant may have a lesser risk of becoming outdated without being noticed when changes to `MutableBuffer::new_null` happen. # Are these changes tested? - No behavior changes # Are there any user-facing changes? - No
1 parent 7e637a7 commit 08dee63

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arrow-array/src/array/fixed_size_binary_array.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,11 @@ impl FixedSizeBinaryArray {
119119
/// * `size < 0`
120120
/// * `size * len` would overflow `usize`
121121
pub fn new_null(size: i32, len: usize) -> Self {
122+
const BITS_IN_A_BYTE: usize = 8;
122123
let capacity_in_bytes = size.to_usize().unwrap().checked_mul(len).unwrap();
123124
Self {
124125
data_type: DataType::FixedSizeBinary(size),
125-
value_data: MutableBuffer::new_null(capacity_in_bytes * 8).into(),
126+
value_data: MutableBuffer::new_null(capacity_in_bytes * BITS_IN_A_BYTE).into(),
126127
nulls: Some(NullBuffer::new_null(len)),
127128
value_length: size,
128129
len,

0 commit comments

Comments
 (0)