pub struct ParXap<I, Vo, X1, R = RunnerWithPool<SequentialPool>>where
R: ParallelRunner,
I: ConcurrentIter,
Vo: TransformableValues<Fallibility = Infallible>,
X1: Fn(<I as ConcurrentIter>::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 as ConcurrentIter>::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 as ConcurrentIter>::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>) -> ParXap<I, Vo, X1, R>
fn num_threads(self, num_threads: impl Into<NumThreads>) -> ParXap<I, Vo, X1, R>
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>) -> ParXap<I, Vo, X1, R>
fn chunk_size(self, chunk_size: impl Into<ChunkSize>) -> ParXap<I, Vo, X1, R>
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) -> ParXap<I, Vo, X1, R>
fn iteration_order(self, collect: IterationOrder) -> ParXap<I, Vo, X1, R>
Sets the iteration order of the parallel computation. Read more
Sourceยงfn with_runner<Q>(
self,
orchestrator: Q,
) -> impl ParIter<Q, Item = <ParXap<I, Vo, X1, R> as ParIter<R>>::Item>where
Q: ParallelRunner,
fn with_runner<Q>(
self,
orchestrator: Q,
) -> impl ParIter<Q, Item = <ParXap<I, Vo, X1, R> as ParIter<R>>::Item>where
Q: ParallelRunner,
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 = <ParXap<I, Vo, X1, R> as ParIter<R>>::Item>
fn using<U, F>( self, using: F, ) -> impl ParIterUsing<UsingFun<F, U>, R, Item = <ParXap<I, Vo, X1, R> 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 = <ParXap<I, Vo, X1, R> as ParIter<R>>::Item>where
U: Clone + 'static,
fn using_clone<U>(
self,
value: U,
) -> impl ParIterUsing<UsingClone<U>, R, Item = <ParXap<I, Vo, X1, R> 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 = <ParXap<I, Vo, X1, R> as ParIter<R>>::Item>
fn filter<Filter>( self, filter: Filter, ) -> impl ParIter<R, Item = <ParXap<I, Vo, X1, R> as ParIter<R>>::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 as IntoIterator>::Item>
fn flat_map<IOut, FlatMap>( self, flat_map: FlatMap, ) -> impl ParIter<R, Item = <IOut as IntoIterator>::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 = <ParXap<I, Vo, X1, R> as ParIter<R>>::Item>
fn take_while<While>( self, take_while: While, ) -> impl ParIter<R, Item = <ParXap<I, Vo, X1, R> as ParIter<R>>::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>
fn into_fallible_result<Out, Err>( self, ) -> impl ParIterResult<R, Item = Out, Err = 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) -> C
fn collect_into<C>(self, output: C) -> C
Collects all the items from an iterator into a collection. Read more
Sourceยงfn reduce<Reduce>(
self,
reduce: Reduce,
) -> Option<<ParXap<I, Vo, X1, R> as ParIter<R>>::Item>
fn reduce<Reduce>( self, reduce: Reduce, ) -> Option<<ParXap<I, Vo, X1, R> as ParIter<R>>::Item>
Reduces the elements to a single one, by repeatedly applying a reducing operation. Read more
Sourceยงfn first(self) -> Option<<ParXap<I, Vo, X1, R> as ParIter<R>>::Item>
fn first(self) -> Option<<ParXap<I, Vo, X1, R> as ParIter<R>>::Item>
Returns the first (or any) element of the iterator; returns None if it is empty. Read more
Sourceยงfn with_pool<P>(
self,
pool: P,
) -> impl ParIter<RunnerWithPool<P, <R as ParallelRunner>::Executor>, Item = Self::Item>where
P: ParThreadPool,
fn with_pool<P>(
self,
pool: P,
) -> impl ParIter<RunnerWithPool<P, <R as ParallelRunner>::Executor>, Item = Self::Item>where
P: ParThreadPool,
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 as ConcurrentIter>::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 as ConcurrentIter>::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