Documentation ¶
Overview ¶
Package rotate implemennts a sliding set of three bloomfilters: `previous`, `current` and `next` and the bloomfilter interface.
When adding an element, it is stored in the `current` and `next` bloomfilters. When sliding (rotating), `current` passes to `previous` and `next` to `current`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bloomfilter ¶
type Bloomfilter struct {
Previous, Current, Next *baseBloomfilter.Bloomfilter
Config Config
// contains filtered or unexported fields
}
Bloomfilter type defines a sliding set of 3 bloomfilters
func New ¶
func New(ctx context.Context, cfg Config) *Bloomfilter
New creates a new sliding set of 3 bloomfilters It uses a context and configuration
func (*Bloomfilter) Add ¶
func (bs *Bloomfilter) Add(elem []byte)
Add element to sliding set of bloomfilters
func (*Bloomfilter) Check ¶
func (bs *Bloomfilter) Check(elem []byte) bool
Check if element in sliding set of bloomfilters
func (*Bloomfilter) MarshalBinary ¶
func (bs *Bloomfilter) MarshalBinary() ([]byte, error)
MarshalBinary serializes a set of sliding bloomfilters
func (*Bloomfilter) Union ¶
func (bs *Bloomfilter) Union(that interface{}) (float64, error)
Union two sliding sets of bloomfilters Take care that false positive probability P, number of elements being filtered N and hashfunctions are the same
func (*Bloomfilter) UnmarshalBinary ¶
func (bs *Bloomfilter) UnmarshalBinary(data []byte) error
MarshalBinary deserializes a set of sliding bloomfilters
type Compressor ¶
type Compressor interface { NewWriter(io.Writer) io.WriteCloser NewReader(io.Reader) (io.Reader, error) }
Compressor type with new writer and reader function interface
type Config ¶
type Config struct { bloomfilter.Config TTL uint }
Config contains a bloomfilter config and the rotation frequency TTL in sec
type Gzip ¶
type Gzip int
Gzip type implementing the Compressor interface
type SerializibleBloomfilter ¶
type SerializibleBloomfilter struct {
Previous, Current, Next *baseBloomfilter.Bloomfilter
Config Config
}
SerializibleBloomfilter used when (de)serializing a set of sliding bloomfilters It has exportable fields