mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
parent
12813d5918
commit
1f500583b1
@ -20,7 +20,6 @@
|
|||||||
package org.elasticsearch.search.aggregations.bucket.range;
|
package org.elasticsearch.search.aggregations.bucket.range;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
|
||||||
import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
||||||
import org.elasticsearch.search.aggregations.Aggregator;
|
import org.elasticsearch.search.aggregations.Aggregator;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||||
@ -37,7 +36,6 @@ import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
|||||||
import org.elasticsearch.search.internal.SearchContext;
|
import org.elasticsearch.search.internal.SearchContext;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class AbstractRangeAggregatorFactory<R extends Range> extends ValuesSourceAggregatorFactory {
|
public class AbstractRangeAggregatorFactory<R extends Range> extends ValuesSourceAggregatorFactory {
|
||||||
@ -50,24 +48,10 @@ public class AbstractRangeAggregatorFactory<R extends Range> extends ValuesSourc
|
|||||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder,
|
public static void registerAggregators(ValuesSourceRegistry.Builder builder,
|
||||||
String aggregationName) {
|
String aggregationName) {
|
||||||
builder.register(aggregationName,
|
builder.register(aggregationName,
|
||||||
Arrays.asList(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
org.elasticsearch.common.collect.List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
||||||
new RangeAggregatorSupplier() {
|
(RangeAggregatorSupplier) RangeAggregator::new);
|
||||||
@Override
|
|
||||||
public Aggregator build(String name,
|
|
||||||
AggregatorFactories factories,
|
|
||||||
Numeric valuesSource,
|
|
||||||
DocValueFormat format,
|
|
||||||
InternalRange.Factory rangeFactory,
|
|
||||||
Range[] ranges,
|
|
||||||
boolean keyed,
|
|
||||||
SearchContext context,
|
|
||||||
Aggregator parent,
|
|
||||||
Map<String, Object> metadata) throws IOException {
|
|
||||||
return new RangeAggregator(name, factories, valuesSource, format, rangeFactory, ranges, keyed, context, parent,
|
|
||||||
metadata);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractRangeAggregatorFactory(String name,
|
public AbstractRangeAggregatorFactory(String name,
|
||||||
String aggregationTypeName,
|
String aggregationTypeName,
|
||||||
ValuesSourceConfig config,
|
ValuesSourceConfig config,
|
||||||
|
@ -31,6 +31,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation;
|
|||||||
import org.elasticsearch.search.aggregations.LeafBucketCollector;
|
import org.elasticsearch.search.aggregations.LeafBucketCollector;
|
||||||
import org.elasticsearch.search.aggregations.LeafBucketCollectorBase;
|
import org.elasticsearch.search.aggregations.LeafBucketCollectorBase;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
||||||
import org.elasticsearch.search.internal.SearchContext;
|
import org.elasticsearch.search.internal.SearchContext;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -45,11 +46,11 @@ class AvgAggregator extends NumericMetricsAggregator.SingleValue {
|
|||||||
DoubleArray compensations;
|
DoubleArray compensations;
|
||||||
DocValueFormat format;
|
DocValueFormat format;
|
||||||
|
|
||||||
AvgAggregator(String name, ValuesSource.Numeric valuesSource, DocValueFormat formatter, SearchContext context,
|
AvgAggregator(String name, ValuesSourceConfig valuesSourceConfig, ValuesSource valuesSource, SearchContext context,
|
||||||
Aggregator parent, Map<String, Object> metadata) throws IOException {
|
Aggregator parent, Map<String, Object> metadata) throws IOException {
|
||||||
super(name, context, parent, metadata);
|
super(name, context, parent, metadata);
|
||||||
this.valuesSource = valuesSource;
|
this.valuesSource = (ValuesSource.Numeric) valuesSource;
|
||||||
this.format = formatter;
|
this.format = valuesSourceConfig.format();
|
||||||
if (valuesSource != null) {
|
if (valuesSource != null) {
|
||||||
final BigArrays bigArrays = context.bigArrays();
|
final BigArrays bigArrays = context.bigArrays();
|
||||||
counts = bigArrays.newLongArray(1, true);
|
counts = bigArrays.newLongArray(1, true);
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package org.elasticsearch.search.aggregations.metrics;
|
package org.elasticsearch.search.aggregations.metrics;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
|
||||||
import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
||||||
import org.elasticsearch.search.aggregations.Aggregator;
|
import org.elasticsearch.search.aggregations.Aggregator;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||||
@ -28,14 +27,12 @@ import org.elasticsearch.search.aggregations.AggregatorFactory;
|
|||||||
import org.elasticsearch.search.aggregations.support.AggregatorSupplier;
|
import org.elasticsearch.search.aggregations.support.AggregatorSupplier;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSource.Numeric;
|
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
||||||
import org.elasticsearch.search.internal.SearchContext;
|
import org.elasticsearch.search.internal.SearchContext;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
class AvgAggregatorFactory extends ValuesSourceAggregatorFactory {
|
class AvgAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
@ -48,25 +45,16 @@ class AvgAggregatorFactory extends ValuesSourceAggregatorFactory {
|
|||||||
|
|
||||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||||
builder.register(AvgAggregationBuilder.NAME,
|
builder.register(AvgAggregationBuilder.NAME,
|
||||||
Arrays.asList(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
org.elasticsearch.common.collect.List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
||||||
new MetricAggregatorSupplier() {
|
(MetricAggregatorSupplier) AvgAggregator::new
|
||||||
@Override
|
);
|
||||||
public Aggregator build(String name,
|
|
||||||
ValuesSource valuesSource,
|
|
||||||
DocValueFormat formatter,
|
|
||||||
SearchContext context,
|
|
||||||
Aggregator parent,
|
|
||||||
Map<String, Object> metadata) throws IOException {
|
|
||||||
return new AvgAggregator(name, (Numeric) valuesSource, formatter, context, parent, metadata);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Aggregator createUnmapped(SearchContext searchContext,
|
protected Aggregator createUnmapped(SearchContext searchContext,
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
return new AvgAggregator(name, null, config.format(), searchContext, parent, metadata);
|
return new AvgAggregator(name, config, null, searchContext, parent, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -82,6 +70,6 @@ class AvgAggregatorFactory extends ValuesSourceAggregatorFactory {
|
|||||||
throw new AggregationExecutionException("Registry miss-match - expected MetricAggregatorSupplier, found [" +
|
throw new AggregationExecutionException("Registry miss-match - expected MetricAggregatorSupplier, found [" +
|
||||||
aggregatorSupplier.getClass().toString() + "]");
|
aggregatorSupplier.getClass().toString() + "]");
|
||||||
}
|
}
|
||||||
return ((MetricAggregatorSupplier) aggregatorSupplier).build(name, valuesSource, config.format(), searchContext, parent, metadata);
|
return ((MetricAggregatorSupplier) aggregatorSupplier).build(name, config, valuesSource, searchContext, parent, metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,9 +50,9 @@ final class GeoBoundsAggregator extends MetricsAggregator {
|
|||||||
DoubleArray negRights;
|
DoubleArray negRights;
|
||||||
|
|
||||||
GeoBoundsAggregator(String name, SearchContext aggregationContext, Aggregator parent,
|
GeoBoundsAggregator(String name, SearchContext aggregationContext, Aggregator parent,
|
||||||
ValuesSource.GeoPoint valuesSource, boolean wrapLongitude, Map<String, Object> metadata) throws IOException {
|
ValuesSource valuesSource, boolean wrapLongitude, Map<String, Object> metadata) throws IOException {
|
||||||
super(name, aggregationContext, parent, metadata);
|
super(name, aggregationContext, parent, metadata);
|
||||||
this.valuesSource = valuesSource;
|
this.valuesSource = (ValuesSource.GeoPoint) valuesSource;
|
||||||
this.wrapLongitude = wrapLongitude;
|
this.wrapLongitude = wrapLongitude;
|
||||||
if (valuesSource != null) {
|
if (valuesSource != null) {
|
||||||
final BigArrays bigArrays = context.bigArrays();
|
final BigArrays bigArrays = context.bigArrays();
|
||||||
|
@ -76,8 +76,6 @@ class GeoBoundsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
|||||||
|
|
||||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||||
builder.register(GeoBoundsAggregationBuilder.NAME, CoreValuesSourceType.GEOPOINT,
|
builder.register(GeoBoundsAggregationBuilder.NAME, CoreValuesSourceType.GEOPOINT,
|
||||||
(GeoBoundsAggregatorSupplier) (name, aggregationContext, parent, valuesSource, wrapLongitude, metadata)
|
(GeoBoundsAggregatorSupplier) GeoBoundsAggregator::new);
|
||||||
-> new GeoBoundsAggregator(name, aggregationContext, parent, (ValuesSource.GeoPoint) valuesSource,
|
|
||||||
wrapLongitude, metadata));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,9 @@ final class GeoCentroidAggregator extends MetricsAggregator {
|
|||||||
private LongArray counts;
|
private LongArray counts;
|
||||||
|
|
||||||
GeoCentroidAggregator(String name, SearchContext context, Aggregator parent,
|
GeoCentroidAggregator(String name, SearchContext context, Aggregator parent,
|
||||||
ValuesSource.GeoPoint valuesSource, Map<String, Object> metadata) throws IOException {
|
ValuesSource valuesSource, Map<String, Object> metadata) throws IOException {
|
||||||
super(name, context, parent, metadata);
|
super(name, context, parent, metadata);
|
||||||
this.valuesSource = valuesSource;
|
this.valuesSource = (ValuesSource.GeoPoint) valuesSource;
|
||||||
if (valuesSource != null) {
|
if (valuesSource != null) {
|
||||||
final BigArrays bigArrays = context.bigArrays();
|
final BigArrays bigArrays = context.bigArrays();
|
||||||
lonSum = bigArrays.newDoubleArray(1, true);
|
lonSum = bigArrays.newDoubleArray(1, true);
|
||||||
|
@ -71,7 +71,6 @@ class GeoCentroidAggregatorFactory extends ValuesSourceAggregatorFactory {
|
|||||||
|
|
||||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||||
builder.register(GeoCentroidAggregationBuilder.NAME, CoreValuesSourceType.GEOPOINT,
|
builder.register(GeoCentroidAggregationBuilder.NAME, CoreValuesSourceType.GEOPOINT,
|
||||||
(GeoCentroidAggregatorSupplier) (name, context, parent, valuesSource, metadata) ->
|
(GeoCentroidAggregatorSupplier) GeoCentroidAggregator::new);
|
||||||
new GeoCentroidAggregator(name, context, parent, (ValuesSource.GeoPoint) valuesSource, metadata));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,11 +58,11 @@ class MaxAggregator extends NumericMetricsAggregator.SingleValue {
|
|||||||
|
|
||||||
MaxAggregator(String name,
|
MaxAggregator(String name,
|
||||||
ValuesSourceConfig config,
|
ValuesSourceConfig config,
|
||||||
ValuesSource.Numeric valuesSource,
|
ValuesSource valuesSource,
|
||||||
SearchContext context,
|
SearchContext context,
|
||||||
Aggregator parent, Map<String, Object> metadata) throws IOException {
|
Aggregator parent, Map<String, Object> metadata) throws IOException {
|
||||||
super(name, context, parent, metadata);
|
super(name, context, parent, metadata);
|
||||||
this.valuesSource = valuesSource;
|
this.valuesSource = (ValuesSource.Numeric) valuesSource;
|
||||||
if (valuesSource != null) {
|
if (valuesSource != null) {
|
||||||
maxes = context.bigArrays().newDoubleArray(1, false);
|
maxes = context.bigArrays().newDoubleArray(1, false);
|
||||||
maxes.fill(0, maxes.size(), Double.NEGATIVE_INFINITY);
|
maxes.fill(0, maxes.size(), Double.NEGATIVE_INFINITY);
|
||||||
|
@ -27,32 +27,20 @@ import org.elasticsearch.search.aggregations.AggregatorFactory;
|
|||||||
import org.elasticsearch.search.aggregations.support.AggregatorSupplier;
|
import org.elasticsearch.search.aggregations.support.AggregatorSupplier;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSource.Numeric;
|
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
||||||
import org.elasticsearch.search.internal.SearchContext;
|
import org.elasticsearch.search.internal.SearchContext;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
class MaxAggregatorFactory extends ValuesSourceAggregatorFactory {
|
class MaxAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
|
|
||||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||||
builder.register(MaxAggregationBuilder.NAME,
|
builder.register(MaxAggregationBuilder.NAME,
|
||||||
Arrays.asList(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
org.elasticsearch.common.collect.List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
||||||
new MinMaxAggregatorSupplier() {
|
(MetricAggregatorSupplier) MaxAggregator::new);
|
||||||
@Override
|
|
||||||
public Aggregator build(String name,
|
|
||||||
ValuesSourceConfig config,
|
|
||||||
ValuesSource valuesSource,
|
|
||||||
SearchContext context,
|
|
||||||
Aggregator parent,
|
|
||||||
Map<String, Object> metadata) throws IOException {
|
|
||||||
return new MaxAggregator(name, config, (Numeric) valuesSource, context, parent, metadata);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MaxAggregatorFactory(String name, ValuesSourceConfig config, QueryShardContext queryShardContext,
|
MaxAggregatorFactory(String name, ValuesSourceConfig config, QueryShardContext queryShardContext,
|
||||||
@ -77,11 +65,10 @@ class MaxAggregatorFactory extends ValuesSourceAggregatorFactory {
|
|||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
||||||
MaxAggregationBuilder.NAME);
|
MaxAggregationBuilder.NAME);
|
||||||
|
|
||||||
if (aggregatorSupplier instanceof MinMaxAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof MetricAggregatorSupplier == false) {
|
||||||
throw new AggregationExecutionException("Registry miss-match - expected MinMaxAggregatorSupplier, found [" +
|
throw new AggregationExecutionException("Registry miss-match - expected MetricAggregatorSupplier, found [" +
|
||||||
aggregatorSupplier.getClass().toString() + "]");
|
aggregatorSupplier.getClass().toString() + "]");
|
||||||
}
|
}
|
||||||
return ((MinMaxAggregatorSupplier) aggregatorSupplier).build(name, config, valuesSource, searchContext, parent,
|
return ((MetricAggregatorSupplier) aggregatorSupplier).build(name, config, valuesSource, searchContext, parent, metadata);
|
||||||
metadata);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,16 +50,16 @@ public class MedianAbsoluteDeviationAggregator extends NumericMetricsAggregator.
|
|||||||
private ObjectArray<TDigestState> valueSketches;
|
private ObjectArray<TDigestState> valueSketches;
|
||||||
|
|
||||||
MedianAbsoluteDeviationAggregator(String name,
|
MedianAbsoluteDeviationAggregator(String name,
|
||||||
SearchContext context,
|
@Nullable ValuesSource valuesSource,
|
||||||
|
DocValueFormat format,
|
||||||
|
SearchContext context,
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
Map<String, Object> metadata,
|
Map<String, Object> metadata,
|
||||||
@Nullable ValuesSource.Numeric valuesSource,
|
|
||||||
DocValueFormat format,
|
|
||||||
double compression) throws IOException {
|
double compression) throws IOException {
|
||||||
|
|
||||||
super(name, context, parent, metadata);
|
super(name, context, parent, metadata);
|
||||||
|
|
||||||
this.valuesSource = valuesSource;
|
this.valuesSource = (ValuesSource.Numeric) valuesSource;
|
||||||
this.format = Objects.requireNonNull(format);
|
this.format = Objects.requireNonNull(format);
|
||||||
this.compression = compression;
|
this.compression = compression;
|
||||||
this.valueSketches = context.bigArrays().newObjectArray(1);
|
this.valueSketches = context.bigArrays().newObjectArray(1);
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package org.elasticsearch.search.aggregations.metrics;
|
package org.elasticsearch.search.aggregations.metrics;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
|
||||||
import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
||||||
import org.elasticsearch.search.aggregations.Aggregator;
|
import org.elasticsearch.search.aggregations.Aggregator;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||||
@ -54,27 +53,7 @@ public class MedianAbsoluteDeviationAggregatorFactory extends ValuesSourceAggreg
|
|||||||
|
|
||||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||||
builder.register(MedianAbsoluteDeviationAggregationBuilder.NAME,
|
builder.register(MedianAbsoluteDeviationAggregationBuilder.NAME,
|
||||||
CoreValuesSourceType.NUMERIC,
|
CoreValuesSourceType.NUMERIC, (MedianAbsoluteDeviationAggregatorSupplier) MedianAbsoluteDeviationAggregator::new);
|
||||||
new MedianAbsoluteDeviationAggregatorSupplier() {
|
|
||||||
@Override
|
|
||||||
public Aggregator build(String name,
|
|
||||||
ValuesSource valuesSource,
|
|
||||||
DocValueFormat format,
|
|
||||||
SearchContext context,
|
|
||||||
Aggregator parent,
|
|
||||||
Map<String, Object> metadata,
|
|
||||||
double compression) throws IOException {
|
|
||||||
return new MedianAbsoluteDeviationAggregator(
|
|
||||||
name,
|
|
||||||
context,
|
|
||||||
parent,
|
|
||||||
metadata,
|
|
||||||
(ValuesSource.Numeric) valuesSource,
|
|
||||||
format,
|
|
||||||
compression
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -84,11 +63,11 @@ public class MedianAbsoluteDeviationAggregatorFactory extends ValuesSourceAggreg
|
|||||||
|
|
||||||
return new MedianAbsoluteDeviationAggregator(
|
return new MedianAbsoluteDeviationAggregator(
|
||||||
name,
|
name,
|
||||||
|
null,
|
||||||
|
config.format(),
|
||||||
searchContext,
|
searchContext,
|
||||||
parent,
|
parent,
|
||||||
metadata,
|
metadata,
|
||||||
null,
|
|
||||||
config.format(),
|
|
||||||
compression
|
compression
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.elasticsearch.search.aggregations.metrics;
|
package org.elasticsearch.search.aggregations.metrics;
|
||||||
|
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
|
||||||
import org.elasticsearch.search.aggregations.Aggregator;
|
import org.elasticsearch.search.aggregations.Aggregator;
|
||||||
import org.elasticsearch.search.aggregations.support.AggregatorSupplier;
|
import org.elasticsearch.search.aggregations.support.AggregatorSupplier;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
||||||
import org.elasticsearch.search.internal.SearchContext;
|
import org.elasticsearch.search.internal.SearchContext;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -29,8 +29,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
public interface MetricAggregatorSupplier extends AggregatorSupplier {
|
public interface MetricAggregatorSupplier extends AggregatorSupplier {
|
||||||
Aggregator build(String name,
|
Aggregator build(String name,
|
||||||
|
ValuesSourceConfig valuesSourceConfig,
|
||||||
ValuesSource valuesSource,
|
ValuesSource valuesSource,
|
||||||
DocValueFormat format,
|
|
||||||
SearchContext context,
|
SearchContext context,
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
Map<String, Object> metadata) throws IOException;
|
Map<String, Object> metadata) throws IOException;
|
||||||
|
@ -61,12 +61,12 @@ class MinAggregator extends NumericMetricsAggregator.SingleValue {
|
|||||||
|
|
||||||
MinAggregator(String name,
|
MinAggregator(String name,
|
||||||
ValuesSourceConfig config,
|
ValuesSourceConfig config,
|
||||||
ValuesSource.Numeric valuesSource,
|
ValuesSource valuesSource,
|
||||||
SearchContext context,
|
SearchContext context,
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
super(name, context, parent, metadata);
|
super(name, context, parent, metadata);
|
||||||
this.valuesSource = valuesSource;
|
this.valuesSource = (ValuesSource.Numeric) valuesSource;
|
||||||
if (valuesSource != null) {
|
if (valuesSource != null) {
|
||||||
mins = context.bigArrays().newDoubleArray(1, false);
|
mins = context.bigArrays().newDoubleArray(1, false);
|
||||||
mins.fill(0, mins.size(), Double.POSITIVE_INFINITY);
|
mins.fill(0, mins.size(), Double.POSITIVE_INFINITY);
|
||||||
|
@ -27,32 +27,20 @@ import org.elasticsearch.search.aggregations.AggregatorFactory;
|
|||||||
import org.elasticsearch.search.aggregations.support.AggregatorSupplier;
|
import org.elasticsearch.search.aggregations.support.AggregatorSupplier;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSource.Numeric;
|
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
||||||
import org.elasticsearch.search.internal.SearchContext;
|
import org.elasticsearch.search.internal.SearchContext;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
class MinAggregatorFactory extends ValuesSourceAggregatorFactory {
|
class MinAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
|
|
||||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||||
builder.register(MinAggregationBuilder.NAME,
|
builder.register(MinAggregationBuilder.NAME,
|
||||||
Arrays.asList(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
org.elasticsearch.common.collect.List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
||||||
new MinMaxAggregatorSupplier() {
|
(MetricAggregatorSupplier) MinAggregator::new);
|
||||||
@Override
|
|
||||||
public Aggregator build(String name,
|
|
||||||
ValuesSourceConfig config,
|
|
||||||
ValuesSource valuesSource,
|
|
||||||
SearchContext context,
|
|
||||||
Aggregator parent,
|
|
||||||
Map<String, Object> metadata) throws IOException {
|
|
||||||
return new MinAggregator(name, config, (Numeric) valuesSource, context, parent, metadata);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MinAggregatorFactory(String name, ValuesSourceConfig config, QueryShardContext queryShardContext,
|
MinAggregatorFactory(String name, ValuesSourceConfig config, QueryShardContext queryShardContext,
|
||||||
@ -77,10 +65,10 @@ class MinAggregatorFactory extends ValuesSourceAggregatorFactory {
|
|||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
||||||
MinAggregationBuilder.NAME);
|
MinAggregationBuilder.NAME);
|
||||||
|
|
||||||
if (aggregatorSupplier instanceof MinMaxAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof MetricAggregatorSupplier == false) {
|
||||||
throw new AggregationExecutionException("Registry miss-match - expected MinMaxAggregatorSupplier, found [" +
|
throw new AggregationExecutionException("Registry miss-match - expected MetricAggregatorSupplier, found [" +
|
||||||
aggregatorSupplier.getClass().toString() + "]");
|
aggregatorSupplier.getClass().toString() + "]");
|
||||||
}
|
}
|
||||||
return ((MinMaxAggregatorSupplier) aggregatorSupplier).build(name, config, valuesSource, searchContext, parent, metadata);
|
return ((MetricAggregatorSupplier) aggregatorSupplier).build(name, config, valuesSource, searchContext, parent, metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Licensed to Elasticsearch under one or more contributor
|
|
||||||
* license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright
|
|
||||||
* ownership. Elasticsearch licenses this file to you under
|
|
||||||
* the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
* not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package org.elasticsearch.search.aggregations.metrics;
|
|
||||||
|
|
||||||
import org.elasticsearch.search.aggregations.Aggregator;
|
|
||||||
import org.elasticsearch.search.aggregations.support.AggregatorSupplier;
|
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
|
||||||
import org.elasticsearch.search.internal.SearchContext;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public interface MinMaxAggregatorSupplier extends AggregatorSupplier {
|
|
||||||
Aggregator build(String name,
|
|
||||||
ValuesSourceConfig config,
|
|
||||||
ValuesSource valuesSource,
|
|
||||||
SearchContext context,
|
|
||||||
Aggregator parent,
|
|
||||||
Map<String, Object> metadata) throws IOException;
|
|
||||||
}
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation;
|
|||||||
import org.elasticsearch.search.aggregations.LeafBucketCollector;
|
import org.elasticsearch.search.aggregations.LeafBucketCollector;
|
||||||
import org.elasticsearch.search.aggregations.LeafBucketCollectorBase;
|
import org.elasticsearch.search.aggregations.LeafBucketCollectorBase;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
||||||
import org.elasticsearch.search.internal.SearchContext;
|
import org.elasticsearch.search.internal.SearchContext;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -47,10 +48,10 @@ class StatsAggregator extends NumericMetricsAggregator.MultiValue {
|
|||||||
DoubleArray mins;
|
DoubleArray mins;
|
||||||
DoubleArray maxes;
|
DoubleArray maxes;
|
||||||
|
|
||||||
StatsAggregator(String name, ValuesSource.Numeric valuesSource, DocValueFormat format,
|
StatsAggregator(String name, ValuesSourceConfig valuesSourceConfig, ValuesSource valuesSource,
|
||||||
SearchContext context, Aggregator parent, Map<String, Object> metadata) throws IOException {
|
SearchContext context, Aggregator parent, Map<String, Object> metadata) throws IOException {
|
||||||
super(name, context, parent, metadata);
|
super(name, context, parent, metadata);
|
||||||
this.valuesSource = valuesSource;
|
this.valuesSource = (ValuesSource.Numeric) valuesSource;
|
||||||
if (valuesSource != null) {
|
if (valuesSource != null) {
|
||||||
final BigArrays bigArrays = context.bigArrays();
|
final BigArrays bigArrays = context.bigArrays();
|
||||||
counts = bigArrays.newLongArray(1, true);
|
counts = bigArrays.newLongArray(1, true);
|
||||||
@ -61,7 +62,7 @@ class StatsAggregator extends NumericMetricsAggregator.MultiValue {
|
|||||||
maxes = bigArrays.newDoubleArray(1, false);
|
maxes = bigArrays.newDoubleArray(1, false);
|
||||||
maxes.fill(0, maxes.size(), Double.NEGATIVE_INFINITY);
|
maxes.fill(0, maxes.size(), Double.NEGATIVE_INFINITY);
|
||||||
}
|
}
|
||||||
this.format = format;
|
this.format = valuesSourceConfig.format();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package org.elasticsearch.search.aggregations.metrics;
|
package org.elasticsearch.search.aggregations.metrics;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
|
||||||
import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
||||||
import org.elasticsearch.search.aggregations.Aggregator;
|
import org.elasticsearch.search.aggregations.Aggregator;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||||
@ -28,14 +27,12 @@ import org.elasticsearch.search.aggregations.AggregatorFactory;
|
|||||||
import org.elasticsearch.search.aggregations.support.AggregatorSupplier;
|
import org.elasticsearch.search.aggregations.support.AggregatorSupplier;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSource.Numeric;
|
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
||||||
import org.elasticsearch.search.internal.SearchContext;
|
import org.elasticsearch.search.internal.SearchContext;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
class StatsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
class StatsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
@ -51,25 +48,15 @@ class StatsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
|||||||
|
|
||||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||||
builder.register(StatsAggregationBuilder.NAME,
|
builder.register(StatsAggregationBuilder.NAME,
|
||||||
Arrays.asList(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
org.elasticsearch.common.collect.List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
||||||
new MetricAggregatorSupplier() {
|
(MetricAggregatorSupplier) StatsAggregator::new);
|
||||||
@Override
|
|
||||||
public Aggregator build(String name,
|
|
||||||
ValuesSource valuesSource,
|
|
||||||
DocValueFormat formatter,
|
|
||||||
SearchContext context,
|
|
||||||
Aggregator parent,
|
|
||||||
Map<String, Object> metadata) throws IOException {
|
|
||||||
return new StatsAggregator(name, (Numeric) valuesSource, formatter, context, parent, metadata);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Aggregator createUnmapped(SearchContext searchContext,
|
protected Aggregator createUnmapped(SearchContext searchContext,
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
return new StatsAggregator(name, null, config.format(), searchContext, parent, metadata);
|
return new StatsAggregator(name, config, null, searchContext, parent, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -85,6 +72,6 @@ class StatsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
|||||||
throw new AggregationExecutionException("Registry miss-match - expected MetricAggregatorSupplier, found [" +
|
throw new AggregationExecutionException("Registry miss-match - expected MetricAggregatorSupplier, found [" +
|
||||||
aggregatorSupplier.getClass().toString() + "]");
|
aggregatorSupplier.getClass().toString() + "]");
|
||||||
}
|
}
|
||||||
return ((MetricAggregatorSupplier) aggregatorSupplier).build(name, valuesSource, config.format(), searchContext, parent, metadata);
|
return ((MetricAggregatorSupplier) aggregatorSupplier).build(name, config, valuesSource, searchContext, parent, metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation;
|
|||||||
import org.elasticsearch.search.aggregations.LeafBucketCollector;
|
import org.elasticsearch.search.aggregations.LeafBucketCollector;
|
||||||
import org.elasticsearch.search.aggregations.LeafBucketCollectorBase;
|
import org.elasticsearch.search.aggregations.LeafBucketCollectorBase;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
||||||
import org.elasticsearch.search.internal.SearchContext;
|
import org.elasticsearch.search.internal.SearchContext;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -43,11 +44,11 @@ public class SumAggregator extends NumericMetricsAggregator.SingleValue {
|
|||||||
private DoubleArray sums;
|
private DoubleArray sums;
|
||||||
private DoubleArray compensations;
|
private DoubleArray compensations;
|
||||||
|
|
||||||
SumAggregator(String name, ValuesSource.Numeric valuesSource, DocValueFormat formatter, SearchContext context,
|
SumAggregator(String name, ValuesSourceConfig valuesSourceConfig, ValuesSource valuesSource, SearchContext context,
|
||||||
Aggregator parent, Map<String, Object> metadata) throws IOException {
|
Aggregator parent, Map<String, Object> metadata) throws IOException {
|
||||||
super(name, context, parent, metadata);
|
super(name, context, parent, metadata);
|
||||||
this.valuesSource = valuesSource;
|
this.valuesSource = (ValuesSource.Numeric) valuesSource;
|
||||||
this.format = formatter;
|
this.format = valuesSourceConfig.format();
|
||||||
if (valuesSource != null) {
|
if (valuesSource != null) {
|
||||||
sums = context.bigArrays().newDoubleArray(1, true);
|
sums = context.bigArrays().newDoubleArray(1, true);
|
||||||
compensations = context.bigArrays().newDoubleArray(1, true);
|
compensations = context.bigArrays().newDoubleArray(1, true);
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package org.elasticsearch.search.aggregations.metrics;
|
package org.elasticsearch.search.aggregations.metrics;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
|
||||||
import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
||||||
import org.elasticsearch.search.aggregations.Aggregator;
|
import org.elasticsearch.search.aggregations.Aggregator;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||||
@ -28,14 +27,12 @@ import org.elasticsearch.search.aggregations.AggregatorFactory;
|
|||||||
import org.elasticsearch.search.aggregations.support.AggregatorSupplier;
|
import org.elasticsearch.search.aggregations.support.AggregatorSupplier;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSource.Numeric;
|
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
||||||
import org.elasticsearch.search.internal.SearchContext;
|
import org.elasticsearch.search.internal.SearchContext;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
class SumAggregatorFactory extends ValuesSourceAggregatorFactory {
|
class SumAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
@ -51,18 +48,8 @@ class SumAggregatorFactory extends ValuesSourceAggregatorFactory {
|
|||||||
|
|
||||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||||
builder.register(SumAggregationBuilder.NAME,
|
builder.register(SumAggregationBuilder.NAME,
|
||||||
Arrays.asList(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
org.elasticsearch.common.collect.List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
||||||
new MetricAggregatorSupplier() {
|
(MetricAggregatorSupplier) SumAggregator::new);
|
||||||
@Override
|
|
||||||
public Aggregator build(String name,
|
|
||||||
ValuesSource valuesSource,
|
|
||||||
DocValueFormat formatter,
|
|
||||||
SearchContext context,
|
|
||||||
Aggregator parent,
|
|
||||||
Map<String, Object> metadata) throws IOException {
|
|
||||||
return new SumAggregator(name, (Numeric) valuesSource, formatter, context, parent, metadata);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -70,7 +57,7 @@ class SumAggregatorFactory extends ValuesSourceAggregatorFactory {
|
|||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
Map<String, Object> metadata)
|
Map<String, Object> metadata)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
return new SumAggregator(name, null, config.format(), searchContext, parent, metadata);
|
return new SumAggregator(name, config, null, searchContext, parent, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -86,6 +73,6 @@ class SumAggregatorFactory extends ValuesSourceAggregatorFactory {
|
|||||||
throw new AggregationExecutionException("Registry miss-match - expected MetricAggregatorSupplier, found [" +
|
throw new AggregationExecutionException("Registry miss-match - expected MetricAggregatorSupplier, found [" +
|
||||||
aggregatorSupplier.getClass().toString() + "]");
|
aggregatorSupplier.getClass().toString() + "]");
|
||||||
}
|
}
|
||||||
return ((MetricAggregatorSupplier) aggregatorSupplier).build(name, valuesSource, config.format(), searchContext, parent, metadata);
|
return ((MetricAggregatorSupplier) aggregatorSupplier).build(name, config, valuesSource, searchContext, parent, metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,8 +68,14 @@ public class AnalyticsAggregatorFactory {
|
|||||||
public static void registerHistoBackedSumAggregator(ValuesSourceRegistry.Builder builder) {
|
public static void registerHistoBackedSumAggregator(ValuesSourceRegistry.Builder builder) {
|
||||||
builder.register(SumAggregationBuilder.NAME,
|
builder.register(SumAggregationBuilder.NAME,
|
||||||
AnalyticsValuesSourceType.HISTOGRAM,
|
AnalyticsValuesSourceType.HISTOGRAM,
|
||||||
(MetricAggregatorSupplier) (name, valuesSource, format, context, parent, metadata) ->
|
(MetricAggregatorSupplier) (name, valuesSourceConfig, valuesSource, context, parent, metadata) -> new HistoBackedSumAggregator(
|
||||||
new HistoBackedSumAggregator(name, (HistogramValuesSource.Histogram) valuesSource, format, context, parent, metadata)
|
name,
|
||||||
|
(HistogramValuesSource.Histogram) valuesSource,
|
||||||
|
valuesSourceConfig.format(),
|
||||||
|
context,
|
||||||
|
parent,
|
||||||
|
metadata
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,8 +90,14 @@ public class AnalyticsAggregatorFactory {
|
|||||||
public static void registerHistoBackedAverageAggregator(ValuesSourceRegistry.Builder builder) {
|
public static void registerHistoBackedAverageAggregator(ValuesSourceRegistry.Builder builder) {
|
||||||
builder.register(AvgAggregationBuilder.NAME,
|
builder.register(AvgAggregationBuilder.NAME,
|
||||||
AnalyticsValuesSourceType.HISTOGRAM,
|
AnalyticsValuesSourceType.HISTOGRAM,
|
||||||
(MetricAggregatorSupplier) (name, valuesSource, format, context, parent, metadata) ->
|
(MetricAggregatorSupplier) (name, valuesSourceConfig, valuesSource, context, parent, metadata) -> new HistoBackedAvgAggregator(
|
||||||
new HistoBackedAvgAggregator(name, (HistogramValuesSource.Histogram) valuesSource, format, context, parent, metadata)
|
name,
|
||||||
|
(HistogramValuesSource.Histogram) valuesSource,
|
||||||
|
valuesSourceConfig.format(),
|
||||||
|
context,
|
||||||
|
parent,
|
||||||
|
metadata
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,11 +48,11 @@ public class StringStatsAggregator extends MetricsAggregator {
|
|||||||
/** Map that stores the number of occurrences for each character. */
|
/** Map that stores the number of occurrences for each character. */
|
||||||
Map<Character, LongArray> charOccurrences;
|
Map<Character, LongArray> charOccurrences;
|
||||||
|
|
||||||
StringStatsAggregator(String name, boolean showDistribution, ValuesSource.Bytes valuesSource, DocValueFormat format,
|
StringStatsAggregator(String name, ValuesSource valuesSource, boolean showDistribution, DocValueFormat format,
|
||||||
SearchContext context, Aggregator parent, Map<String, Object> metadata) throws IOException {
|
SearchContext context, Aggregator parent, Map<String, Object> metadata) throws IOException {
|
||||||
super(name, context, parent, metadata);
|
super(name, context, parent, metadata);
|
||||||
this.showDistribution = showDistribution;
|
this.showDistribution = showDistribution;
|
||||||
this.valuesSource = valuesSource;
|
this.valuesSource = (ValuesSource.Bytes) valuesSource;
|
||||||
if (valuesSource != null) {
|
if (valuesSource != null) {
|
||||||
final BigArrays bigArrays = context.bigArrays();
|
final BigArrays bigArrays = context.bigArrays();
|
||||||
count = bigArrays.newLongArray(1, true);
|
count = bigArrays.newLongArray(1, true);
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
package org.elasticsearch.xpack.analytics.stringstats;
|
package org.elasticsearch.xpack.analytics.stringstats;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
|
||||||
import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
||||||
import org.elasticsearch.search.aggregations.Aggregator;
|
import org.elasticsearch.search.aggregations.Aggregator;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||||
@ -38,26 +37,14 @@ class StringStatsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
|||||||
|
|
||||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||||
builder.register(StringStatsAggregationBuilder.NAME,
|
builder.register(StringStatsAggregationBuilder.NAME,
|
||||||
CoreValuesSourceType.BYTES, new StringStatsAggregatorSupplier() {
|
CoreValuesSourceType.BYTES, (StringStatsAggregatorSupplier) StringStatsAggregator::new);
|
||||||
@Override
|
|
||||||
public Aggregator build(String name,
|
|
||||||
ValuesSource valuesSource,
|
|
||||||
boolean showDistribution,
|
|
||||||
DocValueFormat format,
|
|
||||||
SearchContext context,
|
|
||||||
Aggregator parent,
|
|
||||||
Map<String, Object> metadata) throws IOException {
|
|
||||||
return new StringStatsAggregator(name, showDistribution, (ValuesSource.Bytes) valuesSource,
|
|
||||||
format, context, parent, metadata);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Aggregator createUnmapped(SearchContext searchContext,
|
protected Aggregator createUnmapped(SearchContext searchContext,
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
return new StringStatsAggregator(name, showDistribution,null, config.format(), searchContext, parent, metadata);
|
return new StringStatsAggregator(name, null, showDistribution, config.format(), searchContext, parent, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user