Apache DataFusion SQL Query Engine
remove 'spill_record_batch_by_size' api (#16958)
ding-young21362aa53da2
diff --git a/datafusion/physical-plan/src/spill/mod.rs b/datafusion/physical-plan/src/spill/mod.rsindex a81221c8b6..91d40e79c8 100644--- a/datafusion/physical-plan/src/spill/mod.rs+++ b/datafusion/physical-plan/src/spill/mod.rs@@ -474,10 +474,15 @@ mod tests {let metrics = SpillMetrics::new(&ExecutionPlanMetricsSet::new(), 0);let spill_manager = SpillManager::new(env, metrics, Arc::clone(&schema));- let spill_file = spill_manager- .spill_record_batch_by_size(&batch1, "Test Spill", 1)?+ let (spill_file, max_batch_mem) = spill_manager+ .spill_record_batch_by_size_and_return_max_batch_memory(+ &batch1,+ "Test Spill",+ 1,+ )?.unwrap();assert!(spill_file.path().exists());+ assert!(max_batch_mem > 0);let stream = spill_manager.read_spill_as_stream(spill_file)?;assert_eq!(stream.schema(), schema);@@ -850,7 +855,7 @@ mod tests {let completed_file = spill_manager.spill_record_batch_and_finish(&[], "Test")?;assert!(completed_file.is_none());- // Test write empty batch with interface `spill_record_batch_by_size()`+ // Test write empty batch with interface `spill_record_batch_by_size_and_return_max_batch_memory()`let empty_batch = RecordBatch::try_new(Arc::clone(&schema),vec![@@ -858,8 +863,12 @@ mod tests {Arc::new(StringArray::from(Vec::<Option<&str>>::new())),],)?;- let completed_file =- spill_manager.spill_record_batch_by_size(&empty_batch, "Test", 1)?;+ let completed_file = spill_manager+ .spill_record_batch_by_size_and_return_max_batch_memory(+ &empty_batch,+ "Test",+ 1,+ )?;assert!(completed_file.is_none());Ok(())diff --git a/datafusion/physical-plan/src/spill/spill_manager.rs b/datafusion/physical-plan/src/spill/spill_manager.rsindex 6c47af129f..467a7aa72b 100644--- a/datafusion/physical-plan/src/spill/spill_manager.rs+++ b/datafusion/physical-plan/src/spill/spill_manager.rs@@ -104,34 +104,6 @@ impl SpillManager {in_progress_file.finish()}- /// Refer to the documentation for [`Self::spill_record_batch_and_finish`]. This method- /// additionally spills the `RecordBatch` into smaller batches, divided by `row_limit`.- ///- /// # Errors- /// - Returns an error if spilling would exceed the disk usage limit configured- /// by `max_temp_directory_size` in `DiskManager`- pub fn spill_record_batch_by_size(- &self,- batch: &RecordBatch,- request_description: &str,- row_limit: usize,- ) -> Result<Option<RefCountedTempFile>> {- let total_rows = batch.num_rows();- let mut batches = Vec::new();- let mut offset = 0;-- // It's ok to calculate all slices first, because slicing is zero-copy.- while offset < total_rows {- let length = std::cmp::min(total_rows - offset, row_limit);- let sliced_batch = batch.slice(offset, length);- batches.push(sliced_batch);- offset += length;- }-- // Spill the sliced batches to disk- self.spill_record_batch_and_finish(&batches, request_description)- }-/// Refer to the documentation for [`Self::spill_record_batch_and_finish`]. This method/// additionally spills the `RecordBatch` into smaller batches, divided by `row_limit`.///