@Override public void run() { try { this.procedure = this.procedureFactory.create(); this.iterable.batchForEach(this.procedure, this.sectionIndex, this.sectionCount); } catch (Throwable newError) { this.taskRunner.setFailed(newError); } finally { this.taskRunner.taskCompleted(this); } }
public static <T, BT extends Procedure<? super T>> void forEachInBatchWithExecutor( BatchIterable<T> set, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, int minForkSize, int taskCount, Executor executor) { int size = set.size(); if (size < minForkSize) { BT procedure = procedureFactory.create(); set.forEach(procedure); if (combiner.useCombineOne()) { combiner.combineOne(procedure); } else { combiner.combineAll(iList(procedure)); } } else { int threadCount = Math.min(size, Math.min(taskCount, set.getBatchCount((int) Math.ceil((double) size / (double) taskCount)))); BatchIterableProcedureFJTaskRunner<T, BT> runner = new BatchIterableProcedureFJTaskRunner<>(combiner, threadCount); runner.executeAndCombine(executor, procedureFactory, set); } }
private static <T> int calculateTaskCount(BatchIterable<T> batchIterable, int batchSize) { return Math.max(2, batchIterable.getBatchCount(batchSize)); }
private static <T> int calculateTaskCount(BatchIterable<T> batchIterable, int batchSize) { return Math.max(2, batchIterable.getBatchCount(batchSize)); }
public static <T, BT extends Procedure<? super T>> void forEachInBatchWithExecutor( BatchIterable<T> set, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, int minForkSize, int taskCount, Executor executor) { int size = set.size(); if (size < minForkSize) { BT procedure = procedureFactory.create(); set.forEach(procedure); if (combiner.useCombineOne()) { combiner.combineOne(procedure); } else { combiner.combineAll(iList(procedure)); } } else { int threadCount = Math.min(size, Math.min(taskCount, set.getBatchCount((int) Math.ceil((double) size / (double) taskCount)))); BatchIterableProcedureFJTaskRunner<T, BT> runner = new BatchIterableProcedureFJTaskRunner<>(combiner, threadCount); runner.executeAndCombine(executor, procedureFactory, set); } }
private static <T> int calculateTaskCount(BatchIterable<T> batchIterable, int batchSize) { return Math.max(2, batchIterable.getBatchCount(batchSize)); }
@Override public void run() { try { this.procedure = this.procedureFactory.create(); this.iterable.batchForEach(this.procedure, this.sectionIndex, this.sectionCount); } catch (Throwable newError) { this.taskRunner.setFailed(newError); } finally { this.taskRunner.taskCompleted(this); } }
public static <T, BT extends Procedure<? super T>> void forEachInBatchWithExecutor( BatchIterable<T> set, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, int minForkSize, int taskCount, Executor executor) { int size = set.size(); if (size < minForkSize) { BT procedure = procedureFactory.create(); set.forEach(procedure); if (combiner.useCombineOne()) { combiner.combineOne(procedure); } else { combiner.combineAll(iList(procedure)); } } else { int threadCount = Math.min(size, Math.min(taskCount, set.getBatchCount((int) Math.ceil((double) size / (double) taskCount)))); BatchIterableProcedureFJTaskRunner<T, BT> runner = new BatchIterableProcedureFJTaskRunner<>(combiner, threadCount); runner.executeAndCombine(executor, procedureFactory, set); } }
private static <T> int calculateTaskCount(BatchIterable<T> batchIterable, int batchSize) { return Math.max(2, batchIterable.getBatchCount(batchSize)); }
@Override protected boolean exec() { try { this.procedure = this.procedureFactory.create(); this.iterable.batchForEach(this.procedure, this.sectionIndex, this.sectionCount); } catch (Throwable newError) { this.taskRunner.setFailed(newError); } finally { this.taskRunner.taskCompleted(this); } return true; }
public static <T, PT extends Procedure<? super T>> void forEachInBatchWithExecutor( BatchIterable<T> batchIterable, ProcedureFactory<PT> procedureFactory, Combiner<PT> combiner, int minForkSize, int taskCount, ForkJoinPool executor) { int size = batchIterable.size(); if (size < minForkSize || FJIterate.executedInsideOfForEach()) { PT procedure = procedureFactory.create(); batchIterable.forEach(procedure); if (combiner.useCombineOne()) { combiner.combineOne(procedure); } else { combiner.combineAll(Lists.immutable.of(procedure)); } } else { int newTaskCount = Math.min(size, Math.min(taskCount, batchIterable.getBatchCount((int) Math.ceil((double) size / (double) taskCount)))); new FJBatchIterableProcedureRunner<>(combiner, newTaskCount).executeAndCombine(executor, procedureFactory, batchIterable); } }
@Override public void run() { try { this.procedure = this.procedureFactory.create(); this.iterable.batchForEach(this.procedure, this.sectionIndex, this.sectionCount); } catch (Throwable newError) { this.taskRunner.setFailed(newError); } finally { this.taskRunner.taskCompleted(this); } }