@@ -203,39 +203,54 @@ impl ExternalSorterMetrics {
203203/// in_mem_batches
204204/// ```
205205struct ExternalSorter {
206- /// schema of the output (and the input)
206+ // ========================================================================
207+ // PROPERTIES:
208+ // Fields that define the sorter's configuration and remain constant
209+ // ========================================================================
210+ /// Schema of the output (and the input)
207211 schema : SchemaRef ,
212+ /// Sort expressions
213+ expr : Arc < [ PhysicalSortExpr ] > ,
214+ /// If Some, the maximum number of output rows that will be produced
215+ fetch : Option < usize > ,
216+ /// The target number of rows for output batches
217+ batch_size : usize ,
218+ /// If the in size of buffered memory batches is below this size,
219+ /// the data will be concatenated and sorted in place rather than
220+ /// sort/merged.
221+ sort_in_place_threshold_bytes : usize ,
222+
223+ // ========================================================================
224+ // STATE BUFFERS:
225+ // Fields that hold intermediate data during sorting
226+ // ========================================================================
208227 /// Potentially unsorted in memory buffer
209228 in_mem_batches : Vec < RecordBatch > ,
210229 /// if `Self::in_mem_batches` are sorted
211230 in_mem_batches_sorted : bool ,
231+
212232 /// If data has previously been spilled, the locations of the
213233 /// spill files (in Arrow IPC format)
214234 spills : Vec < RefCountedTempFile > ,
215- /// Sort expressions
216- expr : Arc < [ PhysicalSortExpr ] > ,
235+
236+ // ========================================================================
237+ // EXECUTION RESOURCES:
238+ // Fields related to managing execution resources and monitoring performance.
239+ // ========================================================================
217240 /// Runtime metrics
218241 metrics : ExternalSorterMetrics ,
219- /// If Some, the maximum number of output rows that will be
220- /// produced.
221- fetch : Option < usize > ,
242+ /// A handle to the runtime to get spill files
243+ runtime : Arc < RuntimeEnv > ,
222244 /// Reservation for in_mem_batches
223245 reservation : MemoryReservation ,
246+
224247 /// Reservation for the merging of in-memory batches. If the sort
225248 /// might spill, `sort_spill_reservation_bytes` will be
226249 /// pre-reserved to ensure there is some space for this sort/merge.
227250 merge_reservation : MemoryReservation ,
228- /// A handle to the runtime to get spill files
229- runtime : Arc < RuntimeEnv > ,
230- /// The target number of rows for output batches
231- batch_size : usize ,
232251 /// How much memory to reserve for performing in-memory sort/merges
233252 /// prior to spilling.
234253 sort_spill_reservation_bytes : usize ,
235- /// If the in size of buffered memory batches is below this size,
236- /// the data will be concatenated and sorted in place rather than
237- /// sort/merged.
238- sort_in_place_threshold_bytes : usize ,
239254}
240255
241256impl ExternalSorter {
0 commit comments