viirya commented on code in PR #11218:
URL: https://github.com/apache/datafusion/pull/11218#discussion_r1682222150
##########
datafusion/physical-plan/src/joins/sort_merge_join.rs:
##########
@@ -858,6 +889,57 @@ impl SMJStream {
}
}
+ fn free_reservation(&mut self, buffered_batch: BufferedBatch) ->
Result<()> {
+ // Shrink memory usage for in memory batches only
+ if buffered_batch.spill_file.is_none() &&
buffered_batch.batch.is_some() {
+ self.reservation
+ .try_shrink(buffered_batch.size_estimation)?;
+ }
+
+ Ok(())
+ }
+
+ fn allocate_reservation(&mut self, mut buffered_batch: BufferedBatch) ->
Result<()> {
+ match self.reservation.try_grow(buffered_batch.size_estimation) {
+ Ok(_) => {
+ self.join_metrics
+ .peak_mem_used
+ .set_max(self.reservation.size());
+ Ok(())
+ }
+ Err(_) if self.runtime_env.disk_manager.tmp_files_enabled() => {
+ // spill buffered batch to disk
+ let spill_file = self
+ .runtime_env
+ .disk_manager
+ .create_tmp_file("SortMergeJoinBuffered")?;
+
+ if let Some(batch) = buffered_batch.batch {
Review Comment:
`allocate_reservation` is called on the polled batch. I think this is always
`Some`. We should return an `Err` if this is a `None`, instead of ignoring it
silently.
--
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]