Skip to content

Commit

Permalink
Add round_trip check
Browse files Browse the repository at this point in the history
  • Loading branch information
viirya committed May 11, 2024
1 parent 0b928a6 commit 555cdfd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions arrow-array/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,8 @@ mod tests_from_ffi {
assert_eq!(offset_buf_len, 4);
assert_eq!(data_buf_len, 0);

test_round_trip(&imported_array.consume()?);

Ok(())
}
}
21 changes: 11 additions & 10 deletions arrow-data/src/equal/variable_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ fn offset_value_equal<T: ArrowNativeType + Integer>(
) -> bool {
let lhs_start = lhs_offsets[lhs_pos].as_usize();
let rhs_start = rhs_offsets[rhs_pos].as_usize();
let lhs_len = lhs_offsets[lhs_pos + len] - lhs_offsets[lhs_pos];
let rhs_len = rhs_offsets[rhs_pos + len] - rhs_offsets[rhs_pos];
let lhs_len = (lhs_offsets[lhs_pos + len] - lhs_offsets[lhs_pos])
.to_usize()
.unwrap();
let rhs_len = (rhs_offsets[rhs_pos + len] - rhs_offsets[rhs_pos])
.to_usize()
.unwrap();

lhs_len == rhs_len
&& equal_len(
lhs_values,
rhs_values,
lhs_start,
rhs_start,
lhs_len.to_usize().unwrap(),
)
if lhs_len == 0 && rhs_len == 0 {
return true;
}

lhs_len == rhs_len && equal_len(lhs_values, rhs_values, lhs_start, rhs_start, lhs_len)
}

pub(super) fn variable_sized_equal<T: ArrowNativeType + Integer>(
Expand Down

0 comments on commit 555cdfd

Please sign in to comment.