Apache DataFusion SQL Query Engine
organize ExternalSorter fields (#13447)
Yongting You73507c307487
diff --git a/datafusion/physical-plan/src/sorts/sort.rs b/datafusion/physical-plan/src/sorts/sort.rsindex 9f7bd6b28a..e9f17ddeba 100644--- a/datafusion/physical-plan/src/sorts/sort.rs+++ b/datafusion/physical-plan/src/sorts/sort.rs@@ -203,39 +203,54 @@ impl ExternalSorterMetrics {/// in_mem_batches/// ```struct ExternalSorter {- /// schema of the output (and the input)+ // ========================================================================+ // PROPERTIES:+ // Fields that define the sorter's configuration and remain constant+ // ========================================================================+ /// Schema of the output (and the input)schema: SchemaRef,+ /// Sort expressions+ expr: Arc<[PhysicalSortExpr]>,+ /// If Some, the maximum number of output rows that will be produced+ fetch: Option<usize>,+ /// The target number of rows for output batches+ batch_size: usize,+ /// If the in size of buffered memory batches is below this size,+ /// the data will be concatenated and sorted in place rather than+ /// sort/merged.+ sort_in_place_threshold_bytes: usize,++ // ========================================================================+ // STATE BUFFERS:+ // Fields that hold intermediate data during sorting+ // ========================================================================/// Potentially unsorted in memory bufferin_mem_batches: Vec<RecordBatch>,/// if `Self::in_mem_batches` are sortedin_mem_batches_sorted: bool,+/// If data has previously been spilled, the locations of the/// spill files (in Arrow IPC format)spills: Vec<RefCountedTempFile>,- /// Sort expressions- expr: Arc<[PhysicalSortExpr]>,++ // ========================================================================+ // EXECUTION RESOURCES:+ // Fields related to managing execution resources and monitoring performance.+ // ========================================================================/// Runtime metricsmetrics: ExternalSorterMetrics,- /// If Some, the maximum number of output rows that will be- /// produced.- fetch: Option<usize>,+ /// A handle to the runtime to get spill files+ runtime: Arc<RuntimeEnv>,/// Reservation for in_mem_batchesreservation: MemoryReservation,+/// Reservation for the merging of in-memory batches. If the sort/// might spill, `sort_spill_reservation_bytes` will be/// pre-reserved to ensure there is some space for this sort/merge.merge_reservation: MemoryReservation,- /// A handle to the runtime to get spill files- runtime: Arc<RuntimeEnv>,- /// The target number of rows for output batches- batch_size: usize,/// How much memory to reserve for performing in-memory sort/merges/// prior to spilling.sort_spill_reservation_bytes: usize,- /// If the in size of buffered memory batches is below this size,- /// the data will be concatenated and sorted in place rather than- /// sort/merged.- sort_in_place_threshold_bytes: usize,}impl ExternalSorter {