Documentation ¶
Index ¶
- type CountMinSketch
- func (s *CountMinSketch) D() uint
- func (s *CountMinSketch) Estimate(key []byte) uint
- func (s *CountMinSketch) EstimateString(key string) uint
- func (s *CountMinSketch) GobDecode(data []byte) error
- func (s *CountMinSketch) GobEncode() ([]byte, error)
- func (s *CountMinSketch) MarshalJSON() ([]byte, error)
- func (s *CountMinSketch) ReadFrom(stream io.Reader) (int64, error)
- func (s *CountMinSketch) ReadFromFile(file string) (int64, error)
- func (s *CountMinSketch) UnmarshalJSON(data []byte) error
- func (s *CountMinSketch) Update(key []byte, count uint)
- func (s *CountMinSketch) UpdateString(key string, count uint)
- func (s *CountMinSketch) W() uint
- func (s *CountMinSketch) WriteTo(stream io.Writer) (int64, error)
- func (s *CountMinSketch) WriteToFile(file string) (int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CountMinSketch ¶
type CountMinSketch struct {
// contains filtered or unexported fields
}
CountMinSketch struct. d is the number of hashing functions, w is the size of every hash table. count, a matrix, is used to store the count. uint is used to store count, the maximum count is 1<<32-1 in 32 bit OS, and 1<<64-1 in 64 bit OS.
func New ¶
func New(d uint, w uint) (s *CountMinSketch, err error)
Create a new Count-Min Sketch with _d_ hashing functions and _w_ hash value range
func NewFromFile ¶
func NewFromFile(file string) (*CountMinSketch, error)
Create a new Count-Min Sketch from dumpped file
func NewWithEstimates ¶
func NewWithEstimates(varepsilon, delta float64) (*CountMinSketch, error)
Create a new Count-Min Sketch with given error rate and confidence. Accuracy guarantees will be made in terms of a pair of user specified parameters, ε and δ, meaning that the error in answering a query is within a factor of ε with probability δ
func (*CountMinSketch) Estimate ¶
func (s *CountMinSketch) Estimate(key []byte) uint
Estimate the frequency of a key. It is point query.
func (*CountMinSketch) EstimateString ¶
func (s *CountMinSketch) EstimateString(key string) uint
Estimate the frequency of a key
func (*CountMinSketch) GobDecode ¶
func (s *CountMinSketch) GobDecode(data []byte) error
GobDecode implements gob.GobDecoder interface.
func (*CountMinSketch) GobEncode ¶
func (s *CountMinSketch) GobEncode() ([]byte, error)
GobEncode implements gob.GobEncoder interface.
func (*CountMinSketch) MarshalJSON ¶
func (s *CountMinSketch) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface. Based on https://github.com/willf/bloom/blob/master/bloom.go
func (*CountMinSketch) ReadFrom ¶
func (s *CountMinSketch) ReadFrom(stream io.Reader) (int64, error)
ReadFrom a binary representation of the CountMinSketch from an i/o stream. Based on https://github.com/willf/bloom/blob/master/bloom.go
func (*CountMinSketch) ReadFromFile ¶
func (s *CountMinSketch) ReadFromFile(file string) (int64, error)
Read Count-Min Sketch from file
func (*CountMinSketch) UnmarshalJSON ¶
func (s *CountMinSketch) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler interface. Based on https://github.com/willf/bloom/blob/master/bloom.go
func (*CountMinSketch) Update ¶
func (s *CountMinSketch) Update(key []byte, count uint)
Update the frequency of a key
func (*CountMinSketch) UpdateString ¶
func (s *CountMinSketch) UpdateString(key string, count uint)
Update the frequency of a key
func (*CountMinSketch) WriteTo ¶
func (s *CountMinSketch) WriteTo(stream io.Writer) (int64, error)
WriteTo writes a binary representation of the CountMinSketch to an i/o stream. Based on https://github.com/willf/bloom/blob/master/bloom.go
func (*CountMinSketch) WriteToFile ¶
func (s *CountMinSketch) WriteToFile(file string) (int64, error)
Write the Count-Min Sketch to file