bloom

package
v0.53.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIncompatibleBloom = errors.New("incompatible bloom filters")

Functions

func EstimateFalsePositiveRate added in v0.51.0

func EstimateFalsePositiveRate(m, k, n uint) float64

EstimateFalsePositiveRate estimates the false-positive rate for the filter shape.

func NewBloomBlock

func NewBloomBlock() block.Block

NewBloomBlock constructs a new Bloom block.

Types

type BloomFilter

type BloomFilter struct {

	// K is the number of hash functions.
	// Max: 10.
	// Min: 1.
	K uint32 `protobuf:"varint,1,opt,name=k,proto3" json:"k,omitempty"`
	// M is the length (capacity) of the bloom filter.
	M uint32 `protobuf:"varint,2,opt,name=m,proto3" json:"m,omitempty"`
	// BitSet is the underlying bitset.
	BitSet *bitset.BitSet `protobuf:"bytes,3,opt,name=bit_set,json=bitSet,proto3" json:"bitSet,omitempty"`
	// contains filtered or unexported fields
}

BloomFilter contains a bloom filter in a Block. uses FNV64 hash function m factor is determined by len(bit_set)*64

func NewBloom

func NewBloom(bl *Filter) *BloomFilter

NewBloom constructs a new bloom object from an existing bloom. if input is nil, returns nil

func (*BloomFilter) BlockAliasIdentity added in v0.52.0

func (b *BloomFilter) BlockAliasIdentity() *block.AliasIdentityToken

BlockAliasIdentity returns the in-memory alias token for BloomFilter.

func (*BloomFilter) Clone

func (b *BloomFilter) Clone() *BloomFilter

Clone clones the bloom filter block.

func (*BloomFilter) CloneMessageVT

func (m *BloomFilter) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*BloomFilter) CloneVT

func (m *BloomFilter) CloneVT() *BloomFilter

func (*BloomFilter) EqualMessageVT

func (this *BloomFilter) EqualMessageVT(thatMsg any) bool

func (*BloomFilter) EqualVT

func (this *BloomFilter) EqualVT(that *BloomFilter) bool

func (*BloomFilter) GetBitSet

func (x *BloomFilter) GetBitSet() *bitset.BitSet

func (*BloomFilter) GetK

func (x *BloomFilter) GetK() uint32

func (*BloomFilter) GetM

func (x *BloomFilter) GetM() uint32

func (*BloomFilter) IsEmpty

func (b *BloomFilter) IsEmpty() bool

IsEmpty checks if the bloom filter is empty.

func (*BloomFilter) IsNil

func (b *BloomFilter) IsNil() bool

IsNil checks if the object is nil.

func (*BloomFilter) MarshalBlock

func (b *BloomFilter) MarshalBlock() ([]byte, error)

MarshalBlock marshals the block to binary. This is the initial step of marshaling, before transformations.

func (*BloomFilter) MarshalJSON

func (x *BloomFilter) MarshalJSON() ([]byte, error)

MarshalJSON marshals the BloomFilter to JSON.

func (*BloomFilter) MarshalProtoJSON

func (x *BloomFilter) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the BloomFilter message to JSON.

func (*BloomFilter) MarshalProtoText

func (x *BloomFilter) MarshalProtoText() string

func (*BloomFilter) MarshalToSizedBufferVT

func (m *BloomFilter) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*BloomFilter) MarshalToVT

func (m *BloomFilter) MarshalToVT(dAtA []byte) (int, error)

func (*BloomFilter) MarshalVT

func (m *BloomFilter) MarshalVT() (dAtA []byte, err error)

func (*BloomFilter) ProtoMessage

func (*BloomFilter) ProtoMessage()

func (*BloomFilter) Reset

func (x *BloomFilter) Reset()

func (*BloomFilter) SizeVT

func (m *BloomFilter) SizeVT() (n int)

func (*BloomFilter) String

func (x *BloomFilter) String() string

func (*BloomFilter) ToBloomFilter

func (b *BloomFilter) ToBloomFilter() *Filter

ToBloomFilter converts the bloom block into a BloomFilter. Returns nil if empty.

func (*BloomFilter) UnmarshalBlock

func (b *BloomFilter) UnmarshalBlock(data []byte) error

UnmarshalBlock unmarshals the block to the object. This is the final step of decoding, after transformations.

func (*BloomFilter) UnmarshalJSON

func (x *BloomFilter) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the BloomFilter from JSON.

func (*BloomFilter) UnmarshalProtoJSON

func (x *BloomFilter) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the BloomFilter message from JSON.

func (*BloomFilter) UnmarshalVT

func (m *BloomFilter) UnmarshalVT(dAtA []byte) error

type Filter added in v0.51.0

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

Filter is the runtime bloom filter used by block metadata.

func From added in v0.51.0

func From(words []uint64, m, k uint) *Filter

From constructs a runtime bloom filter from serialized words.

func NewFilter added in v0.51.0

func NewFilter(n uint, p float64) *Filter

NewFilter creates a bloom filter sized for n entries and p false-positive rate.

func (*Filter) Add added in v0.51.0

func (f *Filter) Add(key []byte)

Add inserts a key.

func (*Filter) AddString added in v0.51.0

func (f *Filter) AddString(key string)

AddString inserts a key string.

func (*Filter) Cap added in v0.51.0

func (f *Filter) Cap() uint

Cap returns the number of bits in the filter.

func (*Filter) Copy added in v0.51.0

func (f *Filter) Copy() *Filter

Copy returns a deep copy of the filter.

func (*Filter) K added in v0.51.0

func (f *Filter) K() uint

K returns the number of hash functions.

func (*Filter) Merge added in v0.51.0

func (f *Filter) Merge(other *Filter) error

Merge ORs another filter into this filter.

func (*Filter) Test added in v0.51.0

func (f *Filter) Test(key []byte) bool

Test checks if a key may be present.

func (*Filter) TestString added in v0.51.0

func (f *Filter) TestString(key string) bool

TestString checks if a key string may be present.

func (*Filter) Words added in v0.51.0

func (f *Filter) Words() []uint64

Words returns the underlying bitset words.

Jump to

Keyboard shortcuts

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