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 2022/04/01 17:25:19 UTC

[GitHub] [arrow-rs] alamb commented on a change in pull request #1507: Add `new_from_strings` to create `MapArrays`

alamb commented on a change in pull request #1507:
URL: https://github.com/apache/arrow-rs/pull/1507#discussion_r840784430



##########
File path: arrow/src/array/array_map.rs
##########
@@ -152,6 +155,44 @@ impl MapArray {
             value_offsets,
         })
     }
+
+    /// Creates map array from provided keys, values and entry_offsets.
+    pub fn new_from_strings<'a>(
+        keys: impl Iterator<Item = &'a str>,
+        values: ArrayData,

Review comment:
       > Hmm, if we make it values: &dyn Array, how can we call StructArray::from or make StructArray from it? We cannot move values.
   
   I guess I was thinking we could use `array.data()` to get the `ArrayData` needed to construct the `StructArray`
   
   > For example, in the test, the keys is vec!["a", "b", "c", "d", "e", "f", "g", "h"]; and the offsets are [0, 3, 6, 8]. So it represents [[a, b, c], [d, e, f], [g, h]].
   
   Ah, sorry, I missed that point. 
   
   




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

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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