Dandandan commented on code in PR #5632:
URL: https://github.com/apache/arrow-datafusion/pull/5632#discussion_r1141456630
##########
datafusion/core/src/physical_plan/joins/sort_merge_join.rs:
##########
@@ -505,15 +516,33 @@ struct BufferedBatch {
pub join_arrays: Vec<ArrayRef>,
/// Buffered joined index (null joining buffered)
pub null_joined: Vec<usize>,
+ /// Size estimation used for reserving / releasing memory
+ pub size_estimation: usize,
}
impl BufferedBatch {
fn new(batch: RecordBatch, range: Range<usize>, on_column: &[Column]) ->
Self {
let join_arrays = join_arrays(&batch, on_column);
+
+ // Estimation is calculated as
+ // inner batch size
+ // + join keys size
+ // + worst case null_joined (as vector capacity)
+ // + Range size (16)
+ // + size of this estimation (8)
+ let size_estimation = batch.get_array_memory_size()
+ + join_arrays
+ .iter()
+ .map(|arr| arr.get_array_memory_size())
+ .sum::<usize>()
+ + batch.num_rows().next_power_of_two() * 8
+ + 24;
Review Comment:
```suggestion
+ sizeof::<Range>()
+ sizeof::<usize>();
```
--
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]