alamb commented on code in PR #13585:
URL: https://github.com/apache/datafusion/pull/13585#discussion_r1861280467


##########
datafusion/physical-plan/src/aggregates/topk/heap.rs:
##########
@@ -151,10 +151,11 @@ where
     }
 
     fn drain(&mut self) -> (ArrayRef, Vec<usize>) {
+        let nulls = None;
         let (vals, map_idxs) = self.heap.drain();
-        let vals = Arc::new(PrimitiveArray::<VAL>::from_iter_values(vals));
-        let vals = adjust_output_array(&self.data_type, vals).expect("Type is 
incorrect");
-        (vals, map_idxs)
+        let arr = PrimitiveArray::<VAL>::new(ScalarBuffer::from(vals), nulls)

Review Comment:
   I believe this will also be slightly faster as the ScalarBuffer::from avoids 
copying the values into the Vec: 
https://docs.rs/arrow/latest/arrow/buffer/struct.ScalarBuffer.html#impl-From%3CVec%3CT%3E%3E-for-ScalarBuffer%3CT%3E



-- 
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-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to