|
@@ -351,14 +351,14 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
|
|
|
|
|
if (factories == AggregatorFactories.EMPTY &&
|
|
if (factories == AggregatorFactories.EMPTY &&
|
|
includeExclude == null &&
|
|
includeExclude == null &&
|
|
- Aggregator.descendsFromBucketAggregator(parent) == false &&
|
|
|
|
|
|
+ collectsFromSingleBucket &&
|
|
ordinalsValuesSource.supportsGlobalOrdinalsMapping() &&
|
|
ordinalsValuesSource.supportsGlobalOrdinalsMapping() &&
|
|
// we use the static COLLECT_SEGMENT_ORDS to allow tests to force specific optimizations
|
|
// we use the static COLLECT_SEGMENT_ORDS to allow tests to force specific optimizations
|
|
(COLLECT_SEGMENT_ORDS!= null ? COLLECT_SEGMENT_ORDS.booleanValue() : ratio <= 0.5 && maxOrd <= 2048)) {
|
|
(COLLECT_SEGMENT_ORDS!= null ? COLLECT_SEGMENT_ORDS.booleanValue() : ratio <= 0.5 && maxOrd <= 2048)) {
|
|
- /**
|
|
|
|
|
|
+ /*
|
|
* We can use the low cardinality execution mode iff this aggregator:
|
|
* We can use the low cardinality execution mode iff this aggregator:
|
|
* - has no sub-aggregator AND
|
|
* - has no sub-aggregator AND
|
|
- * - is not a child of a bucket aggregator AND
|
|
|
|
|
|
+ * - collects from a single bucket AND
|
|
* - has a values source that can map from segment to global ordinals
|
|
* - has a values source that can map from segment to global ordinals
|
|
* - At least we reduce the number of global ordinals look-ups by half (ration <= 0.5) AND
|
|
* - At least we reduce the number of global ordinals look-ups by half (ration <= 0.5) AND
|
|
* - the maximum global ordinal is less than 2048 (LOW_CARDINALITY has additional memory usage,
|
|
* - the maximum global ordinal is less than 2048 (LOW_CARDINALITY has additional memory usage,
|
|
@@ -382,16 +382,16 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
|
} else {
|
|
} else {
|
|
remapGlobalOrds = true;
|
|
remapGlobalOrds = true;
|
|
if (includeExclude == null &&
|
|
if (includeExclude == null &&
|
|
- Aggregator.descendsFromBucketAggregator(parent) == false &&
|
|
|
|
|
|
+ collectsFromSingleBucket &&
|
|
(factories == AggregatorFactories.EMPTY ||
|
|
(factories == AggregatorFactories.EMPTY ||
|
|
(isAggregationSort(order) == false && subAggCollectMode == SubAggCollectionMode.BREADTH_FIRST))) {
|
|
(isAggregationSort(order) == false && subAggCollectMode == SubAggCollectionMode.BREADTH_FIRST))) {
|
|
- /**
|
|
|
|
|
|
+ /*
|
|
* We don't need to remap global ords iff this aggregator:
|
|
* We don't need to remap global ords iff this aggregator:
|
|
* - has no include/exclude rules AND
|
|
* - has no include/exclude rules AND
|
|
- * - is not a child of a bucket aggregator AND
|
|
|
|
|
|
+ * - only collects from a single bucket AND
|
|
* - has no sub-aggregator or only sub-aggregator that can be deferred
|
|
* - has no sub-aggregator or only sub-aggregator that can be deferred
|
|
* ({@link SubAggCollectionMode#BREADTH_FIRST}).
|
|
* ({@link SubAggCollectionMode#BREADTH_FIRST}).
|
|
- **/
|
|
|
|
|
|
+ */
|
|
remapGlobalOrds = false;
|
|
remapGlobalOrds = false;
|
|
}
|
|
}
|
|
}
|
|
}
|