bloom

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSeed1 uint64 = 6269
	DefaultSeed2 uint64 = 4241
)

Variables

This section is empty.

Functions

func GetFalsePositiveProbabilityEstimate

func GetFalsePositiveProbabilityEstimate(n_bits, n_hash, n_add uint64) float64

`GetPositiveProbablityEstimate`: returns probability of getting true, for a filter with n_bits, n_hash, and n_add Add operations.

func GetOptimalParameters

func GetOptimalParameters(n_add uint64, prob_fp float64) (uint64, uint64)

`GetOptimalParameters`: return optimal (n_bits, n_hash) for a given n_add, and prob_fp

Types

type Bloom

type Bloom struct {
	State BloomDS
}

func NewBloomCustom

func NewBloomCustom(id string, n_bits, n_hash uint64, seeds [2]uint64) *Bloom

`NewBloomCustom` return a custom `Bloom` object

func NewBloomDefault

func NewBloomDefault(id string, n_bits, n_hash uint64) *Bloom

`NewBloomDefault` return a default `Bloom` object

func NewBloomFromBloomDS

func NewBloomFromBloomDS(b *BloomDS) *Bloom

`NewBloomFromBloomDS`: return a `Bloom` using the data from bloom_ds

func (*Bloom) Add

func (b *Bloom) Add(value any)

`Add`: add a value to the set

func (*Bloom) Check

func (b *Bloom) Check(value any) bool

`Check`: check a value to the set (false negative: never, false positives: maybe)

func (*Bloom) GetState added in v0.1.1

func (b *Bloom) GetState() BloomDS

`GetState`: return current State bool

func (*Bloom) Reset

func (b *Bloom) Reset()

`Reset`: resets bloom_ds

func (*Bloom) Union

func (b1 *Bloom) Union(b2 *BloomDS) bool

`Union`: tries state union

type BloomAtomic

type BloomAtomic struct {
	State BloomDS
	// contains filtered or unexported fields
}

func NewBloomAtomicCustom

func NewBloomAtomicCustom(id string, n_bits, n_hash uint64, seeds [2]uint64) *BloomAtomic

`NewBloomAtomicCustom` return a custom `BloomAtomic` object

func NewBloomAtomicDefault

func NewBloomAtomicDefault(id string, n_bits, n_hash uint64) *BloomAtomic

`NewBloomAtomicDefault` return a default `BloomAtomic` object

func NewBloomAtomicFromBloomDS

func NewBloomAtomicFromBloomDS(b *BloomDS) *BloomAtomic

`NewBloomAtomicFromBloomDS`: return a `BloomAtomic` using the data from the bloom_ds

func (*BloomAtomic) Add

func (b *BloomAtomic) Add(value any)

`Add`: add a value to the set

func (*BloomAtomic) Check

func (b *BloomAtomic) Check(value any) bool

`Check: check a value to the set (false negative: never, false positives: maybe)

func (*BloomAtomic) GetState added in v0.1.1

func (b *BloomAtomic) GetState() BloomDS

`GetState`: return current State bool

func (*BloomAtomic) Reset

func (b *BloomAtomic) Reset()

`Reset`: resets bloom_ds

func (*BloomAtomic) Union

func (b1 *BloomAtomic) Union(b2 *BloomDS) bool

`Union`: tries state union

type BloomDS

type BloomDS struct {
	ID     string
	NBits  uint64
	NHash  uint64
	Seeds  [2]uint64
	Filter []uint64
}

func NewBloomDSCustom

func NewBloomDSCustom(id string, n_bits, n_hash uint64, seeds [2]uint64) BloomDS

`NewBloomDSCustom`: return custom bloom_ds

func NewBloomDSDefault

func NewBloomDSDefault(id string, n_bits, n_hash uint64) BloomDS

`NewBloomDSDefault`: return default bloom_ds

func (*BloomDS) GetIndices

func (b *BloomDS) GetIndices(value any) []uint64

`GetIndices`: get indices that would be considered for a value

func (*BloomDS) Load

func (b *BloomDS) Load(dir string) error

`Load`: load bloom_ds from dir/id.bloom

func (*BloomDS) Reset

func (b *BloomDS) Reset()

`Reset`: resets all bits

func (*BloomDS) Save

func (b *BloomDS) Save(dir string) error

`Save`: save bloom_ds to dir/id.bloom

func (*BloomDS) Union

func (b1 *BloomDS) Union(b2 *BloomDS) bool

`Union`: union with another bloom_ds with same n_bits and seeds

type BloomRW

type BloomRW struct {
	State BloomDS
	Mu    sync.RWMutex
	// contains filtered or unexported fields
}

func NewBloomRWCustom

func NewBloomRWCustom(id string, n_bits, n_hash uint64, seeds [2]uint64) *BloomRW

`NewBloomRWCustom` return a custom `BloomRW` object

func NewBloomRWDefault

func NewBloomRWDefault(id string, n_bits, n_hash uint64) *BloomRW

`NewBloomRWDefault` return a default `BloomRW` object

func NewBloomRWFromBloomDS

func NewBloomRWFromBloomDS(b *BloomDS) *BloomRW

`NewBloomRWFromBloomDS`: return a `BloomRW` using the data from the bloom_ds

func (*BloomRW) Add

func (b *BloomRW) Add(value any)

`Add`: add a value to the set

func (*BloomRW) Check

func (b *BloomRW) Check(value any) bool

`Check`: check a value to the set (false negative: never, false positives: maybe)

func (*BloomRW) GetState added in v0.1.1

func (b *BloomRW) GetState() BloomDS

`GetState`: return current State bool

func (*BloomRW) Reset

func (b *BloomRW) Reset()

`Reset`: resets bloom_ds

func (*BloomRW) Union

func (b1 *BloomRW) Union(b2 *BloomDS) bool

`Union`: tries state union

type BloomShard

type BloomShard struct {
	State   BloomDS
	NShards uint64
	Shards  []sync.RWMutex
	// contains filtered or unexported fields
}

func NewBloomShardCustom

func NewBloomShardCustom(id string, n_bits, n_hash, n_shards uint64, seeds [2]uint64) *BloomShard

`NewBloomShardCustom` return a custom `BloomShard` object

func NewBloomShardDefault

func NewBloomShardDefault(id string, n_bits, n_hash, n_shards uint64) *BloomShard

`NewBloomShardDefault` return a default `BloomShard` object

func NewBloomShardFromBloomDS

func NewBloomShardFromBloomDS(b *BloomDS, n_shard uint64) *BloomShard

`NewBloomShardFromBloomDS`: return a `BloomShard` using the data from the bloom_ds

func (*BloomShard) Add

func (b *BloomShard) Add(value any)

`Add`: add a value to the set

func (*BloomShard) Check

func (b *BloomShard) Check(value any) bool

`Check`: check a value to the set (false negative: never, false positives: maybe)

func (*BloomShard) GetState added in v0.1.1

func (b *BloomShard) GetState() BloomDS

`GetState`: return current State bool

func (*BloomShard) Reset

func (b *BloomShard) Reset()

`Reset`: resets bloom_ds

func (*BloomShard) Union

func (b1 *BloomShard) Union(b2 *BloomDS) bool

`Union`: tries state union

type IBloom

type IBloom interface {
	Add(any)
	Check(any) bool
	Reset()
	Union(*BloomDS) bool
	GetState() BloomDS
}

Jump to

Keyboard shortcuts

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