Trait ext_sort::chunk::ExternalChunk
source · pub trait ExternalChunk<T>: Sized + Iterator<Item = Result<T, Self::DeserializationError>> {
type SerializationError: Error;
type DeserializationError: Error;
// Required methods
fn new(reader: Take<BufReader<File>>) -> Self;
fn dump(
chunk_writer: &mut BufWriter<File>,
items: impl IntoIterator<Item = T>
) -> Result<(), Self::SerializationError>;
// Provided method
fn build(
dir: &TempDir,
items: impl IntoIterator<Item = T>,
buf_size: Option<usize>
) -> Result<Self, ExternalChunkError<Self::SerializationError>> { ... }
}
Expand description
External chunk interface. Provides methods for creating a chunk stored on file system and reading data from it.
Required Associated Types§
sourcetype SerializationError: Error
type SerializationError: Error
Error returned when data serialization failed.
sourcetype DeserializationError: Error
type DeserializationError: Error
Error returned when data deserialization failed.
Required Methods§
sourcefn new(reader: Take<BufReader<File>>) -> Self
fn new(reader: Take<BufReader<File>>) -> Self
Creates and instance of an external chunk.
Arguments
reader
- The reader of the file the chunk is stored in
sourcefn dump(
chunk_writer: &mut BufWriter<File>,
items: impl IntoIterator<Item = T>
) -> Result<(), Self::SerializationError>
fn dump( chunk_writer: &mut BufWriter<File>, items: impl IntoIterator<Item = T> ) -> Result<(), Self::SerializationError>
Dumps items to an external file.
Arguments
chunk_writer
- The writer of the file the data should be dumped initems
- Items to be dumped
Provided Methods§
sourcefn build(
dir: &TempDir,
items: impl IntoIterator<Item = T>,
buf_size: Option<usize>
) -> Result<Self, ExternalChunkError<Self::SerializationError>>
fn build( dir: &TempDir, items: impl IntoIterator<Item = T>, buf_size: Option<usize> ) -> Result<Self, ExternalChunkError<Self::SerializationError>>
Builds an instance of an external chunk creating file and dumping the items to it.
Arguments
dir
- Directory the chunk file is created initems
- Items to be dumped to the chunkbuf_size
- File I/O buffer size