Documentation ¶
Index ¶
- type Count16
- type Count16x4
- type Count8
- type CountMin
- func (c *CountMin) Count(item []byte) uint
- func (c *CountMin) CountHash(hash uint64) uint
- func (c *CountMin) CountString(item string) uint
- func (c *CountMin) Reset()
- func (c *CountMin) Update(item []byte) bool
- func (c *CountMin) UpdateHash(hash uint64) (updated bool)
- func (c *CountMin) UpdateString(item string) bool
- type TopK
- type TopValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Count16 ¶
type Count16 uint16
Count16 is a 16-bit counter that uses Morris's algorithm to estimate the count. The counter was tuned to count up to ~2 billion with relatively low mean error rate of around ~0.50%.
type Count16x4 ¶
type Count16x4 struct {
// contains filtered or unexported fields
}
Count16x4 is a represents 4 16-bit approximate counters, using atomic operations to increment the counter.
func (*Count16x4) EstimateAt ¶
EstimateAt returns the estimated count for the counter at the given index.
func (*Count16x4) IncrementAt ¶
IncrementAt increments the counter at the given index. It returns true if the counter estimate was updated.
type Count8 ¶
type Count8 uint8
Count8 is a 8-bit counter that uses Morris's algorithm to estimate the count. The counter was tuned to count up to ~100k with relatively mean error rate of around ~10%.
type CountMin ¶
type CountMin struct {
// contains filtered or unexported fields
}
CountMin is a sketch data structure for estimating the frequency of items in a stream
func NewCountMin ¶
NewCountMin creates a new CountMin sketch with default epsilon and confidence
func NewCountMinWithEstimates ¶
NewCountMinWithEpsilon creates a new CountMin sketch with the given epsilon and delta. The epsilon parameter controls the accuracy of the estimates, and the confidence parameter controls the probability that the estimates are within the specified error bounds.
func NewCountMinWithSize ¶
NewCountMinWithSize creates a new CountMin sketch with the given depth and width
func (*CountMin) CountString ¶
CountString returns the estimated frequency of the given item
func (*CountMin) UpdateHash ¶
UpdateHash increments the counter for the given item
func (*CountMin) UpdateString ¶
UpdateString increments the counter for the given item
type TopK ¶
type TopK struct {
// contains filtered or unexported fields
}
TopK uses a Count-Min Sketch to calculate the top-K frequent elements in a stream.
func NewTopK ¶
NewTopK creates a new structure to track the top-k elements in a stream. The k parameter specifies the number of elements to track.
func (*TopK) Cardinality ¶
Cardinality returns the estimated cardinality of the stream.
func (*TopK) Reset ¶
Reset restores the TopK to its original state. The function returns the top-k elements and their counts as well as the estimated cardinality of the stream.