Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Hendrik Muhs committed Oct 18, 2018
1 parent d0284f3 commit 50669ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.Map;
import java.util.stream.Stream;

public class AggregationResultUtils {
final class AggregationResultUtils {
private static final Logger logger = Logger.getLogger(AggregationResultUtils.class.getName());

/**
Expand All @@ -34,8 +34,7 @@ public class AggregationResultUtils {
public static Stream<Map<String, Object>> extractCompositeAggregationResults(CompositeAggregation agg,
List<CompositeValuesSourceBuilder<?>> sources, Collection<AggregationBuilder> aggregationBuilders) {
return agg.getBuckets().stream().map(bucket -> {
Map<String, Object> document;
document = new HashMap<>();
Map<String, Object> document = new HashMap<>();
for (CompositeValuesSourceBuilder<?> source : sources) {
String destinationFieldName = source.name();
document.put(destinationFieldName, bucket.getKey().get(destinationFieldName));
Expand All @@ -50,9 +49,10 @@ public static Stream<Map<String, Object>> extractCompositeAggregationResults(Com
NumericMetricsAggregation.SingleValue aggResultSingleValue = (SingleValue) aggResult;
document.put(aggName, aggResultSingleValue.value());
} else {
// should never be reached as we should prevent creating
// jobs with unsupported aggregations
logger.error("Unsupported aggregation, ignoring");
// Execution should never reach this point!
// Creating jobs with unsupported aggregations shall not be possible
logger.error("Dataframe Internal Error: unsupported aggregation ["+ aggResult.getName() +"], ignoring");
assert false;
}
}
return document;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -91,13 +92,13 @@ protected NamedXContentRegistry xContentRegistry() {
public void testExtractCompositeAggregationResults() throws IOException {
String targetField = randomAlphaOfLengthBetween(5, 10);

List<CompositeValuesSourceBuilder<?>> sources = asList(
List<CompositeValuesSourceBuilder<?>> sources = Collections.singletonList(
new TermsValuesSourceBuilder(targetField).field("doesn't_matter_for_this_test")
);

String aggName = randomAlphaOfLengthBetween(5, 10);
String aggTypedName = "avg#" + aggName;
Collection<AggregationBuilder> aggregationBuilders = asList(AggregationBuilders.avg(aggName));
Collection<AggregationBuilder> aggregationBuilders = Collections.singletonList(AggregationBuilders.avg(aggName));

Map<String, Object> input = asMap(
"buckets",
Expand Down Expand Up @@ -148,7 +149,7 @@ public void testExtractCompositeAggregationResultsMultiSources() throws IOExcept

String aggName = randomAlphaOfLengthBetween(5, 10);
String aggTypedName = "avg#" + aggName;
Collection<AggregationBuilder> aggregationBuilders = asList(AggregationBuilders.avg(aggName));
Collection<AggregationBuilder> aggregationBuilders = Collections.singletonList(AggregationBuilders.avg(aggName));

Map<String, Object> input = asMap(
"buckets",
Expand Down Expand Up @@ -210,7 +211,7 @@ aggTypedName, asMap(

public void testExtractCompositeAggregationResultsMultiAggregations() throws IOException {
String targetField = randomAlphaOfLengthBetween(5, 10);
List<CompositeValuesSourceBuilder<?>> sources = asList(
List<CompositeValuesSourceBuilder<?>> sources = Collections.singletonList(
new TermsValuesSourceBuilder(targetField).field("doesn't_matter_for_this_test")
);

Expand Down

0 comments on commit 50669ca

Please sign in to comment.