bloom

package module
v0.0.0-...-63c7bc1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: MIT Imports: 4 Imported by: 0

README

bloom

bloom filter base on redis

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitmapSet

type BitmapSet interface {
	// Init init bitmap, m is number of bits in filter
	Init(m uint) error

	// Set each bit in bits, to 1
	Set(bits []uint) error

	// Test whether bits is set.
	Test(bits []uint) (bool, error)

	// Close closes the connection.
	Close()
}

BitmapSet interface

func NewMemoryBitmapSet

func NewMemoryBitmapSet() BitmapSet

NewMemoryBitmapSet create bitmap base on memory

func NewRedisBitmapSet

func NewRedisBitmapSet(c RedisConfig) BitmapSet

NewMemoryBitmapSet create bitmap base on memory

type Bloom

type Bloom struct {
	// contains filtered or unexported fields
}

Bloom bloom filter,

func NewBloomFilter

func NewBloomFilter(m uint, k uint, bms BitmapSet) (*Bloom, error)

New creates a new Bloom filter with m bits and k hashing functions

func (*Bloom) Add

func (b *Bloom) Add(data []byte) error

Add data to the Bloom Filter

func (*Bloom) AddString

func (b *Bloom) AddString(data string) error

AddString to the Bloom Filter

func (*Bloom) Test

func (b *Bloom) Test(data []byte) (bool, error)

Test returns true if the data is in the Bloom, false otherwise. If true, the result might be a false positive. If false, the data is definitely not in the set.

func (*Bloom) TestString

func (b *Bloom) TestString(data string) (bool, error)

TestString returns true if the string is in the BloomFilter, false otherwise. If true, the result might be a false positive. If false, the data is definitely not in the set.

type RedisConfig

type RedisConfig struct {
	Address           string
	BitmapKey         string
	RemoveKeyIfExists bool
}

Jump to

Keyboard shortcuts

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