Skip to content

Commit 8178f21

Browse files
docs: explain shared and per-run sort reservation sizes
Document the independent-input and common-input cases explicitly, including which budget covers private input buffers and when input charges are released.
1 parent 69fb4e0 commit 8178f21

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

  • datafusion/physical-plan/src/sorts

‎datafusion/physical-plan/src/sorts/sort.rs‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -931,13 +931,15 @@ impl ExternalSorter {
931931

932932
/// Calculates each run's reservation size and any shared input size.
933933
///
934-
/// Runs can share buffers, for example zero-copy slices of one larger batch,
935-
/// and `self.reservation` covers each shared buffer once. A shared buffer
936-
/// stays alive until the last run holding it is sorted, so if any buffers are
937-
/// shared, the reservation for every run's input is held until all the runs
938-
/// are sorted. Otherwise each run releases its input once it is sorted.
939-
/// With shared input, each run's size covers only its sorted copy. Otherwise
940-
/// it also includes that run's input.
934+
/// - With no shared input size (`None`), each run's size covers its input
935+
/// buffers and an estimated sorted copy.
936+
/// - With a shared input size (`Some`), that size counts all input buffers
937+
/// once, including buffers private to one run. Each run's size covers only
938+
/// its estimated sorted copy.
939+
///
940+
/// Runs can share buffers, for example zero-copy slices of one larger batch.
941+
/// Callers hold the shared input reservation until all runs are sorted.
942+
/// Otherwise each run holds its input charge until its own sort finishes.
941943
fn sort_run_sizes(
942944
&self,
943945
runs: &[RecordBatch],

0 commit comments

Comments
 (0)