This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 08dee63f83 [minor] Name Magic Number "8" in
`FixedSizeBinaryArray::new_null` (#8914)
08dee63f83 is described below
commit 08dee63f8333ad48485300fca74088c202c9b5b1
Author: Tobias Schwarzinger <[email protected]>
AuthorDate: Tue Nov 25 12:44:48 2025 +0100
[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](https://github.com/apache/arrow-rs/pull/8901#discussion_r2550603957)
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
---
arrow-array/src/array/fixed_size_binary_array.rs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arrow-array/src/array/fixed_size_binary_array.rs
b/arrow-array/src/array/fixed_size_binary_array.rs
index 95f47a423a..600ac50eb0 100644
--- a/arrow-array/src/array/fixed_size_binary_array.rs
+++ b/arrow-array/src/array/fixed_size_binary_array.rs
@@ -119,10 +119,11 @@ impl FixedSizeBinaryArray {
/// * `size < 0`
/// * `size * len` would overflow `usize`
pub fn new_null(size: i32, len: usize) -> Self {
+ const BITS_IN_A_BYTE: usize = 8;
let capacity_in_bytes =
size.to_usize().unwrap().checked_mul(len).unwrap();
Self {
data_type: DataType::FixedSizeBinary(size),
- value_data: MutableBuffer::new_null(capacity_in_bytes * 8).into(),
+ value_data: MutableBuffer::new_null(capacity_in_bytes *
BITS_IN_A_BYTE).into(),
nulls: Some(NullBuffer::new_null(len)),
value_length: size,
len,