public static <T, BT extends Procedure<? super T>> void forEach( Iterable<T> iterable, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, int batchSize, Executor executor) { ParallelIterate.forEach(iterable, procedureFactory, combiner, batchSize, ParallelIterate.calculateTaskCount(iterable, batchSize), executor); }
/** * Returns a brand new ExecutorService using the specified poolName and uses the optional property named * to set the maximum thread pool size. The same poolName may be used more than * once resulting in multiple pools with the same name. */ public static ExecutorService newPooledExecutor(String poolName, boolean useDaemonThreads) { return ParallelIterate.newPooledExecutor(ParallelIterate.getDefaultMaxThreadPoolSize(), poolName, useDaemonThreads); }
public static <T, K, V> MutableMap<K, V> aggregateBy( Iterable<T> iterable, Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V, ? super T, ? extends V> nonMutatingAggregator) { return ParallelIterate.aggregateBy( iterable, groupBy, zeroValueFactory, nonMutatingAggregator, ParallelIterate.DEFAULT_MIN_FORK_SIZE); }
public static int getDefaultTaskCount() { return ParallelIterate.getDefaultMaxThreadPoolSize() * ParallelIterate.getTaskRatio(); }
static final int AVAILABLE_PROCESSORS = Runtime.getRuntime().availableProcessors(); static final int TASK_RATIO = 2; static final int DEFAULT_PARALLEL_TASK_COUNT = ParallelIterate.getDefaultTaskCount(); static final ExecutorService EXECUTOR_SERVICE = ParallelIterate.newPooledExecutor(ParallelIterate.class.getSimpleName(), true); ParallelIterate.forEach( iterable, procedureFactory, combiner, batchSize, ParallelIterate.calculateTaskCount(iterable, batchSize), executor); return (R) combiner.getResult(); ParallelIterate.forEach( iterable, new PassThruProcedureFactory<>(nonMutatingAggregationProcedure), ParallelIterate.forEach( iterable, new PassThruProcedureFactory<>(mutatingAggregationProcedure),
public static <T, BT extends Procedure<? super T>> void forEach( Iterable<T> iterable, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner) { ParallelIterate.forEach(iterable, procedureFactory, combiner, ParallelIterate.EXECUTOR_SERVICE); }
private static final int DEFAULT_PARALLEL_TASK_COUNT = ParallelIterate.getDefaultTaskCount() * 4; private static final ForkJoinPool FORK_JOIN_POOL = new ForkJoinPool(ParallelIterate.getDefaultMaxThreadPoolSize());
public static <T, K, V> MutableMap<K, V> aggregateInPlaceBy( Iterable<T> iterable, Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V, ? super T> mutatingAggregator) { return ParallelIterate.aggregateInPlaceBy( iterable, groupBy, zeroValueFactory, mutatingAggregator, ParallelIterate.DEFAULT_MIN_FORK_SIZE); }
/** * Same effect as {@link Iterate#collect(Iterable, Function)}, * but executed in parallel batches. * * @return The collected elements. The Collection will be of the same type as the input (List or Set) * and will be in the same order as the input (if it is an ordered collection). * @see ParallelIterate#collect(Iterable, Function, boolean) */ public static <T, V> Collection<V> collect( Iterable<T> iterable, Function<? super T, V> function) { return ParallelIterate.collect(iterable, function, false); }
/** * Same effect as {@link Iterate#collectIf(Iterable, Predicate, Function)}, * but executed in parallel batches. * * @return The collected elements. The Collection will be of the same type as the input (List or Set) * and will be in the same order as the input (if it is an ordered collection). * @see ParallelIterate#collectIf(Iterable, Predicate, Function, boolean) */ public static <T, V> Collection<V> collectIf( Iterable<T> iterable, Predicate<? super T> predicate, Function<? super T, V> function) { return ParallelIterate.collectIf(iterable, predicate, function, false); }
public static <T, V> Collection<V> flatCollect( Iterable<T> iterable, Function<? super T, Collection<V>> function, boolean allowReorderedResult) { return ParallelIterate.flatCollect(iterable, function, null, allowReorderedResult); }
/** * Same effect as {@link Iterate#count(Iterable, Predicate)}, but executed in parallel batches. * * @return The number of elements which satisfy the predicate. */ public static <T> int count(Iterable<T> iterable, Predicate<? super T> predicate) { return ParallelIterate.count(iterable, predicate, ParallelIterate.DEFAULT_MIN_FORK_SIZE, ParallelIterate.EXECUTOR_SERVICE); }
private static <T> int calculateTaskCount(Iterable<T> iterable, int batchSize) { if (iterable instanceof BatchIterable<?>) { return ParallelIterate.calculateTaskCount((BatchIterable<?>) iterable, batchSize); } return ParallelIterate.calculateTaskCount(Iterate.sizeOf(iterable), batchSize); }
static final int AVAILABLE_PROCESSORS = Runtime.getRuntime().availableProcessors(); static final int TASK_RATIO = 2; static final int DEFAULT_PARALLEL_TASK_COUNT = ParallelIterate.getDefaultTaskCount(); static final ExecutorService EXECUTOR_SERVICE = ParallelIterate.newPooledExecutor(ParallelIterate.class.getSimpleName(), true); ParallelIterate.forEach( iterable, procedureFactory, combiner, batchSize, ParallelIterate.calculateTaskCount(iterable, batchSize), executor); return (R) combiner.getResult(); ParallelIterate.forEach( iterable, new PassThruProcedureFactory<>(nonMutatingAggregationProcedure), ParallelIterate.forEach( iterable, new PassThruProcedureFactory<>(mutatingAggregationProcedure),
public static <T, BT extends Procedure<? super T>> void forEach( Iterable<T> iterable, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner) { ParallelIterate.forEach(iterable, procedureFactory, combiner, ParallelIterate.EXECUTOR_SERVICE); }
public static int getDefaultTaskCount() { return ParallelIterate.getDefaultMaxThreadPoolSize() * ParallelIterate.getTaskRatio(); }
public static <T, K, V> MutableMap<K, V> aggregateInPlaceBy( Iterable<T> iterable, Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V, ? super T> mutatingAggregator) { return ParallelIterate.aggregateInPlaceBy( iterable, groupBy, zeroValueFactory, mutatingAggregator, ParallelIterate.DEFAULT_MIN_FORK_SIZE); }
/** * Same effect as {@link Iterate#collect(Iterable, Function)}, * but executed in parallel batches. * * @return The collected elements. The Collection will be of the same type as the input (List or Set) * and will be in the same order as the input (if it is an ordered collection). * @see ParallelIterate#collect(Iterable, Function, boolean) */ public static <T, V> Collection<V> collect( Iterable<T> iterable, Function<? super T, V> function) { return ParallelIterate.collect(iterable, function, false); }
/** * Same effect as {@link Iterate#collectIf(Iterable, Predicate, Function)}, * but executed in parallel batches. * * @return The collected elements. The Collection will be of the same type as the input (List or Set) * and will be in the same order as the input (if it is an ordered collection). * @see ParallelIterate#collectIf(Iterable, Predicate, Function, boolean) */ public static <T, V> Collection<V> collectIf( Iterable<T> iterable, Predicate<? super T> predicate, Function<? super T, V> function) { return ParallelIterate.collectIf(iterable, predicate, function, false); }
public static <T, V> Collection<V> flatCollect( Iterable<T> iterable, Function<? super T, Collection<V>> function, boolean allowReorderedResult) { return ParallelIterate.flatCollect(iterable, function, null, allowReorderedResult); }