Skip to content

Commit

Permalink
ARROW-10042: [Rust] Only compare BufferData's data for equality
Browse files Browse the repository at this point in the history
And disregard differences in capacity.
  • Loading branch information
carols10cents committed Nov 4, 2020
1 parent 913cd76 commit 6c82060
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 13 additions & 4 deletions rust/arrow/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down Expand Up @@ -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) };
Expand Down
2 changes: 0 additions & 2 deletions rust/parquet/src/arrow/arrow_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8> = (0..SMALL_SIZE as u8).collect();
let many_vecs: Vec<_> = std::iter::repeat(one_vec).take(SMALL_SIZE).collect();
Expand All @@ -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<u8> = (0..SMALL_SIZE as u8).collect();
let many_vecs: Vec<_> = std::iter::repeat(one_vec).take(SMALL_SIZE).collect();
Expand Down

0 comments on commit 6c82060

Please sign in to comment.