Struct ext_sort::sort::ExternalSorter
source · pub struct ExternalSorter<T, E, B = LimitedBufferBuilder, C = RmpExternalChunk<T>>where
T: Send,
E: Error,
B: ChunkBufferBuilder<T>,
C: ExternalChunk<T>,{ /* private fields */ }
Expand description
External sorter.
Implementations§
source§impl<T, E, B, C> ExternalSorter<T, E, B, C>where
T: Send,
E: Error,
B: ChunkBufferBuilder<T>,
C: ExternalChunk<T>,
impl<T, E, B, C> ExternalSorter<T, E, B, C>where T: Send, E: Error, B: ChunkBufferBuilder<T>, C: ExternalChunk<T>,
sourcepub fn new(
threads_number: Option<usize>,
tmp_path: Option<&Path>,
buffer_builder: B,
rw_buf_size: Option<usize>
) -> Result<Self, SortError<C::SerializationError, C::DeserializationError, E>>
pub fn new( threads_number: Option<usize>, tmp_path: Option<&Path>, buffer_builder: B, rw_buf_size: Option<usize> ) -> Result<Self, SortError<C::SerializationError, C::DeserializationError, E>>
Creates a new external sorter instance.
Arguments
threads_number
- Number of threads to be used to sort data in parallel. If the parameter isNone
threads number will be selected based on available CPU core number.tmp_path
- Directory to be used to store temporary data. If paramater isNone
default OS temporary directory will be used.buffer_builder
- An instance of a buffer builder that will be used for chunk buffer creation.rw_buf_size
- Chunks file read/write buffer size.
sourcepub fn sort<I>(
&self,
input: I
) -> Result<BinaryHeapMerger<T, C::DeserializationError, impl Fn(&T, &T) -> Ordering + Copy, C>, SortError<C::SerializationError, C::DeserializationError, E>>where
T: Ord,
I: IntoIterator<Item = Result<T, E>>,
pub fn sort<I>( &self, input: I ) -> Result<BinaryHeapMerger<T, C::DeserializationError, impl Fn(&T, &T) -> Ordering + Copy, C>, SortError<C::SerializationError, C::DeserializationError, E>>where T: Ord, I: IntoIterator<Item = Result<T, E>>,
Sorts data from the input. Returns an iterator that can be used to get sorted data stream.
Arguments
input
- Input stream data to be fetched from
sourcepub fn sort_by<I, F>(
&self,
input: I,
compare: F
) -> Result<BinaryHeapMerger<T, C::DeserializationError, F, C>, SortError<C::SerializationError, C::DeserializationError, E>>where
I: IntoIterator<Item = Result<T, E>>,
F: Fn(&T, &T) -> Ordering + Sync + Send + Copy,
pub fn sort_by<I, F>( &self, input: I, compare: F ) -> Result<BinaryHeapMerger<T, C::DeserializationError, F, C>, SortError<C::SerializationError, C::DeserializationError, E>>where I: IntoIterator<Item = Result<T, E>>, F: Fn(&T, &T) -> Ordering + Sync + Send + Copy,
Sorts data from the input using a custom compare function. Returns an iterator that can be used to get sorted data stream.
Arguments
input
- Input stream data to be fetched fromcompare
- Function be be used to compare items