
org.elasticsearch.search.aggregations.bucket.terms.InternalMappedRareTerms Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticsearch Show documentation
Show all versions of elasticsearch Show documentation
Elasticsearch - Open Source, Distributed, RESTful Search Engine
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
package org.elasticsearch.search.aggregations.bucket.terms;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.lucene.util.CollectionUtil;
import org.elasticsearch.common.Randomness;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.util.SetBackedScalingCuckooFilter;
import org.elasticsearch.search.DocValueFormat;
import org.elasticsearch.search.aggregations.AggregationExecutionException;
import org.elasticsearch.search.aggregations.AggregationReduceContext;
import org.elasticsearch.search.aggregations.BucketOrder;
import org.elasticsearch.search.aggregations.InternalAggregation;
import org.elasticsearch.search.aggregations.InternalAggregations;
import org.elasticsearch.search.aggregations.support.SamplingContext;
import org.elasticsearch.xcontent.XContentBuilder;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
public abstract class InternalMappedRareTerms, B extends InternalRareTerms.Bucket> extends
InternalRareTerms {
protected DocValueFormat format;
protected List buckets;
protected Map bucketMap;
final SetBackedScalingCuckooFilter filter;
protected final Logger logger = LogManager.getLogger(getClass());
InternalMappedRareTerms(
String name,
BucketOrder order,
Map metadata,
DocValueFormat format,
List buckets,
long maxDocCount,
SetBackedScalingCuckooFilter filter
) {
super(name, order, maxDocCount, metadata);
this.format = format;
this.buckets = buckets;
this.filter = filter;
}
public long getMaxDocCount() {
return maxDocCount;
}
SetBackedScalingCuckooFilter getFilter() {
return filter;
}
/**
* Read from a stream.
*/
InternalMappedRareTerms(StreamInput in, Bucket.Reader bucketReader) throws IOException {
super(in);
format = in.readNamedWriteable(DocValueFormat.class);
buckets = in.readList(stream -> bucketReader.read(stream, format));
filter = new SetBackedScalingCuckooFilter(in, Randomness.get());
}
@Override
protected void writeTermTypeInfoTo(StreamOutput out) throws IOException {
out.writeNamedWriteable(format);
out.writeList(buckets);
filter.writeTo(out);
}
@Override
public InternalAggregation reduce(List aggregations, AggregationReduceContext reduceContext) {
Map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy