Documentation ¶
Overview ¶
Package cardinal implements efficient cardinality estimation datastructures.
Package cardinal implements efficient cardinality estimation datastructures.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HyperLogLog ¶
type HyperLogLog struct {
// contains filtered or unexported fields
}
HyperLogLog data structure does cardinality estimation by ranking items according to the LSB bits index.
func NewHyperLogLog ¶
func NewHyperLogLog(precision int) (*HyperLogLog, error)
NewHyperLogLog creates a new instance of hyperloglog precision takes values in (4..16).
func (*HyperLogLog) Add ¶
func (h *HyperLogLog) Add(item int32)
Add indexes an element into the counter.
func (*HyperLogLog) Cardinal ¶
func (h *HyperLogLog) Cardinal() int
Cardinal approximately counts the number of unique elements indexed by the HyperLogLog counter.
func (*HyperLogLog) Rank ¶
func (h *HyperLogLog) Rank(value uint32) int
Rank which is the least significant bit position.
type LinearCounter ¶
type LinearCounter struct {
// contains filtered or unexported fields
}
LinearCounter is a simple map(hash(value) => bit) and cardinality can be estimated using n = ~m*ln(V) where m is a parameter chosen based on how much entires we expect and V is the number of 0-set bits.
func NewLinearCounter ¶
func NewLinearCounter(m int) LinearCounter
NewLinearCounter creates a new linear counter.
func (*LinearCounter) Add ¶
func (lc *LinearCounter) Add(item int) error
Add an item to the linear counter
func (*LinearCounter) Cardinal ¶
func (lc *LinearCounter) Cardinal() float64
Cardinal returns the estimated cardinal of the dataset