neilconway opened a new pull request, #11359:
URL: https://github.com/apache/arrow-rs/pull/11359

   # Which issue does this PR close?
   
   - N/A
   
   # Rationale for this change
   
   Casting a List, LargeList, ListView or Map cast its whole child array. When 
the input to the cast was sliced, this was both inefficient and could also 
result in spurious errors, if a value outside the visible span made the cast 
fail (with `safe: false`).
   
   For lists and maps, we now cast only the range of child values that the rows 
span, and rebase the offsets. For ListView, a row can point anywhere in the 
values buffer, so the visible elements might not form a contiguous span. 
Casting only the visible values would be expensive and require copies, so we 
instead settle for an overestimate: we use the lowest starting offset and 
highest ending offset of any row. This is an improvement over the previous 
behavior, but it does result in unnecessarily casting values that are inside 
that range but not part of any row.
   
   # What changes are included in this PR?
   
   * Only look at the elements in the visible span, for each of the casts in 
question
   * The value buffer of the cast result is potentially smaller than the input 
value buffer, in which case we need to revise the offset buffer
   * Add unit tests
   
   # Are these changes tested?
   
   Yes; existing tests pass, new tests added.
   
   # Are there any significant user-facing changes?
   
   No.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to