@Override public GTRecord next() { if (!hasNext()) { throw new NoSuchElementException(); } // get smallest record PeekingIterator<GTRecord> it = heap.poll(); // WATCH OUT! record got from PartitionResultIterator.next() may changed later, // so we must make a shallow copy of it. record.shallowCopyFrom(it.next()); if (it.hasNext()) { heap.offer(it); } return record; } }
@Override public E next() { if (!hasNext()) { throw new NoSuchElementException(); } // WATCH OUT! record returned by "input" scanner could be changed later, // so we must make a shallow copy of it. first.shallowCopyFrom(input.next()); // shortcut to avoid extra deserialize/serialize cost if (!shouldMergeNext(first)) { return finalizeResult(first); } // merge records with the same key MeasureAggregator[] aggrs = codeSystem.newMetricsAggregators(metrics, metricFuncs); aggregate(aggrs, first); aggregate(aggrs, input.next()); // no need to copy record because it's not referred to later while (shouldMergeNext(first)) { aggregate(aggrs, input.next()); } Object[] aggStates = new Object[aggrs.length]; for (int i = 0; i < aggStates.length; i++) { aggStates[i] = aggrs[i].getState(); } return finalizeResult(first, aggStates); }
@Override public GTRecord next() { if (!hasNext()) { throw new NoSuchElementException(); } // get smallest record PeekingIterator<GTRecord> it = heap.poll(); // WATCH OUT! record got from PartitionResultIterator.next() may changed later, // so we must make a shallow copy of it. record.shallowCopyFrom(it.next()); if (it.hasNext()) { heap.offer(it); } return record; } }
@Override public E next() { if (!hasNext()) { throw new NoSuchElementException(); } // WATCH OUT! record returned by "input" scanner could be changed later, // so we must make a shallow copy of it. first.shallowCopyFrom(input.next()); // shortcut to avoid extra deserialize/serialize cost if (!shouldMergeNext(first)) { return finalizeResult(first); } // merge records with the same key MeasureAggregator[] aggrs = codeSystem.newMetricsAggregators(metrics, metricFuncs); aggregate(aggrs, first); aggregate(aggrs, input.next()); // no need to copy record because it's not referred to later while (shouldMergeNext(first)) { aggregate(aggrs, input.next()); } Object[] aggStates = new Object[aggrs.length]; for (int i = 0; i < aggStates.length; i++) { aggStates[i] = aggrs[i].getState(); } return finalizeResult(first, aggStates); }