InternalHistogram.Factory.create() can now work from prototype
Another InternalHistogram instance can be passed into the method with the buckets and the name and will be used to set all the options such as minDocCount, formatter, Order etc.
This commit is contained in:
parent
f68bce51f1
commit
269d4bc30e
|
@ -22,15 +22,10 @@ import org.elasticsearch.common.Nullable;
|
|||
import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
||||
import org.elasticsearch.search.aggregations.InternalAggregation.Type;
|
||||
import org.elasticsearch.search.aggregations.InternalAggregations;
|
||||
import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram.EmptyBucketInfo;
|
||||
import org.elasticsearch.search.aggregations.reducers.Reducer;
|
||||
import org.elasticsearch.search.aggregations.support.format.ValueFormatter;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -75,14 +70,6 @@ public class InternalDateHistogram {
|
|||
return TYPE.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InternalHistogram create(String name, List<InternalDateHistogram.Bucket> buckets, InternalOrder order,
|
||||
long minDocCount,
|
||||
EmptyBucketInfo emptyBucketInfo, @Nullable ValueFormatter formatter, boolean keyed, List<Reducer> reducers,
|
||||
Map<String, Object> metaData) {
|
||||
return new InternalHistogram(name, buckets, order, minDocCount, emptyBucketInfo, formatter, keyed, this, reducers, metaData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InternalDateHistogram.Bucket createBucket(Object key, long docCount, InternalAggregations aggregations, boolean keyed,
|
||||
@Nullable ValueFormatter formatter) {
|
||||
|
|
|
@ -248,6 +248,11 @@ public class InternalHistogram<B extends InternalHistogram.Bucket> extends Inter
|
|||
return new InternalHistogram<>(name, buckets, order, minDocCount, emptyBucketInfo, formatter, keyed, this, reducers, metaData);
|
||||
}
|
||||
|
||||
public InternalHistogram<B> create(String name, List<B> buckets, InternalHistogram prototype) {
|
||||
return new InternalHistogram<>(name, buckets, prototype.order, prototype.minDocCount, prototype.emptyBucketInfo,
|
||||
prototype.formatter, prototype.keyed, this, prototype.reducers(), prototype.metaData);
|
||||
}
|
||||
|
||||
public B createBucket(Object key, long docCount, InternalAggregations aggregations, boolean keyed,
|
||||
@Nullable ValueFormatter formatter) {
|
||||
if (key instanceof Number) {
|
||||
|
@ -301,10 +306,6 @@ public class InternalHistogram<B extends InternalHistogram.Bucket> extends Inter
|
|||
return factory;
|
||||
}
|
||||
|
||||
public InternalOrder getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
private static class IteratorAndCurrent<B> {
|
||||
|
||||
private final Iterator<B> iterator;
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.Comparator;
|
|||
/**
|
||||
* An internal {@link Histogram.Order} strategy which is identified by a unique id.
|
||||
*/
|
||||
public class InternalOrder extends Histogram.Order {
|
||||
class InternalOrder extends Histogram.Order {
|
||||
|
||||
final byte id;
|
||||
final String key;
|
||||
|
|
Loading…
Reference in New Issue