zhuqi-lucas commented on code in PR #14823:
URL: https://github.com/apache/datafusion/pull/14823#discussion_r1966528251
##########
datafusion/physical-plan/src/sorts/sort.rs:
##########
@@ -446,21 +511,9 @@ impl ExternalSorter {
None => {
let sorted_size =
get_reserved_byte_for_record_batch(&batch);
if self.reservation.try_grow(sorted_size).is_err() {
- // Directly write in_mem_batches as well as all the
remaining batches in
- // sorted_stream to disk. Further batches fetched from
`sorted_stream` will
- // be handled by the `Some(writer)` matching arm.
- let spill_file =
-
self.runtime.disk_manager.create_tmp_file("Sorting")?;
- let mut writer = IPCWriter::new(spill_file.path(),
&self.schema)?;
- // Flush everything in memory to the spill file
- for batch in self.in_mem_batches.drain(..) {
- writer.write(&batch)?;
- }
- // as well as the newly sorted batch
- writer.write(&batch)?;
- spill_writer = Some(writer);
+ self.in_mem_batches.push(batch);
+ self.spill().await?;
Review Comment:
Do we need to keep the original logic:
1. self.spill().await?;
2. And then write the remaining batch to disk.
Because the self.in_mem_batches.push(batch) may cause OOM for memory?
--
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]