Documentation ¶
Index ¶
- type HyperLogLog
- type ItemCount
- type Sketch
- func (s *Sketch) Add(h string, count uint32) (val uint32)
- func (s *Sketch) Clone() *Sketch
- func (s *Sketch) Compress()
- func (s *Sketch) ConservativeAdd(h string, count uint32) (val uint32)
- func (s *Sketch) ConservativeIncrement(h string) (val uint32)
- func (s Sketch) Count(h string) uint32
- func (s Sketch) CountMeanMin(h string) uint32
- func (s *Sketch) Del(h string, count uint32) (val uint32)
- func (s *Sketch) Increment(h string) (val uint32)
- func (s *Sketch) Merge(from *Sketch)
- func (s *Sketch) Reset()
- func (s Sketch) String() string
- func (s Sketch) Values(h string) []uint32
- type StreamTop
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HyperLogLog ¶
type HyperLogLog struct {
// contains filtered or unexported fields
}
A HyperLogLog cardinality estimator.
See http://algo.inria.fr/flajolet/Publications/FlFuGaMe07.pdf for more information.
func NewHyperLogLog ¶
func NewHyperLogLog(stdErr float64) *HyperLogLog
NewHyperLogLog returns an estimator for counting cardinality to within the given stderr.
Smaller values require more space, but provide more accurate results. For a good time, try 0.001 or so.
func (*HyperLogLog) Count ¶
func (h *HyperLogLog) Count() uint64
Count returns the current estimate of the number of distinct items seen.
func (*HyperLogLog) Merge ¶
func (h *HyperLogLog) Merge(from *HyperLogLog)
Merge another HyperLogLog into this one.
type Sketch ¶
type Sketch struct {
// contains filtered or unexported fields
}
Sketch is a count-min sketcher.
func NewSketch ¶
NewSketch returns new count-min sketch with the given width and depth. Sketch dimensions must be positive. A sketch with w=⌈ ℯ/𝜀 ⌉ and d=⌈ln (1/𝛿)⌉ answers queries within a factor of 𝜀 with probability 1-𝛿.
func (*Sketch) Compress ¶
func (s *Sketch) Compress()
Compress reduces the space used by the sketch. This also reduces the accuracy. This routine panics if the width is not a power of two.
func (*Sketch) ConservativeAdd ¶
ConservativeAdd adds the count (conservatively) for the given input.
func (*Sketch) ConservativeIncrement ¶
ConservativeIncrement increments the count (conservatively) for the given input.
func (Sketch) CountMeanMin ¶
CountMeanMin returns estimated count for the given input, using the count-min-mean heuristic. This gives more accurate results than Count() for low-frequency counts at the cost of larger under-estimation error. For tasks sensitive to under-estimation, use the regular Count() and only call ConservativeAdd() and ConservativeIncrement() when constructing your sketch.
type StreamTop ¶
type StreamTop struct {
// contains filtered or unexported fields
}
StreamTop tracks the top-n items in a stream.
func NewStreamTop ¶
NewStreamTop returns an estimator for the 'maxItems' in the stream. It uses a count-min sketch, which is created with width w and depth d.