Source:
public GroupByNumericSummaryParallelIterator( final QueryNode node, final QueryResult result, final Collection<TimeSeries> sources) { expected_summary = -1; expect_sums_and_counts = false; DownsampleConfig downsampleConfig = ((GroupBy) node).getDownsampleConfig(); if (null == downsampleConfig) { throw new IllegalStateException("Shouldn't be here if the downsample was null."); } intervals = downsampleConfig.intervals(); interval = downsampleConfig.interval(); interval_in_seconds = DateTime.parseDuration(downsampleConfig.getInterval()) / 1000; start_epoch = (int) downsampleConfig.startTime().epoch(); ts = downsampleConfig.startTime().getCopy(); System.out.println(" START: " + ts.epoch()); agg = AggEnum.valueOf(((GroupByConfig) node.config()).getAggregator().toLowerCase()); infectious_nan = ((GroupByConfig) node.config()).getInfectiousNan(); dp = new MutableNumericSummaryValue(); accumulators = new Accumulator[GroupByNumericArrayIterator.NUM_THREADS]; for (int i = 0; i < accumulators.length; i++) { accumulators[i] = new Accumulator(i); } List<Future<Void>> futures = new ArrayList<>(sources.size()); int i = 0; for (final TimeSeries source : sources) { int index = (i++) % GroupByNumericArrayIterator.NUM_THREADS; final ExecutorService executorService = GroupByNumericArrayIterator.executorList.get(index); final long s = System.nanoTime(); Future<Void> future = executorService.submit( () -> { accumulators[index].accumulate(source); return null; }); futures.add(future); } for (Future<Void> future : futures) { try { future.get(); } catch (InterruptedException e) { throw new QueryDownstreamException(e.getMessage(), e); } catch (ExecutionException e) { throw new QueryDownstreamException(e.getMessage(), e); } } combine(); }

Target:
public GroupByNumericSummaryParallelIterator( final QueryNode node, final QueryResult result, final Collection<TimeSeries> sources) { expected_summary = -1; expect_sums_and_counts = false; DownsampleConfig downsampleConfig = ((GroupBy) node).getDownsampleConfig(); if (null == downsampleConfig) { throw new IllegalStateException("Shouldn't be here if the downsample was null."); } intervals = downsampleConfig.intervals(); interval = downsampleConfig.interval(); interval_in_seconds = DateTime.parseDuration(downsampleConfig.getInterval()) / 1000; start_epoch = (int) downsampleConfig.startTime().epoch(); ts = downsampleConfig.startTime().getCopy(); agg = AggEnum.valueOf(((GroupByConfig) node.config()).getAggregator().toLowerCase()); infectious_nan = ((GroupByConfig) node.config()).getInfectiousNan(); dp = new MutableNumericSummaryValue(); accumulators = new Accumulator[GroupByNumericArrayIterator.NUM_THREADS]; for (int i = 0; i < accumulators.length; i++) { accumulators[i] = new Accumulator(i); } List<Future<Void>> futures = new ArrayList<>(sources.size()); int i = 0; for (final TimeSeries source : sources) { int index = (i++) % GroupByNumericArrayIterator.NUM_THREADS; final ExecutorService executorService = GroupByNumericArrayIterator.executorList.get(index); final long s = System.nanoTime(); Future<Void> future = executorService.submit( () -> { accumulators[index].accumulate(source); return null; }); futures.add(future); } for (Future<Void> future : futures) { try { future.get(); } catch (InterruptedException e) { throw new QueryDownstreamException(e.getMessage(), e); } catch (ExecutionException e) { throw new QueryDownstreamException(e.getMessage(), e); } } combine(); }