You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "sanjibansg (via GitHub)" <gi...@apache.org> on 2023/03/17 10:42:10 UTC

[GitHub] [arrow] sanjibansg commented on pull request #14758: ARROW-18119: [C++] Utility method to ensure an array object meetings an alignment requirement

sanjibansg commented on PR #14758:
URL: https://github.com/apache/arrow/pull/14758#issuecomment-1473639765

   > In most cases the alignment will already be correct. We want this method to be really fast in that scenario. So this means that methods should look like...
   > 
   > ```
   > std::shared_ptr<Array> Foo(std::shared_ptr<Array> thing) {
   >   if (needs_alignment(...)) {
   >     // a copy needs to be made
   >   } else {
   >     return std::move(thing);
   >   }
   > }
   > ```
   > 
   > This way we can call it like so...
   > 
   > ```
   > std::shared_ptr<Array> aligned = EnsureAlignment(std::move(unaligned), ...);
   > ```
   > 
   > Then, if `unaligned` is already aligned it will be a straight move into `aligned` without ever making any copies (not even copies of `shared_ptr`)
   
   The current implementation might be a bit complicated, so comments and suggestions for optimized approaches will be very helpful. Thanks in advance! 
   
   Currently, we have `Check` functions for various Arrow objects, which check their constituents for alignments. For `ChunkedArray`, `RecordBatch`, and `Table`, we use a boolean vector to track the constituents which require alignment thus avoiding unnecessary function calls.


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