pub struct AsyncSpillFile { /* private fields */ }Expand description
Async handle for a single spill file.
AsyncSpillFile manages a temporary file used for spilling operator state to disk using tokio’s async I/O primitives for non-blocking operations.
Implementations§
Source§impl AsyncSpillFile
impl AsyncSpillFile
Sourcepub async fn new(path: PathBuf) -> Result<Self>
pub async fn new(path: PathBuf) -> Result<Self>
Creates a new async spill file at the given path.
§Errors
Returns an error if the file cannot be created.
Sourcepub fn bytes_written(&self) -> u64
pub fn bytes_written(&self) -> u64
Returns the number of bytes written to this file.
Sourcepub async fn write_u64_le(&mut self, value: u64) -> Result<()>
pub async fn write_u64_le(&mut self, value: u64) -> Result<()>
Sourcepub async fn write_i64_le(&mut self, value: i64) -> Result<()>
pub async fn write_i64_le(&mut self, value: i64) -> Result<()>
Sourcepub async fn write_bytes(&mut self, data: &[u8]) -> Result<()>
pub async fn write_bytes(&mut self, data: &[u8]) -> Result<()>
Writes a length-prefixed byte slice.
Format: [length: u64][data: bytes]
§Errors
Returns an error if the write fails.
Sourcepub async fn finish_write(&mut self) -> Result<()>
pub async fn finish_write(&mut self) -> Result<()>
Finishes writing and flushes buffers.
After this call, the file is ready for reading.
§Errors
Returns an error if the flush fails.
Sourcepub fn is_writable(&self) -> bool
pub fn is_writable(&self) -> bool
Returns whether this file is still in write mode.
Sourcepub async fn reader(&self) -> Result<AsyncSpillFileReader>
pub async fn reader(&self) -> Result<AsyncSpillFileReader>
Creates an async reader for this file.
Can be called multiple times to create multiple readers.
§Errors
Returns an error if the file cannot be opened for reading.