westonpace commented on code in PR #35565:
URL: https://github.com/apache/arrow/pull/35565#discussion_r1205201732


##########
cpp/src/arrow/util/align_util.h:
##########
@@ -82,29 +101,109 @@ ARROW_EXPORT bool CheckAlignment(const Array& array, 
int64_t alignment);
 // of the constituent objects during the EnsureAlignment function where certain
 // objects can be ignored for further checking if we already know that they are
 // completely aligned.
+
+/// \brief calculate which (if any) chunks in a chunked array are unaligned
+/// \param array the array to check
+/// \param alignment the alignment to check for
+/// \param needs_alignment an output vector that will store the results of the 
check
+///        it must be set to a valid vector.  Extra elements will be added to 
the end
+///        of the vector for each chunk that is checked.  `true` will be 
stored if

Review Comment:
   Yes, but I think we can clean it up.  The motivation is basically that it is 
used in `EnsureAlignment(Table)`.  In that method we call CheckAlignment on the 
table which in turn calls CheckAlignment on each column (which is a chunked 
array).  At the end we have one `alignment` vector that has an entry for each 
chunk in the table (this is `num_chunks() * num_columns()`).  Then we go 
through and only align the chunks that need aligned.
   
   The goal here was to avoid something like...
   
   ```
   if (!CheckAlignment(table)) {
     for (const auto& col : table.columns) {
       if (!CheckAlignment(col)) {
         Reallocate(col);
       }
     }
   }
   ```
   
   Since `CheckAlignment(table)` internally calls `CheckAlignment(col)` for 
each column we don't want to have to call it again.
   
   Perhaps an easier thing to do would be to give the caller responsibility of 
resizing the vector and then pass in an iterator to start recording 
aligned/unaligned.



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