Documentation ¶
Overview ¶
Copyright (c) 2022 Blockwatch Data Inc. Author: alex@blockwatch.cc
Index ¶
- func Estimate(n uint64, p float64) (m int, k int)
- func Hash(data []byte) [2]uint32
- func HashFloat32(v float32) [2]uint32
- func HashFloat64(v float64) [2]uint32
- func HashInt16(v int16) [2]uint32
- func HashInt32(v int32) [2]uint32
- func HashInt64(v int64) [2]uint32
- func HashUint16(v uint16) [2]uint32
- func HashUint32(v uint32) [2]uint32
- func HashUint64(v uint64) [2]uint32
- type Filter
- func (f *Filter) Add(v []byte)
- func (f *Filter) AddMany(l [][]byte)
- func (f *Filter) AddManyFloat32(data []float32)
- func (f *Filter) AddManyFloat64(data []float64)
- func (f *Filter) AddManyInt16(data []int16)
- func (f *Filter) AddManyInt32(data []int32)
- func (f *Filter) AddManyInt64(data []int64)
- func (f *Filter) AddManyUint16(data []uint16)
- func (f *Filter) AddManyUint32(data []uint32)
- func (f *Filter) AddManyUint64(data []uint64)
- func (f *Filter) Bytes() []byte
- func (f *Filter) Clone() *Filter
- func (f *Filter) Contains(v []byte) bool
- func (f *Filter) ContainsAnyHash(l [][2]uint32) bool
- func (f *Filter) ContainsFloat32(v float32) bool
- func (f *Filter) ContainsFloat64(v float64) bool
- func (f *Filter) ContainsHash(h [2]uint32) bool
- func (f *Filter) ContainsInt16(v int16) bool
- func (f *Filter) ContainsInt32(v int32) bool
- func (f *Filter) ContainsInt64(v int64) bool
- func (f *Filter) ContainsUint16(v uint16) bool
- func (f *Filter) ContainsUint32(v uint32) bool
- func (f *Filter) ContainsUint64(v uint64) bool
- func (f *Filter) K() uint32
- func (f *Filter) Len() uint
- func (f *Filter) Merge(other *Filter) error
- func (f *Filter) Reset()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Estimate ¶
Estimate returns an estimated bit count and hash count given the element count and false positive rate. TODO: adjust formula to fixed k = 4
func HashFloat32 ¶
func HashFloat64 ¶
func HashUint16 ¶
func HashUint32 ¶
func HashUint64 ¶
Types ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter represents a bloom filter.
func NewFilter ¶
NewFilter returns a new instance of Filter using m bits. If m is not a power of two then it is rounded to the next highest power of 2.
func NewFilterBuffer ¶
NewFilterBuffer returns a new instance of a filter using a backing buffer. The buffer length MUST be a power of 2.
func (*Filter) AddManyFloat32 ¶
AddMany inserts multiple data points to the filter.
func (*Filter) AddManyFloat64 ¶
AddMany inserts multiple data points to the filter.
func (*Filter) AddManyInt16 ¶
AddMany inserts multiple data points to the filter.
func (*Filter) AddManyInt32 ¶
AddMany inserts multiple data points to the filter.
func (*Filter) AddManyInt64 ¶
AddMany inserts multiple data points to the filter.
func (*Filter) AddManyUint16 ¶
AddMany inserts multiple data points to the filter.
func (*Filter) AddManyUint32 ¶
AddMany inserts multiple data points to the filter.
func (*Filter) AddManyUint64 ¶
AddMany inserts multiple data points to the filter.
func (*Filter) Contains ¶
Contains returns true if the filter possibly contains v. Returns false if the filter definitely does not contain v.
func (*Filter) ContainsAnyHash ¶
ContainsAnyHash returns true if the filter contains any hash value in l. Returns false if the filter definitely does not contain any hash in l.
func (*Filter) ContainsFloat32 ¶
Contains returns true if the filter possibly contains v. Returns false if the filter definitely does not contain v.
func (*Filter) ContainsFloat64 ¶
Contains returns true if the filter possibly contains v. Returns false if the filter definitely does not contain v.
func (*Filter) ContainsHash ¶
ContainsHash returns true if the filter contains hash value h. Returns false if the filter definitely does not contain h.
func (*Filter) ContainsInt16 ¶
Contains returns true if the filter possibly contains v. Returns false if the filter definitely does not contain v.
func (*Filter) ContainsInt32 ¶
Contains returns true if the filter possibly contains v. Returns false if the filter definitely does not contain v.
func (*Filter) ContainsInt64 ¶
Contains returns true if the filter possibly contains v. Returns false if the filter definitely does not contain v.
func (*Filter) ContainsUint16 ¶
Contains returns true if the filter possibly contains v. Returns false if the filter definitely does not contain v.
func (*Filter) ContainsUint32 ¶
Contains returns true if the filter possibly contains v. Returns false if the filter definitely does not contain v.
func (*Filter) ContainsUint64 ¶
Contains returns true if the filter possibly contains v. Returns false if the filter definitely does not contain v.