Documentation
¶
Overview ¶
Package hll provides a hyperloglog structure for estimating the cardinality of multisets
Index ¶
- Constants
- Variables
- func Len(p uint8) int
- type Counter
- func (c *Counter) Add(v []byte)
- func (c *Counter) Count() int64
- func (c *Counter) HarmonicCount() int64
- func (c *Counter) Len() int
- func (c *Counter) LinearCount() int64
- func (c *Counter) PoissonCount() int64
- func (c *Counter) ReadFrom(r io.Reader) (int64, error)
- func (c *Counter) Reset()
- func (c *Counter) WriteTo(w io.Writer) (int64, error)
Constants ¶
const ( // Version is the version number of the binary serialization format. All // prior versions up to and including this one are deserializable by this // package. Version = 1 )
Variables ¶
var ErrIncompatibleVersion = errors.New("hll: incompatible version")
Functions ¶
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
func New ¶
New creates a new hyperloglog counter with the specified precision. p must be in the range [4,18]
func WithBytes ¶
WithBytes creates a hyperloglog counter that uses buf as its backing storage, preserving any existing data in the byte slice. Any subsequent writes to the counter will mutate buf. The layout of the byte buffer must match the layout used by the WriteTo method.
func (*Counter) Count ¶
Count returns an estimate of the number of distinct items that have been added to the counter.
func (*Counter) HarmonicCount ¶
func (*Counter) LinearCount ¶
func (*Counter) PoissonCount ¶
func (*Counter) ReadFrom ¶
ReadFrom reads a binary representation of the counter from r overwriting any previous configuration. It adheres to the io.ReaderFrom interface protocol. It reads data from r until EOF or error. The return value n is the number of bytes read. Any error except io.EOF encountered during the read is also returned.