From 0cd184ef3c9897bb483d043bf95709e9f6f6abd5 Mon Sep 17 00:00:00 2001 From: markharwood Date: Thu, 20 Mar 2014 10:59:00 +0000 Subject: [PATCH] Fix for Jenkins advice on SignificantTermsAggregatorFactory, changing a small switch statement to an if-else --- .../SignificantTermsAggregatorFactory.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantTermsAggregatorFactory.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantTermsAggregatorFactory.java index 55c3bdb70c3..af43cdf87b6 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantTermsAggregatorFactory.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantTermsAggregatorFactory.java @@ -102,29 +102,27 @@ public class SignificantTermsAggregatorFactory extends ValueSourceAggregatorFact protected Aggregator create(ValuesSource valuesSource, long expectedBucketsCount, AggregationContext aggregationContext, Aggregator parent) { numberOfAggregatorsCreated++; - switch (numberOfAggregatorsCreated) { - case 1: + if (numberOfAggregatorsCreated == 1) { // Setup a termsEnum for use by first aggregator try { SearchContext searchContext = aggregationContext.searchContext(); ContextIndexSearcher searcher = searchContext.searcher(); Terms terms = MultiFields.getTerms(searcher.getIndexReader(), indexedFieldName); - //terms can be null if the choice of field is not found in this index + // terms can be null if the choice of field is not found in this index if (terms != null) { termsEnum = terms.iterator(null); - } + } } catch (IOException e) { throw new ElasticsearchException("IOException loading background document frequency info", e); } - break; - case 2: - // When we have > 1 agg we have possibility of duplicate term frequency lookups and so introduce a cache - // in the form of a wrapper around the plain termsEnum created for use with the first agg + } else if (numberOfAggregatorsCreated == 2) { + // When we have > 1 agg we have possibility of duplicate term frequency lookups and + // so introduce a cache in the form of a wrapper around the plain termsEnum created + // for use with the first agg if (termsEnum != null) { SearchContext searchContext = aggregationContext.searchContext(); termsEnum = new FrequencyCachingTermsEnumWrapper(termsEnum, searchContext.bigArrays(), true, false); } - break; } long estimatedBucketCount = valuesSource.metaData().maxAtomicUniqueValuesCount();