Search in sources :

Example 6 with SetBackedScalingCuckooFilter

use of org.opensearch.common.util.SetBackedScalingCuckooFilter in project OpenSearch by opensearch-project.

the class StringRareTermsTests method createTestInstance.

@Override
protected InternalRareTerms<?, ?> createTestInstance(String name, Map<String, Object> metadata, InternalAggregations aggregations, long maxDocCount) {
    BucketOrder order = BucketOrder.count(false);
    DocValueFormat format = DocValueFormat.RAW;
    List<StringRareTerms.Bucket> buckets = new ArrayList<>();
    final int numBuckets = randomNumberOfBuckets();
    for (int i = 0; i < numBuckets; ++i) {
        Set<BytesRef> terms = new HashSet<>();
        BytesRef term = randomValueOtherThanMany(b -> terms.add(b) == false, () -> new BytesRef(randomAlphaOfLength(10)));
        int docCount = randomIntBetween(1, 100);
        buckets.add(new StringRareTerms.Bucket(term, docCount, aggregations, format));
    }
    SetBackedScalingCuckooFilter filter = new SetBackedScalingCuckooFilter(1000, Randomness.get(), 0.01);
    return new StringRareTerms(name, order, metadata, format, buckets, maxDocCount, filter);
}
Also used : BucketOrder(org.opensearch.search.aggregations.BucketOrder) SetBackedScalingCuckooFilter(org.opensearch.common.util.SetBackedScalingCuckooFilter) DocValueFormat(org.opensearch.search.DocValueFormat) ArrayList(java.util.ArrayList) BytesRef(org.apache.lucene.util.BytesRef) HashSet(java.util.HashSet)

Aggregations

SetBackedScalingCuckooFilter (org.opensearch.common.util.SetBackedScalingCuckooFilter)6 ArrayList (java.util.ArrayList)5 InternalAggregation (org.opensearch.search.aggregations.InternalAggregation)3 BytesRef (org.apache.lucene.util.BytesRef)2 DocValueFormat (org.opensearch.search.DocValueFormat)2 BucketOrder (org.opensearch.search.aggregations.BucketOrder)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Random (java.util.Random)1 BytesRefHash (org.opensearch.common.util.BytesRefHash)1 LongHash (org.opensearch.common.util.LongHash)1 AggregationExecutionException (org.opensearch.search.aggregations.AggregationExecutionException)1