Skip to content

Commit

Permalink
Use BitChunks in equal_bits (apache#2186)
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Jul 27, 2022
1 parent d10d962 commit 4028ba0
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions arrow/src/array/equal/utils.rs
Expand Up @@ -17,7 +17,7 @@

use crate::array::{data::count_nulls, ArrayData};
use crate::datatypes::DataType;
use crate::util::bit_util;
use crate::util::bit_chunk_iterator::BitChunks;

// whether bits along the positions are equal
// `lhs_start`, `rhs_start` and `len` are _measured in bits_.
Expand All @@ -29,10 +29,16 @@ pub(super) fn equal_bits(
rhs_start: usize,
len: usize,
) -> bool {
(0..len).all(|i| {
bit_util::get_bit(lhs_values, lhs_start + i)
== bit_util::get_bit(rhs_values, rhs_start + i)
})
let lhs = BitChunks::new(lhs_values, lhs_start, len);
let rhs = BitChunks::new(rhs_values, rhs_start, len);

for (a, b) in lhs.iter().zip(rhs.iter()) {
if a != b {
return false;
}
}

lhs.remainder_bits() == rhs.remainder_bits()
}

#[inline]
Expand Down

0 comments on commit 4028ba0

Please sign in to comment.