pub struct AsyncSpillManager { /* private fields */ }Expand description
Async manager for spill file lifecycle for out-of-core processing.
The async manager handles:
- Creating unique spill files with prefixes using async I/O
- Tracking total bytes spilled to disk
- Automatic cleanup of all spill files on drop
Implementations§
Source§impl AsyncSpillManager
impl AsyncSpillManager
Sourcepub async fn new(spill_dir: impl Into<PathBuf>) -> Result<Self>
pub async fn new(spill_dir: impl Into<PathBuf>) -> Result<Self>
Creates a new async 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 async fn with_temp_dir() -> Result<Self>
pub async fn with_temp_dir() -> Result<Self>
Creates a new async spill manager using a system temp directory.
§Errors
Returns an error if the temp directory cannot be created.
Sourcepub async fn create_file(&self, prefix: &str) -> Result<AsyncSpillFile>
pub async fn create_file(&self, prefix: &str) -> Result<AsyncSpillFile>
Creates a new async 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 AsyncSpillFile 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 AsyncSpillFile on deletion.
Sourcepub async fn unregister_file(&self, path: &Path)
pub async 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 async fn active_file_count(&self) -> usize
pub async fn active_file_count(&self) -> usize
Returns the number of active spill files.