Skip to content

Commit

Permalink
Fix offset handling in boolean_equal (#2184) (#2187)
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold authored Jul 27, 2022
1 parent d10d962 commit e096ec7
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions arrow/src/array/equal/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ pub(super) fn boolean_equal(

if lhs_null_count == 0 && rhs_null_count == 0 {
// Optimize performance for starting offset at u8 boundary.
if lhs_start % 8 == 0 && rhs_start % 8 == 0 {
if lhs_start % 8 == 0
&& rhs_start % 8 == 0
&& lhs.offset() % 8 == 0
&& rhs.offset() % 8 == 0
{
let quot = len / 8;
if quot > 0
&& !equal_len(
lhs_values,
rhs_values,
lhs_start / 8 + lhs.offset(),
rhs_start / 8 + rhs.offset(),
lhs_start / 8 + lhs.offset() / 8,
rhs_start / 8 + rhs.offset() / 8,
quot,
)
{
Expand Down Expand Up @@ -88,3 +92,21 @@ pub(super) fn boolean_equal(
})
}
}

#[cfg(test)]
mod tests {
use crate::array::{Array, BooleanArray};

#[test]
fn test_boolean_slice() {
let array = BooleanArray::from(vec![true; 32]);
let slice = array.slice(4, 12);
assert_eq!(slice.data(), slice.data());

let slice = array.slice(8, 12);
assert_eq!(slice.data(), slice.data());

let slice = array.slice(8, 24);
assert_eq!(slice.data(), slice.data());
}
}

0 comments on commit e096ec7

Please sign in to comment.