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 2020/12/06 12:02:49 UTC

[GitHub] [arrow] alamb commented on a change in pull request #8850: ARROW-10591: [Rust] Add support for StructArray to MutableArrayData

alamb commented on a change in pull request #8850:
URL: https://github.com/apache/arrow/pull/8850#discussion_r537022972



##########
File path: rust/arrow/src/array/transform/mod.rs
##########
@@ -285,10 +288,16 @@ impl<'a> MutableArrayData<'a> {
     /// `use_nulls` is a flag used to optimize insertions. It should be `false` if the only source of nulls
     /// are the arrays themselves and `true` if the user plans to call [MutableArrayData::extend_nulls].
     /// In other words, if `use_nulls` is `false`, calling [MutableArrayData::extend_nulls] should not be used.
-    pub fn new(arrays: Vec<&'a ArrayData>, use_nulls: bool, capacity: usize) -> Self {
+    pub fn new(arrays: Vec<&'a ArrayData>, mut use_nulls: bool, capacity: usize) -> Self {

Review comment:
       https://github.com/apache/arrow/pull/8848 appears to contain this same code -- though github seems to think merging will not be a problem

##########
File path: rust/arrow/src/array/transform/mod.rs
##########
@@ -687,4 +728,118 @@ mod tests {
         let expected = Int16Array::from(vec![Some(1), None]);
         assert_eq!(result.keys(), &expected);
     }
+
+    #[test]
+    fn test_struct() {
+        let strings: ArrayRef = Arc::new(StringArray::from(vec![
+            Some("joe"),
+            None,
+            None,
+            Some("mark"),
+            Some("doe"),
+        ]));
+        let ints: ArrayRef = Arc::new(Int32Array::from(vec![
+            Some(1),
+            Some(2),
+            Some(3),
+            Some(4),
+            Some(5),
+        ]));
+
+        let array =
+            StructArray::try_from(vec![("f1", strings.clone()), ("f2", ints.clone())])
+                .unwrap()
+                .data();
+        let arrays = vec![array.as_ref()];
+        let mut mutable = MutableArrayData::new(arrays, false, 0);
+
+        mutable.extend(0, 1, 3);

Review comment:
       I wonder if ensuring the slice covers an actual string value would be useful (this slice just takes the two `None`, `None` values). It it it was like `mutable.extend(0, 2, 4)` that would also include `Some("mark")`. The same comment applies to `test_struct_nulls` as well




----------------------------------------------------------------
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