Documentation ¶
Overview ¶
Package bloomfilter implements a bloom-filter for pieces that need to be preserved.
Index ¶
- func GenerateSeed() byte
- func OptimalParameters(expectedElements int64, falsePositiveRate float64, maxSize memory.Size) (hashCount byte, sizeInBytes int)
- type Filter
- func (filter *Filter) Add(pieceID storj.PieceID)
- func (filter *Filter) AddFilter(operand *Filter) error
- func (filter *Filter) Bytes() []byte
- func (filter *Filter) Contains(pieceID storj.PieceID) bool
- func (filter *Filter) FillRate() float64
- func (filter *Filter) Parameters() (hashCount, size int)
- func (filter *Filter) SeedAndParameters() (seed, hashCount byte, size int)
- func (filter *Filter) Size() int64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateSeed ¶
func GenerateSeed() byte
GenerateSeed returns a pseudo-random seed between 0 and 254.
func OptimalParameters ¶
func OptimalParameters(expectedElements int64, falsePositiveRate float64, maxSize memory.Size) (hashCount byte, sizeInBytes int)
OptimalParameters returns the optimal parameters for the given expected number of elements, desired false positive rate, and optional maximum memory size.
Types ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter is a bloom filter implementation.
func NewExplicit ¶
NewExplicit returns a new filter with the explicit seed and parameters.
func NewFromBytes ¶
NewFromBytes decodes the filter from a sequence of bytes.
Note: data will be referenced inside the table.
func NewOptimal ¶
NewOptimal returns a filter based on expected element count and false positive rate.
func NewOptimalMaxSize ¶
func NewOptimalMaxSize(expectedElements int64, falsePositiveRate float64, maxSize memory.Size) *Filter
NewOptimalMaxSize returns a filter based on expected element count and false positive rate, capped at a maximum size in bytes.
func (*Filter) AddFilter ¶
AddFilter adds the given filter into the receiver. The filters must have a matching seed and parameters.
func (*Filter) Bytes ¶
Bytes encodes the filter into a sequence of bytes that can be transferred on network.
func (*Filter) Parameters ¶
Parameters returns filter parameters.
func (*Filter) SeedAndParameters ¶
SeedAndParameters returns the seed along with the filter parameters.