Dandandan commented on code in PR #12969:
URL: https://github.com/apache/datafusion/pull/12969#discussion_r1804346448


##########
datafusion/physical-plan/src/joins/utils.rs:
##########
@@ -1356,17 +1357,34 @@ pub(crate) fn append_right_indices(
         if right_unmatched_indices.is_empty() {
             (left_indices, right_indices)
         } else {
+            let left_size = left_indices.len();
+            let right_size = right_indices.len();
             let unmatched_size = right_unmatched_indices.len();
+
+            let left_indices_data = left_indices.into_data();
+            let right_indices_data = right_indices.into_data();
+            let right_unmatched_indices_data = 
right_unmatched_indices.into_data();
+
             // the new left indices: left_indices + null array
+            let mut new_left_indices = MutableArrayData::new(
+                vec![&left_indices_data],
+                true,
+                left_size + unmatched_size,
+            );
+            new_left_indices.extend(0, 0, left_size);
+            new_left_indices.extend_nulls(unmatched_size);
+            let new_left_indices = 
UInt64Array::from(new_left_indices.freeze());
+
             // the new right indices: right_indices + right_unmatched_indices
-            let new_left_indices = left_indices
-                .iter()
-                .chain(std::iter::repeat(None).take(unmatched_size))
-                .collect();
-            let new_right_indices = right_indices
-                .iter()
-                .chain(right_unmatched_indices.iter())
-                .collect();
+            let mut new_right_indices = MutableArrayData::new(

Review Comment:
   Hm you're right, sorry I missed that it was producing nulls, in that case 
this is not very efficient indeed.
   
   Seems though we can just use 
https://docs.rs/arrow/latest/arrow/array/struct.PrimitiveBuilder.html then 
instead?



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to