pub struct ParXap<I, Vo, X1, R = DefaultRunner>where
R: ParallelRunner,
I: ConcurrentIter,
Vo: TransformableValues<Fallibility = Infallible>,
X1: Fn(I::Item) -> Vo + Sync,{ /* private fields */ }Expand description
A parallel iterator that xaps inputs.
xap is a generalization of one-to-one map, filter-map and flat-map operations.
Implementations§
Source§impl<E, T, R, Vo, X1> ParXap<ConcurrentRecursiveIter<T, E>, Vo, X1, R>
impl<E, T, R, Vo, X1> ParXap<ConcurrentRecursiveIter<T, E>, Vo, X1, R>
Sourcepub fn linearize(self) -> ParXap<ConIterVec<T>, Vo, X1, R>
pub fn linearize(self) -> ParXap<ConIterVec<T>, Vo, X1, R>
Even with exact length, a recursive parallel iterator is much more dynamic than a flat parallel iterator. This dynamic nature of shrinking and growing concurrently requires a greater parallelization overhead. An alternative approach is to eagerly discover all tasks and then perform the parallel computation over the flattened input of tasks.
The linearize approach works in two parallelization phases:
- first phase to linearize the inputs in parallel over the non-linear data, and
- second phase to perform the computation in parallel over the linear data.
See into_par_rec and into_par_rec_exact for examples.
Trait Implementations§
Source§impl<I, Vo, X1, R> ParIter<R> for ParXap<I, Vo, X1, R>where
R: ParallelRunner,
I: ConcurrentIter,
Vo: TransformableValues<Fallibility = Infallible>,
X1: Fn(I::Item) -> Vo + Sync,
impl<I, Vo, X1, R> ParIter<R> for ParXap<I, Vo, X1, R>where
R: ParallelRunner,
I: ConcurrentIter,
Vo: TransformableValues<Fallibility = Infallible>,
X1: Fn(I::Item) -> Vo + Sync,
Source§fn con_iter(&self) -> &impl ConcurrentIter
fn con_iter(&self) -> &impl ConcurrentIter
Returns a reference to the input concurrent iterator.
Source§fn num_threads(self, num_threads: impl Into<NumThreads>) -> Self
fn num_threads(self, num_threads: impl Into<NumThreads>) -> Self
Sets the number of threads to be used in the parallel execution.
Integers can be used as the argument with the following mapping: Read more
Source§fn chunk_size(self, chunk_size: impl Into<ChunkSize>) -> Self
fn chunk_size(self, chunk_size: impl Into<ChunkSize>) -> Self
Sets the number of elements to be pulled from the concurrent iterator during the
parallel execution. When integers are used as argument, the following mapping applies: Read more
Source§fn iteration_order(self, collect: IterationOrder) -> Self
fn iteration_order(self, collect: IterationOrder) -> Self
Sets the iteration order of the parallel computation. Read more
Source§fn with_runner<Q: ParallelRunner>(
self,
orchestrator: Q,
) -> impl ParIter<Q, Item = Self::Item>
fn with_runner<Q: ParallelRunner>( self, orchestrator: Q, ) -> impl ParIter<Q, Item = Self::Item>
Rather than the
DefaultRunner, uses the parallel runner Q which implements ParallelRunner. Read moreSource§fn using<U, F>(
self,
using: F,
) -> impl ParIterUsing<UsingFun<F, U>, R, Item = <Self as ParIter<R>>::Item>
fn using<U, F>( self, using: F, ) -> impl ParIterUsing<UsingFun<F, U>, R, Item = <Self as ParIter<R>>::Item>
Converts the
ParIter into ParIterUsing which will have access to a mutable reference of the
used variable throughout the computation. Read moreSource§fn using_clone<U>(
self,
value: U,
) -> impl ParIterUsing<UsingClone<U>, R, Item = <Self as ParIter<R>>::Item>where
U: Clone + 'static,
fn using_clone<U>(
self,
value: U,
) -> impl ParIterUsing<UsingClone<U>, R, Item = <Self as ParIter<R>>::Item>where
U: Clone + 'static,
Converts the
ParIter into ParIterUsing which will have access to a mutable reference of the
used variable throughout the computation. Read moreSource§fn map<Out, Map>(self, map: Map) -> impl ParIter<R, Item = Out>
fn map<Out, Map>(self, map: Map) -> impl ParIter<R, Item = Out>
Takes a closure
map and creates a parallel iterator which calls that closure on each element. Read moreSource§fn filter<Filter>(self, filter: Filter) -> impl ParIter<R, Item = Self::Item>
fn filter<Filter>(self, filter: Filter) -> impl ParIter<R, Item = Self::Item>
Creates an iterator which uses a closure
filter to determine if an element should be yielded. Read moreSource§fn flat_map<IOut, FlatMap>(
self,
flat_map: FlatMap,
) -> impl ParIter<R, Item = IOut::Item>
fn flat_map<IOut, FlatMap>( self, flat_map: FlatMap, ) -> impl ParIter<R, Item = IOut::Item>
Creates an iterator that works like map, but flattens nested structure. Read more
Source§fn filter_map<Out, FilterMap>(
self,
filter_map: FilterMap,
) -> impl ParIter<R, Item = Out>
fn filter_map<Out, FilterMap>( self, filter_map: FilterMap, ) -> impl ParIter<R, Item = Out>
Creates an iterator that both filters and maps. Read more
Source§fn take_while<While>(
self,
take_while: While,
) -> impl ParIter<R, Item = Self::Item>
fn take_while<While>( self, take_while: While, ) -> impl ParIter<R, Item = Self::Item>
Creates an iterator that yields elements based on the predicate
take_while. Read moreSource§fn into_fallible_result<Out, Err>(
self,
) -> impl ParIterResult<R, Item = Out, Err = Err>where
Self::Item: IntoResult<Out, Err>,
fn into_fallible_result<Out, Err>(
self,
) -> impl ParIterResult<R, Item = Out, Err = Err>where
Self::Item: IntoResult<Out, Err>,
Transforms a parallel iterator where elements are of the result type; i.e.,
ParIter<R, Item = Result<T, E>>,
into fallible parallel iterator with item type T and error type E; i.e., into ParIterResult<R, Item = T, Err = E>. Read moreSource§fn collect_into<C>(self, output: C) -> Cwhere
C: ParCollectInto<Self::Item>,
fn collect_into<C>(self, output: C) -> Cwhere
C: ParCollectInto<Self::Item>,
Collects all the items from an iterator into a collection. Read more
Source§fn reduce<Reduce>(self, reduce: Reduce) -> Option<Self::Item>
fn reduce<Reduce>(self, reduce: Reduce) -> Option<Self::Item>
Reduces the elements to a single one, by repeatedly applying a reducing operation. Read more
Source§fn first(self) -> Option<Self::Item>
fn first(self) -> Option<Self::Item>
Returns the first (or any) element of the iterator; returns None if it is empty. Read more
Source§fn with_pool<P: ParThreadPool>(
self,
pool: P,
) -> impl ParIter<RunnerWithPool<P, R::Executor>, Item = Self::Item>
fn with_pool<P: ParThreadPool>( self, pool: P, ) -> impl ParIter<RunnerWithPool<P, R::Executor>, Item = Self::Item>
Rather than
DefaultPool, uses the parallel runner with the given pool implementing
ParThreadPool. Read moreSource§fn into_fallible_option<T>(self) -> impl ParIterOption<R, Item = T>where
Self::Item: IntoOption<T>,
fn into_fallible_option<T>(self) -> impl ParIterOption<R, Item = T>where
Self::Item: IntoOption<T>,
Transforms a parallel iterator where elements are of the option type; i.e.,
ParIter<R, Item = Option<T>>,
into fallible parallel iterator with item type T; i.e., into ParIterOption<R, Item = T>. Read moreSource§fn inspect<Operation>(
self,
operation: Operation,
) -> impl ParIter<R, Item = Self::Item>
fn inspect<Operation>( self, operation: Operation, ) -> impl ParIter<R, Item = Self::Item>
Does something with each element of an iterator, passing the value on. Read more
Source§fn map_while<Out, MapWhile>(
self,
map_while: MapWhile,
) -> impl ParIter<R, Item = Out>
fn map_while<Out, MapWhile>( self, map_while: MapWhile, ) -> impl ParIter<R, Item = Out>
Creates an iterator that both yields elements based on the predicate
map_while and maps. Read moreSource§fn copied<'a, T>(self) -> impl ParIter<R, Item = T>
fn copied<'a, T>(self) -> impl ParIter<R, Item = T>
Creates an iterator which copies all of its elements. Read more
Source§fn cloned<'a, T>(self) -> impl ParIter<R, Item = T>
fn cloned<'a, T>(self) -> impl ParIter<R, Item = T>
Creates an iterator which clones all of its elements. Read more
Source§fn flatten(self) -> impl ParIter<R, Item = <Self::Item as IntoIterator>::Item>where
Self::Item: IntoIterator,
fn flatten(self) -> impl ParIter<R, Item = <Self::Item as IntoIterator>::Item>where
Self::Item: IntoIterator,
Creates an iterator that flattens nested structure. Read more
Source§fn collect<C>(self) -> Cwhere
C: ParCollectInto<Self::Item>,
fn collect<C>(self) -> Cwhere
C: ParCollectInto<Self::Item>,
Transforms an iterator into a collection. Read more
Source§fn all<Predicate>(self, predicate: Predicate) -> bool
fn all<Predicate>(self, predicate: Predicate) -> bool
Tests if every element of the iterator matches a predicate. Read more
Source§fn any<Predicate>(self, predicate: Predicate) -> bool
fn any<Predicate>(self, predicate: Predicate) -> bool
Tests if any element of the iterator matches a predicate. Read more
Source§fn count(self) -> usize
fn count(self) -> usize
Consumes the iterator, counting the number of iterations and returning it. Read more
Source§fn for_each<Operation>(self, operation: Operation)
fn for_each<Operation>(self, operation: Operation)
Calls a closure on each element of an iterator. Read more
Source§fn max_by<Compare>(self, compare: Compare) -> Option<Self::Item>
fn max_by<Compare>(self, compare: Compare) -> Option<Self::Item>
Returns the element that gives the maximum value with respect to the specified
compare function. Read moreSource§fn max_by_key<Key, GetKey>(self, key: GetKey) -> Option<Self::Item>
fn max_by_key<Key, GetKey>(self, key: GetKey) -> Option<Self::Item>
Returns the element that gives the maximum value from the specified function. Read more
Source§fn min_by<Compare>(self, compare: Compare) -> Option<Self::Item>
fn min_by<Compare>(self, compare: Compare) -> Option<Self::Item>
Returns the element that gives the minimum value with respect to the specified
compare function. Read moreSource§fn min_by_key<Key, GetKey>(self, get_key: GetKey) -> Option<Self::Item>
fn min_by_key<Key, GetKey>(self, get_key: GetKey) -> Option<Self::Item>
Returns the element that gives the minimum value from the specified function. Read more
impl<I, Vo, X1, R> Send for ParXap<I, Vo, X1, R>where
R: ParallelRunner,
I: ConcurrentIter,
Vo: TransformableValues<Fallibility = Infallible>,
X1: Fn(I::Item) -> Vo + Sync,
impl<I, Vo, X1, R> Sync for ParXap<I, Vo, X1, R>where
R: ParallelRunner,
I: ConcurrentIter,
Vo: TransformableValues<Fallibility = Infallible>,
X1: Fn(I::Item) -> Vo + Sync,
Auto Trait Implementations§
impl<I, Vo, X1, R> Freeze for ParXap<I, Vo, X1, R>
impl<I, Vo, X1, R> RefUnwindSafe for ParXap<I, Vo, X1, R>
impl<I, Vo, X1, R> Unpin for ParXap<I, Vo, X1, R>
impl<I, Vo, X1, R> UnwindSafe for ParXap<I, Vo, X1, R>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more