From 555cdfd9a74e15400c5a4d8c550fb7e614838eb1 Mon Sep 17 00:00:00 2001 From: Liang-Chi Hsieh Date: Sat, 11 May 2024 11:33:32 -0700 Subject: [PATCH] Add round_trip check --- arrow-array/src/ffi.rs | 2 ++ arrow-data/src/equal/variable_size.rs | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/arrow-array/src/ffi.rs b/arrow-array/src/ffi.rs index 311b5b83e98e..4ca95f22888a 100644 --- a/arrow-array/src/ffi.rs +++ b/arrow-array/src/ffi.rs @@ -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(()) } } diff --git a/arrow-data/src/equal/variable_size.rs b/arrow-data/src/equal/variable_size.rs index 92f00818b4a0..d6e8e6a95481 100644 --- a/arrow-data/src/equal/variable_size.rs +++ b/arrow-data/src/equal/variable_size.rs @@ -32,17 +32,18 @@ fn offset_value_equal( ) -> 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(