flipcounter

package module
v0.0.0-...-c25b44c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2017 License: MIT Imports: 4 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

FlipCounter

Data-structure with 5 byte keys and 3 bytes counters (64 bits per entry).

The 3 byte counter (24 bit) uses 23 for counting (guaranteeing 100% accurate counting per key up to (2^23)-1 ==> 8388607 hits.

The remaining bit is used to annotate an overflow (hits > 8388607) and the counter falls back to estimated counting trying to guarantee a max 1% absolute error.

Usage is straight forward

import "github.com/watchly/flipcounter"

c := flipcounter.New()
fc.Increment([]byte("watchly"))
fc.Get([]byte("watchly"))

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

type Counter map[key]count

Counter consits of a 5 bytes key and a 3 bytes estimating counter with a 100% accurary up to 8388607 hits, then an estimation of 1% error

func New

func New() *Counter

New return a HashLog sketch with 5 bytes keys and 3 bytes counters

func (*Counter) Get

func (fc *Counter) Get(val []byte) uint64

Get returns the number of hits for val []byte

func (*Counter) Increment

func (fc *Counter) Increment(val []byte)

Increment increments the counter of val []byte by +1

func (*Counter) Len

func (fc *Counter) Len() uint64

Len ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址