rotate

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

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

func SetCompressor

func SetCompressor(c Compressor)

SetCompressor is a compressor setter

Types

type Bloomfilter

type Bloomfilter struct {
	Previous, Current, Next *bbloomfilter.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) Close

func (bs *Bloomfilter) Close()

Close 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 `json:"ttl"`
}

Config contains a bloomfilter config and the rotation frequency TTL in sec

type Gzip

type Gzip int

Gzip type implementing the Compressor interface

func (*Gzip) NewReader

func (*Gzip) NewReader(r io.Reader) (io.Reader, error)

NewReader implementation fo Gzip

func (*Gzip) NewWriter

func (*Gzip) NewWriter(w io.Writer) io.WriteCloser

NewWriter implementation fo Gzip

type SerializibleBloomfilter

type SerializibleBloomfilter struct {
	Previous, Current, Next *bbloomfilter.Bloomfilter
	Config                  Config
}

SerializibleBloomfilter used when (de)serializing a set of sliding bloomfilters It has exportable fields

Jump to

Keyboard shortcuts

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