@@ -203,39 +203,54 @@ impl ExternalSorterMetrics {
203
203
/// in_mem_batches
204
204
/// ```
205
205
struct 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)
207
211
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
+ // ========================================================================
208
227
/// Potentially unsorted in memory buffer
209
228
in_mem_batches : Vec < RecordBatch > ,
210
229
/// if `Self::in_mem_batches` are sorted
211
230
in_mem_batches_sorted : bool ,
231
+
212
232
/// If data has previously been spilled, the locations of the
213
233
/// spill files (in Arrow IPC format)
214
234
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
+ // ========================================================================
217
240
/// Runtime metrics
218
241
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 > ,
222
244
/// Reservation for in_mem_batches
223
245
reservation : MemoryReservation ,
246
+
224
247
/// Reservation for the merging of in-memory batches. If the sort
225
248
/// might spill, `sort_spill_reservation_bytes` will be
226
249
/// pre-reserved to ensure there is some space for this sort/merge.
227
250
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 ,
232
251
/// How much memory to reserve for performing in-memory sort/merges
233
252
/// prior to spilling.
234
253
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 ,
239
254
}
240
255
241
256
impl ExternalSorter {
0 commit comments