alamb commented on a change in pull request #722:
URL: https://github.com/apache/arrow-datafusion/pull/722#discussion_r671830596



##########
File path: datafusion/src/physical_plan/sort_preserving_merge.rs
##########
@@ -246,7 +274,19 @@ impl SortKeyCursor {
             .zip(other.columns.iter())
             .zip(options.iter());
 
-        for ((l, r), sort_options) in zipped {
+        // Recall or initialise a collection of comparators for comparing
+        // columnar arrays of this cursor and "other".
+        let cmp = self
+            .batch_comparators
+            .entry(other.batch_idx)
+            .or_insert_with(|| Vec::with_capacity(other.columns.len()));

Review comment:
       I personally think the "right" thing to do in this case is to create an 
arrow comparator interface that doesn't have bound arrays, so like
   ```
   let comparator = arrow::compute::build_comparator(array1.data_type(), 
array2.data_type());
   
   ...
   
   if comparator(array1, index_1, array2, index_2) == Ordering::Equal {
     ...
   }
   ```
   
   With that interface we could simply use the same comparator 
   
   So that is to say, I recommend leaving this PR the way it is and putting our 
efforts into a better comparison interface rather than trying to optimize for a 
small amount of memory savings here




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