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
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.
§Errors
Returns an error if the directory cannot be created.
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.