Class ApproximateMostFrequentHistogram<K>
- java.lang.Object
-
- io.prestosql.operator.aggregation.ApproximateMostFrequentHistogram<K>
-
- Type Parameters:
K
-
public class ApproximateMostFrequentHistogram<K> extends Object
Calculate the histogram approximately for topk elements based on the Space-Saving algorithm and the Stream-Summary data structure as described in: Efficient Computation of Frequent and Top-k Elements in Data Streams by Metwally, Agrawal, and Abbadi
-
-
Constructor Summary
Constructors Constructor Description ApproximateMostFrequentHistogram(int maxBuckets, int capacity, ApproximateMostFrequentBucketSerializer<K> serializer, ApproximateMostFrequentBucketDeserializer<K> deserializer)
ApproximateMostFrequentHistogram(io.airlift.slice.Slice serialized, ApproximateMostFrequentBucketSerializer<K> serializer, ApproximateMostFrequentBucketDeserializer<K> deserializer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(K value)
void
add(K value, long incrementCount)
long
estimatedInMemorySize()
void
forEachBucket(BucketConsumer<K> consumer)
Map<K,Long>
getBuckets()
void
merge(ApproximateMostFrequentHistogram<K> other)
io.airlift.slice.Slice
serialize()
-
-
-
Constructor Detail
-
ApproximateMostFrequentHistogram
public ApproximateMostFrequentHistogram(int maxBuckets, int capacity, ApproximateMostFrequentBucketSerializer<K> serializer, ApproximateMostFrequentBucketDeserializer<K> deserializer)
- Parameters:
maxBuckets
- The maximum number of elements stored in the bucket.capacity
- The maximum capacity of the stream summary data structure.serializer
- It serializes a bucket into varbinary slice.deserializer
- It appends a bucket into the histogram.
-
ApproximateMostFrequentHistogram
public ApproximateMostFrequentHistogram(io.airlift.slice.Slice serialized, ApproximateMostFrequentBucketSerializer<K> serializer, ApproximateMostFrequentBucketDeserializer<K> deserializer)
-
-
Method Detail
-
add
public void add(K value)
-
add
public void add(K value, long incrementCount)
-
serialize
public io.airlift.slice.Slice serialize()
-
merge
public void merge(ApproximateMostFrequentHistogram<K> other)
-
forEachBucket
public void forEachBucket(BucketConsumer<K> consumer)
-
estimatedInMemorySize
public long estimatedInMemorySize()
-
-