Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CountMinSketch ¶
type CountMinSketch struct {
// contains filtered or unexported fields
}
CountMinSketch implements the Count-Min Sketch algorithm for frequency estimation.
func NewCountMinSketch ¶
func NewCountMinSketch(epsilon float64, delta float64) *CountMinSketch
NewCountMinSketch creates a new Count-Min Sketch with the given error rate and confidence.
func (*CountMinSketch) Add ¶
func (cms *CountMinSketch) Add(key []byte, count uint64)
Add adds a value to the sketch.
func (*CountMinSketch) Decay ¶
func (cms *CountMinSketch) Decay(factor float64)
Decay applies exponential decay to all counts
func (*CountMinSketch) Estimate ¶
func (cms *CountMinSketch) Estimate(key []byte) uint64
Estimate estimates the frequency of a value.
type SpaceSaving ¶
type SpaceSaving struct {
// contains filtered or unexported fields
}
SpaceSaving implements the Space-Saving algorithm for finding top-k frequent items.
func NewSpaceSaving ¶
func NewSpaceSaving(capacity int) *SpaceSaving
NewSpaceSaving creates a new Space-Saving instance with the given capacity.
func (*SpaceSaving) Add ¶
func (ss *SpaceSaving) Add(key string, count uint64)
Add adds an item to the Space-Saving structure.
func (*SpaceSaving) Clear ¶
func (ss *SpaceSaving) Clear()
Clear removes all items from the Space-Saving structure
func (*SpaceSaving) Count ¶
func (ss *SpaceSaving) Count(key string) uint64
Count returns the count for a specific key
func (*SpaceSaving) Decay ¶
func (ss *SpaceSaving) Decay(factor float64)
Decay applies exponential decay to all counts
type SpaceSavingHeap ¶
type SpaceSavingHeap []*Item
SpaceSavingHeap is a min-heap of Items.
func (SpaceSavingHeap) Less ¶
func (h SpaceSavingHeap) Less(i, j int) bool
Less returns whether the item at index i is less than the item at index j.
func (*SpaceSavingHeap) Pop ¶
func (h *SpaceSavingHeap) Pop() any
Pop removes and returns the minimum item from the heap.
func (SpaceSavingHeap) Swap ¶
func (h SpaceSavingHeap) Swap(i, j int)
Swap swaps the items at indices i and j.