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/01/11 19:06:48 UTC

[GitHub] [arrow-rs] alamb opened a new issue #1158: Nicer API to create `MapArrays`

alamb opened a new issue #1158:
URL: https://github.com/apache/arrow-rs/issues/1158


   **Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
   Right now it is quite cumbersome to create  a `MapArray` as one has to create  an `ArrayData` from a `StructArray` . `MapArray` was contributed by @nevi-me  in https://github.com/apache/arrow-rs/pull/491
   
   https://github.com/apache/arrow-rs/blob/e898de57e4587c64387939f8a557bc5fa2dffeb8/arrow/src/array/array_map.rs#L243-L282
   
   
   **Describe the solution you'd like**
   
   It would be great to be able to create a `MapArray` directly from the appropriate `StructArray`. Something like this perhaps (though other proposals more than welcome):
   
   ```rust
   let entry_array = StructArray::from(vec![
               (keys, make_array(keys_data)),
               (values, make_array(values_data)),
           ]); 
   
   let map_array = MapArray::from(&entry_array).unwrap();
   ```
   
   Where `entry_array` would need to have two fields where the first was strings 
   
   The impl might look like
   
   ```
   impl From<&StructArray> for MapArray {
   ...
   }
   ```
   
   **Describe alternatives you've considered**
   A clear and concise description of any alternative solutions or features you've considered.
   
   **Additional context**
   https://github.com/apache/arrow-rs/pull/1149#discussion_r782433887
   
   


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



[GitHub] [arrow-rs] viirya commented on issue #1158: Nicer API to create `MapArrays`

Posted by GitBox <gi...@apache.org>.
viirya commented on issue #1158:
URL: https://github.com/apache/arrow-rs/issues/1158#issuecomment-1081492715


   I think for the proposed API, we don't know the `entry_offsets` which is necessary when constructing a `MapArray`?


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



[GitHub] [arrow-rs] alamb commented on issue #1158: Nicer API to create `MapArrays`

Posted by GitBox <gi...@apache.org>.
alamb commented on issue #1158:
URL: https://github.com/apache/arrow-rs/issues/1158#issuecomment-1083408644






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



[GitHub] [arrow-rs] viirya commented on issue #1158: Nicer API to create `MapArrays`

Posted by GitBox <gi...@apache.org>.
viirya commented on issue #1158:
URL: https://github.com/apache/arrow-rs/issues/1158#issuecomment-1081498902


   For alternative one `new_from_strings`, we can add offset parameters:
   
   ```rust
   impl MapArray {
     fn new_from_strings(keys: impl Iterator<Item=&str>, values: &dyn Array, entry_offsets: &[u8]) -> Result<Self> {
       ..
     }
   }
   ```


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