You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "LiShiZhensPi (via GitHub)" <gi...@apache.org> on 2023/02/12 14:32:36 UTC

[GitHub] [arrow-rs] LiShiZhensPi opened a new issue, #3702: Is possible to implement GenericListArray::from_iter ?

LiShiZhensPi opened a new issue, #3702:
URL: https://github.com/apache/arrow-rs/issues/3702

   Hi,I'm new to Rust and I really like the Rust language and the project. This is what came to mind when I read the code for this project.
   
   **Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
   The existed method `GenericListArray::from_iter_primitive` can only create Array of `List<T>`,it can't create Array of `List<List<T>>`and other more nested List.
   
   **Describe the solution you'd like**
   Is possible to implement GenericListArray::from_iter so we can create GenericListArray like this:
   ```Rust
       // create ListArray [[[1,2],null],[[3]]]
       let data = vec![
           Some(vec![Some(vec![Some(1), Some(2)]), None]),
           Some(vec![Some(vec![Some(3)])]),
       ];
   
       let list_array = GenericListArray::<i32>::from_iter::<Int32Type,..?>(data);
   ```
   
   **Describe alternatives you've considered**
   Is there a way to support arbitrary nesting depth of list handlers via generic implementation?
   I'm curious if Rust's metaprogramming is powerful enough to implement this feature.
   
   **Additional context**
   https://docs.rs/arrow-array/32.0.0/arrow_array/array/struct.GenericListArray.html#method.from_iter_primitive
   


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

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


[GitHub] [arrow-rs] tustvold commented on issue #3702: Is possible to implement GenericListArray::from_iter ?

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #3702:
URL: https://github.com/apache/arrow-rs/issues/3702#issuecomment-1427131245

   I suspect `FromIterator` will run into issues with trait specialization, we run into this also with supporting both optional and non-optional iterators, but I can't say I've tried to make this work.
   
   That being said you can write something like, which may be sufficient for your needs. The reason this works is you "help" the compiler by fully specifying the nested type in the form of the builder.
   
   ```
   let mut builder = ListBuilder::new(ListBuilder::new(Int32Builder::new()));
   builder.extend(vec![
       Some(vec![Some(vec![Some(1), None, Some(2)]), None]),
       Some(vec![]),
       Some(vec![None]),
       None,
   ]);
   let built = builder.finish();
   ```
   
   


-- 
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] LiShiZhensPi commented on issue #3702: Is possible to implement GenericListArray::from_iter ?

Posted by "LiShiZhensPi (via GitHub)" <gi...@apache.org>.
LiShiZhensPi commented on issue #3702:
URL: https://github.com/apache/arrow-rs/issues/3702#issuecomment-1427226074

   thanks, I read the implementation of [Extend](https://docs.rs/arrow-array/32.0.0/arrow_array/builder/struct.GenericListBuilder.html#impl-Extend%3COption%3CV%3E%3E-for-GenericListBuilder%3CO%2C%20B%3E) and it was very enlightening for me.


-- 
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] LiShiZhensPi closed issue #3702: Is possible to implement GenericListArray::from_iter ?

Posted by "LiShiZhensPi (via GitHub)" <gi...@apache.org>.
LiShiZhensPi closed issue #3702: Is possible to implement GenericListArray::from_iter ?
URL: https://github.com/apache/arrow-rs/issues/3702


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