Source:
<code>public ValueDistributionAnalyzerResult reduce(Collection<? extends ValueDistributionAnalyzerResult> analyzerResults) { final ValueCountList topValues = ValueCountListImpl.emptyList(); final Collection<String> uniqueValues = Collections.emptyList(); final Map<String, RowAnnotation> annotations = Collections.emptyMap(); final InputColumn<?>[] highlightedColumns = null; SingleValueDistributionResult reducedResult = new SingleValueDistributionResult(null, topValues, uniqueValues, 0, 0, 0, annotations, new RowAnnotationImpl(), _rowAnnotationFactory, highlightedColumns); for (ValueDistributionAnalyzerResult partialResult : analyzerResults) { if (partialResult instanceof SingleValueDistributionResult) { final SingleValueDistributionResult singleResult = (SingleValueDistributionResult) partialResult; <START> reducedResult = reduceSingleResult(annotations, highlightedColumns, reducedResult, singleResult); <END> } else if (partialResult instanceof GroupedValueDistributionResult) { GroupedValueDistributionResult groupedResult = (GroupedValueDistributionResult) partialResult; for (ValueCountingAnalyzerResult valueCountingResult : groupedResult.getGroupResults()) { if (valueCountingResult instanceof SingleValueDistributionResult) { SingleValueDistributionResult singleResult = (SingleValueDistributionResult) valueCountingResult; reducedResult = reduceSingleResult(annotations, highlightedColumns, reducedResult, singleResult); } else { throw new IllegalStateException("Expected " + SingleValueDistributionResult.class.getSimpleName() + ", but encountered " + valueCountingResult.getClass().getSimpleName()); } } } else { throw new IllegalStateException("Unsupported type of " + ValueDistributionAnalyzerResult.class.getSimpleName() + ": " + partialResult.getClass().getSimpleName()); } } return reducedResult; }</code><technical_language>I a pattern reduce results a time. some performance overhead of moving data out results. if reducer build big result in a iterative based result in a for-loop</technical_language>

Target:
public ValueDistributionAnalyzerResult reduce(Collection<? extends ValueDistributionAnalyzerResult> analyzerResults) { final Map<String, RowAnnotation> annotations = Collections.emptyMap(); ValueDistributionAnalyzerResult reducedResult = null; for (ValueDistributionAnalyzerResult partialResult : analyzerResults) { if (partialResult instanceof SingleValueDistributionResult) { final SingleValueDistributionResult singleReducedResult = (SingleValueDistributionResult) reducedResult; final SingleValueDistributionResult singlePartialResult = (SingleValueDistributionResult) partialResult; reducedResult = reduceSingleResult(annotations, singlePartialResult.getHighlightedColumns(), singleReducedResult, singlePartialResult); } else if (partialResult instanceof GroupedValueDistributionResult) { final GroupedValueDistributionResult groupedReducedResult = (GroupedValueDistributionResult) reducedResult; final GroupedValueDistributionResult groupedPartialResult = (GroupedValueDistributionResult) partialResult; reducedResult = reduceGroupedResult(annotations, groupedReducedResult, groupedPartialResult); } else { throw new IllegalStateException("Unsupported type of " + ValueDistributionAnalyzerResult.class.getSimpleName() + ": " + partialResult.getClass().getSimpleName()); } } return reducedResult; }