You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/01/15 11:12:46 UTC

[GitHub] [arrow] mqy commented on a change in pull request #9193: ARROW-11239: [Rust] Some unit test failures

mqy commented on a change in pull request #9193:
URL: https://github.com/apache/arrow/pull/9193#discussion_r558238739



##########
File path: rust/arrow/src/array/data.rs
##########
@@ -446,10 +446,37 @@ mod tests {
     }
 
     #[test]
-    fn test_equality() {
-        let int_data = ArrayData::builder(DataType::Int32).build();
-        let float_data = ArrayData::builder(DataType::Float32).build();
-        assert_ne!(int_data, float_data);
+    //#[should_panic(expected = "index out of bounds: the len is 0 but the index is 0")]
+    fn test_slice_equality() {
+        let mut bit_v: [u8; 1] = [0; 1];
+        bit_util::set_bit(&mut bit_v, 1);
+        let data = ArrayData::builder(DataType::Int32)
+            .len(2)
+            .null_bit_buffer(Buffer::from(bit_v))
+            .build();
+        let data_slice = data.slice(1, 1);
+
+        let mut bit_v: [u8; 1] = [0; 1];
+        bit_util::set_bit(&mut bit_v, 0);
+        let arc_data = ArrayData::builder(DataType::Int32)
+            .len(1)
+            .null_bit_buffer(Buffer::from(bit_v))
+            .build();
+        let expected = arc_data.as_ref();
+
+        // thread 'array::data::tests::test_slice_equality' panicked at 'index out of bounds:
+        // the len is 0 but the index is 0', arrow/src/array/equal/primitive.rs:36:23
+        assert_eq!(&data_slice, expected);
+
+        // I've got some background messages from the following PRs:
+        // - https://github.com/apache/arrow/pull/8200
+        // - https://github.com/apache/arrow/pull/8541
+        // - https://github.com/apache/arrow/pull/8590
+        //
+        // My thoughts:
+        // 1. don't clone all data, because it may be great waste when the length is far
+        //    smaller than the total data length (think about 1 vs 10k).
+        // 2. construct buffers from logic data.

Review comment:
       This is not `zero-copy` any more, and the whole behavior is no longer match the semantics of `slicing` -- sounds like `copy arrange`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org