pub struct Sorter<MF, CC: ChunkCreator = DefaultChunkCreator> { /* private fields */ }
Expand description
A struct you can use to automatically sort and merge duplicate entries.
You can insert key-value pairs in arbitrary order, it will use the
ChunkCreator
and you the generated chunks to buffer when the dump_threashold
setting is reached.
Implementations§
source§impl<MF> Sorter<MF, DefaultChunkCreator>
impl<MF> Sorter<MF, DefaultChunkCreator>
sourcepub fn builder(merge: MF) -> SorterBuilder<MF, DefaultChunkCreator>
pub fn builder(merge: MF) -> SorterBuilder<MF, DefaultChunkCreator>
Creates a SorterBuilder
from a merge function, it can be
used to configure your Sorter
to better fit your needs.
sourcepub fn new(merge: MF) -> Sorter<MF, DefaultChunkCreator>
pub fn new(merge: MF) -> Sorter<MF, DefaultChunkCreator>
Creates a Sorter
from a merge function, with the default parameters.
sourcepub fn estimated_dumped_memory_usage(&self) -> u64
pub fn estimated_dumped_memory_usage(&self) -> u64
A rough estimate of how much memory usage it will take on the disk once dumped to disk.
This is a very bad estimate in the sense that it does not calculate the amount of duplicate entries that are in the dumped chunks and neither the fact that the in-memory buffer will likely be compressed once written to disk. This estimate will always be greater than the actual end space usage on disk.
source§impl<MF, CC, U> Sorter<MF, CC>
impl<MF, CC, U> Sorter<MF, CC>
sourcepub fn insert<K, V>(&mut self, key: K, val: V) -> Result<(), Error<U>>
pub fn insert<K, V>(&mut self, key: K, val: V) -> Result<(), Error<U>>
Insert an entry into the Sorter
making sure that conflicts
are resolved by the provided merge function.
sourcepub fn write_into_stream_writer<W: Write>(
self,
writer: &mut Writer<W>
) -> Result<(), Error<U>>
pub fn write_into_stream_writer<W: Write>( self, writer: &mut Writer<W> ) -> Result<(), Error<U>>
sourcepub fn into_stream_merger_iter(
self
) -> Result<MergerIter<CC::Chunk, MF>, Error<U>>
pub fn into_stream_merger_iter( self ) -> Result<MergerIter<CC::Chunk, MF>, Error<U>>
Consumes this Sorter
and outputs a stream of the merged entries in key-order.
sourcepub fn into_reader_cursors(
self
) -> Result<Vec<ReaderCursor<CC::Chunk>>, Error<U>>
pub fn into_reader_cursors( self ) -> Result<Vec<ReaderCursor<CC::Chunk>>, Error<U>>
Consumes this Sorter
and outputs the list of reader cursors.