Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions countmin.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ func (c *CountMinSketch) Add(data []byte) *CountMinSketch {
return c
}

func (c *CountMinSketch) Set(data []byte, count uint64) *CountMinSketch {
lower, upper := hashKernel(data, c.hash)

// Increment count in each row.
for i := uint(0); i < c.depth; i++ {
c.matrix[i][(uint(lower)+uint(upper)*i)%c.width] = count
}

return c
}

// Count returns the approximate count for the specified item, correct within
// epsilon * total count with a probability of delta.
func (c *CountMinSketch) Count(data []byte) uint64 {
Expand Down