Struct extsort::sorter::ExternalSorter [−][src]
Exposes external sorting (i.e. on disk sorting) capability on arbitrarily sized iterator, even if the generated content of the iterator doesn't fit in memory.
It uses an in-memory buffer sorted and flushed to disk in segment files when full. Once sorted, it returns a new sorted iterator with all items. In order to remain efficient for all implementations, the crate doesn't handle serialization, but leaves that to the user.
Implementations
impl ExternalSorter[src]
pub fn new() -> ExternalSorter[src]
pub fn with_segment_size(mut self: Self, size: usize) -> Self[src]
Sets the maximum size of each segment in number of sorted items.
This number of items needs to fit in memory. While sorting, a in-memory buffer is used to collect the items to be sorted. Once it reaches the maximum size, it is sorted and then written to disk.
Using a higher segment size makes sorting faster by leveraging faster in-memory operations.
pub fn with_sort_dir(mut self: Self, path: PathBuf) -> Self[src]
Sets directory in which sorted segments will be written (if it doesn't fit in memory).
pub fn with_parallel_sort(mut self: Self) -> Self[src]
Uses Rayon to sort the in-memory buffer.
This may not be needed if the buffer isn't big enough for parallelism to be gainful over the overhead of multithreading.
pub fn sort<T, I>(
&self,
iterator: I
) -> Result<SortedIterator<T, impl Fn(&T, &T) -> Ordering + Send + Sync>, Error> where
T: Sortable + Ord,
I: Iterator<Item = T>, [src]
&self,
iterator: I
) -> Result<SortedIterator<T, impl Fn(&T, &T) -> Ordering + Send + Sync>, Error> where
T: Sortable + Ord,
I: Iterator<Item = T>,
Sorts a given iterator, returning a new iterator with items
pub fn sort_by<T, I, F>(
&self,
iterator: I,
cmp: F
) -> Result<SortedIterator<T, F>, Error> where
T: Sortable,
I: Iterator<Item = T>,
F: Fn(&T, &T) -> Ordering + Send + Sync, [src]
&self,
iterator: I,
cmp: F
) -> Result<SortedIterator<T, F>, Error> where
T: Sortable,
I: Iterator<Item = T>,
F: Fn(&T, &T) -> Ordering + Send + Sync,
Sorts a given iterator with a comparator function, returning a new iterator with items
pub fn sort_by_key<T, I, F, K>(
&self,
iterator: I,
f: F
) -> Result<SortedIterator<T, impl Fn(&T, &T) -> Ordering + Send + Sync>, Error> where
T: Sortable,
I: Iterator<Item = T>,
F: Fn(&T) -> K + Send + Sync,
K: Ord, [src]
&self,
iterator: I,
f: F
) -> Result<SortedIterator<T, impl Fn(&T, &T) -> Ordering + Send + Sync>, Error> where
T: Sortable,
I: Iterator<Item = T>,
F: Fn(&T) -> K + Send + Sync,
K: Ord,
Sorts a given iterator with a key extraction function, returning a new iterator with items
Trait Implementations
impl Default for ExternalSorter[src]
Auto Trait Implementations
impl RefUnwindSafe for ExternalSorter[src]
impl Send for ExternalSorter[src]
impl Sync for ExternalSorter[src]
impl Unpin for ExternalSorter[src]
impl UnwindSafe for ExternalSorter[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,