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:
Colin Goodheart-Smithe 2015-02-17 10:07:56 +00:00
parent f68bce51f1
commit 269d4bc30e
3 changed files with 6 additions and 18 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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;