pub struct SpillManager { /* private fields */ }Expand description
Manages spill file lifecycle for out-of-core processing.
The manager handles:
- Creating unique spill files with prefixes
- Tracking total bytes spilled to disk
- Automatic cleanup of all spill files on drop
By default the spill directory itself outlives the manager (the caller
owns it). Per-query callers that pass a unique throwaway directory should
chain with_owned_dir so Drop also removes the
directory once its files are gone.
Implementations§
Source§impl SpillManager
impl SpillManager
Sourcepub fn new(spill_dir: impl Into<PathBuf>) -> Result<Self>
pub fn new(spill_dir: impl Into<PathBuf>) -> Result<Self>
Creates a new spill manager with the given directory.
Creates the directory if it doesn’t exist. The directory is not
removed on drop unless with_owned_dir is
chained on the result.
§Errors
Returns an error if the directory cannot be created.
Sourcepub fn with_owned_dir(self) -> Self
pub fn with_owned_dir(self) -> Self
Marks the spill directory as owned by this manager so that Drop
removes it (non-recursive) after spill files are cleaned up.
Use for per-query spill subdirectories (e.g. <base>/query_<id>/)
where leaving the empty directory behind would accumulate over time.
The removal is best-effort: if anything unexpected is left in the
directory, remove_dir fails and the directory is preserved.
Sourcepub fn with_temp_dir() -> Result<Self>
pub fn with_temp_dir() -> Result<Self>
Creates a new spill manager using a system temp directory.
§Errors
Returns an error if the temp directory cannot be created.
Sourcepub fn create_file(&self, prefix: &str) -> Result<SpillFile>
pub fn create_file(&self, prefix: &str) -> Result<SpillFile>
Creates a new spill file with the given prefix.
The file name format is: {prefix}_{file_id}.spill
§Errors
Returns an error if the file cannot be created.
Sourcepub fn register_spilled_bytes(&self, bytes: u64)
pub fn register_spilled_bytes(&self, bytes: u64)
Registers bytes spilled to disk.
Called by SpillFile when writing completes.
Sourcepub fn unregister_spilled_bytes(&self, bytes: u64)
pub fn unregister_spilled_bytes(&self, bytes: u64)
Unregisters bytes when a spill file is deleted.
Called by SpillFile on deletion.
Sourcepub fn unregister_file(&self, path: &Path)
pub fn unregister_file(&self, path: &Path)
Removes a file path from tracking (called when file is deleted).
Sourcepub fn spilled_bytes(&self) -> u64
pub fn spilled_bytes(&self) -> u64
Returns total bytes currently spilled to disk.
Sourcepub fn active_file_count(&self) -> usize
pub fn active_file_count(&self) -> usize
Returns the number of active spill files.
Trait Implementations§
Source§impl Debug for SpillManager
impl Debug for SpillManager
Auto Trait Implementations§
impl !Freeze for SpillManager
impl !RefUnwindSafe for SpillManager
impl Send for SpillManager
impl Sync for SpillManager
impl Unpin for SpillManager
impl UnsafeUnpin 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> 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