pub struct SpillManager {
env: Arc<RuntimeEnv>,
pub(crate) metrics: SpillMetrics,
schema: SchemaRef,
batch_read_buffer_capacity: usize,
pub(crate) compression: SpillCompression,
}Expand description
The SpillManager is responsible for the following tasks:
- Reading and writing
RecordBatches to raw files based on the provided configurations. - Updating the associated metrics.
Note: The caller (external operators such as SortExec) is responsible for interpreting the spilled files.
For example, all records within the same spill file are ordered according to a specific order.
Fields§
§env: Arc<RuntimeEnv>§metrics: SpillMetrics§schema: SchemaRef§batch_read_buffer_capacity: usizeNumber of batches to buffer in memory during disk reads
compression: SpillCompressiongeneral-purpose compression options
Implementations§
Source§impl SpillManager
impl SpillManager
pub fn new( env: Arc<RuntimeEnv>, metrics: SpillMetrics, schema: SchemaRef, ) -> Self
pub fn with_batch_read_buffer_capacity( self, batch_read_buffer_capacity: usize, ) -> Self
pub fn with_compression_type(self, spill_compression: SpillCompression) -> Self
Sourcepub fn create_in_progress_file(
&self,
request_msg: &str,
) -> Result<InProgressSpillFile>
pub fn create_in_progress_file( &self, request_msg: &str, ) -> Result<InProgressSpillFile>
Creates a temporary file for in-progress operations, returning an error message if file creation fails. The file can be used to append batches incrementally and then finish the file when done.
Sourcepub fn spill_record_batch_and_finish(
&self,
batches: &[RecordBatch],
request_msg: &str,
) -> Result<Option<RefCountedTempFile>>
pub fn spill_record_batch_and_finish( &self, batches: &[RecordBatch], request_msg: &str, ) -> Result<Option<RefCountedTempFile>>
Spill input batches into a single file in a atomic operation. If it is
intended to incrementally write in-memory batches into the same spill file,
use Self::create_in_progress_file instead.
None is returned if no batches are spilled.
§Errors
- Returns an error if spilling would exceed the disk usage limit configured
by
max_temp_directory_sizeinDiskManager
Sourcepub(crate) fn spill_record_batch_by_size_and_return_max_batch_memory(
&self,
batch: &RecordBatch,
request_description: &str,
row_limit: usize,
) -> Result<Option<(RefCountedTempFile, usize)>>
pub(crate) fn spill_record_batch_by_size_and_return_max_batch_memory( &self, batch: &RecordBatch, request_description: &str, row_limit: usize, ) -> Result<Option<(RefCountedTempFile, usize)>>
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_sizeinDiskManager
Sourcepub(crate) async fn spill_record_batch_stream_and_return_max_batch_memory(
&self,
stream: &mut SendableRecordBatchStream,
request_description: &str,
) -> Result<Option<(RefCountedTempFile, usize)>>
pub(crate) async fn spill_record_batch_stream_and_return_max_batch_memory( &self, stream: &mut SendableRecordBatchStream, request_description: &str, ) -> Result<Option<(RefCountedTempFile, usize)>>
Spill a stream of RecordBatches to disk and return the spill file and the size of the largest batch in memory
Sourcepub fn read_spill_as_stream(
&self,
spill_file_path: RefCountedTempFile,
max_record_batch_memory: Option<usize>,
) -> Result<SendableRecordBatchStream>
pub fn read_spill_as_stream( &self, spill_file_path: RefCountedTempFile, max_record_batch_memory: Option<usize>, ) -> Result<SendableRecordBatchStream>
Reads a spill file as a stream. The file must be created by the current SpillManager.
This method will generate output in FIFO order: the batch appended first
will be read first.
Trait Implementations§
Source§impl Clone for SpillManager
impl Clone for SpillManager
Source§fn clone(&self) -> SpillManager
fn clone(&self) -> SpillManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SpillManager
impl !RefUnwindSafe for SpillManager
impl Send for SpillManager
impl Sync for SpillManager
impl Unpin for SpillManager
impl !UnwindSafe for SpillManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more