Trait ext_sort::chunk::ExternalChunk
source ·
[−]pub trait ExternalChunk<T>: Sized + Iterator<Item = Result<T, Self::DeserializationError>> {
type SerializationError: Error;
type DeserializationError: Error;
fn new(reader: Take<BufReader<File>>) -> Self;
fn dump(
chunk_writer: &mut BufWriter<File>,
items: impl IntoIterator<Item = T>
) -> Result<(), Self::SerializationError>;
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.
Associated Types
Error returned when data serialization failed.
Error returned when data deserialization failed.
Required methods
Creates and instance of an external chunk.
Arguments
reader- The reader of the file the chunk is stored in
fn 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
fn 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
