From 6c820602952f8f9c602c4351d09e7a7844400439 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Wed, 4 Nov 2020 10:32:38 -0500 Subject: [PATCH] ARROW-10042: [Rust] Only compare BufferData's data for equality And disregard differences in capacity. --- rust/arrow/src/buffer.rs | 17 +++++++++++++---- rust/parquet/src/arrow/arrow_writer.rs | 2 -- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/rust/arrow/src/buffer.rs b/rust/arrow/src/buffer.rs index 3512ae3426182..44e0840bf4976 100644 --- a/rust/arrow/src/buffer.rs +++ b/rust/arrow/src/buffer.rs @@ -70,10 +70,6 @@ struct BufferData { impl PartialEq for BufferData { fn eq(&self, other: &BufferData) -> bool { - if self.capacity != other.capacity { - return false; - } - self.data() == other.data() } } @@ -855,6 +851,19 @@ mod tests { assert_ne!(buf1, buf2); } + #[test] + fn buffer_data_equality_checks_data_not_capacity() { + let buf1 = Buffer::from(&[0, 1, 2, 3, 4]); + + let mut buf2 = MutableBuffer::new(65); + buf2.write_all(&[0, 1, 2, 3, 4]) + .expect("write should be OK"); + + let buf2 = buf2.freeze(); + + assert_eq!(buf1, buf2); + } + #[test] fn test_from_raw_parts() { let buf = unsafe { Buffer::from_raw_parts(null_mut(), 0, 0) }; diff --git a/rust/parquet/src/arrow/arrow_writer.rs b/rust/parquet/src/arrow/arrow_writer.rs index de8bc7c1d4626..5e9192f0d1aba 100644 --- a/rust/parquet/src/arrow/arrow_writer.rs +++ b/rust/parquet/src/arrow/arrow_writer.rs @@ -1202,7 +1202,6 @@ mod tests { } #[test] - #[ignore] // Binary support isn't correct yet - buffers don't match fn binary_single_column() { let one_vec: Vec = (0..SMALL_SIZE as u8).collect(); let many_vecs: Vec<_> = std::iter::repeat(one_vec).take(SMALL_SIZE).collect(); @@ -1213,7 +1212,6 @@ mod tests { } #[test] - #[ignore] // Large binary support isn't correct yet - buffers don't match fn large_binary_single_column() { let one_vec: Vec = (0..SMALL_SIZE as u8).collect(); let many_vecs: Vec<_> = std::iter::repeat(one_vec).take(SMALL_SIZE).collect();