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

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

Reply via email to