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/06/06 09:06:45 UTC

[GitHub] [arrow-rs] jorgecarleitao commented on pull request #389: make slice work for nested types

jorgecarleitao commented on pull request #389:
URL: https://github.com/apache/arrow-rs/pull/389#issuecomment-855365462


   Isn't it possible to not offset the child data, and instead only offset the `offsets`, or do we have some logic around that assumes that offsets always start from 0?
   
   In arrow2, I am doing 
   
   ```
   impl<O: Offset> ListArray<O> {
       pub fn slice(&self, offset: usize, length: usize) -> Self {
           let validity = self.validity.clone().map(|x| x.slice(offset, length));
           let offsets = self.offsets.clone().slice(offset, length + 1);
           Self {
               data_type: self.data_type.clone(),
               offsets,
               values: self.values.clone(),
               validity,
               offset: self.offset + offset,
           }
       }
   }
   ```
   
   note how the `offsets` are sliced and the values are cloned. The `ListArray<O>::offset` is only used for compatibility with the C data interface.
   


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