Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var MaxIterations = 1024
MaxIterations is the maximum number of iterations allowed before the populate function returns an error.
Functions ¶
This section is empty.
Types ¶
type BinaryFuse ¶ added in v0.2.0
type BinaryFuse[T Unsigned] struct { Seed uint64 SegmentLength uint32 SegmentLengthMask uint32 SegmentCount uint32 SegmentCountLength uint32 Fingerprints []T }
func BuildBinaryFuse ¶ added in v0.3.0
func BuildBinaryFuse[T Unsigned](b *BinaryFuseBuilder, keys []uint64) (BinaryFuse[T], error)
BuildBinaryFuse creates a binary fuse filter with provided keys, reusing buffers from the BinaryFuseBuilder if possible. For best results, the caller should avoid having too many duplicated keys.
The Fingerprints slice in the resulting filter is owned by the builder; it is only valid until the BinaryFuseBuilder is used again.
The function can mutate the given keys slice to remove duplicates.
The function may return an error if the set is empty.
func LoadBinaryFuse ¶ added in v0.4.0
func LoadBinaryFuse[T Unsigned](r io.Reader) (*BinaryFuse[T], error)
LoadBinaryFuse reads the filter from the reader assuming little endian system, using direct byte copy for performance.
func NewBinaryFuse ¶ added in v0.2.0
func NewBinaryFuse[T Unsigned](keys []uint64) (*BinaryFuse[T], error)
NewBinaryFuse creates a binary fuse filter with provided keys. For best results, the caller should avoid having too many duplicated keys.
The function can mutate the given keys slice to remove duplicates.
The function may return an error if the set is empty.
func (*BinaryFuse[T]) Contains ¶ added in v0.2.0
func (filter *BinaryFuse[T]) Contains(key uint64) bool
Contains returns `true` if key is part of the set with a false positive probability.
type BinaryFuse8 ¶
type BinaryFuse8 BinaryFuse[uint8]
func LoadBinaryFuse8 ¶ added in v0.4.0
func LoadBinaryFuse8(r io.Reader) (*BinaryFuse8, error)
LoadBinaryFuse8 reads the filter from the reader in little endian format.
func PopulateBinaryFuse8 ¶
func PopulateBinaryFuse8(keys []uint64) (*BinaryFuse8, error)
PopulateBinaryFuse8 fills the filter with provided keys. For best results, the caller should avoid having too many duplicated keys. The function may return an error if the set is empty.
func (*BinaryFuse8) Contains ¶
func (filter *BinaryFuse8) Contains(key uint64) bool
Contains returns `true` if key is part of the set with a false positive probability of <0.4%.
type BinaryFuseBuilder ¶ added in v0.3.0
type BinaryFuseBuilder struct {
// contains filtered or unexported fields
}
BinaryFuseBuilder can be used to reuse memory allocations across multiple BinaryFuse builds.
An empty BinaryFuseBuilder can be used, and its internal memory will grow as needed over time. MakeBinaryFuseBuilder can also be used to pre-initialize for a certain size.
func MakeBinaryFuseBuilder ¶ added in v0.5.1
func MakeBinaryFuseBuilder[T Unsigned](initialSize int) BinaryFuseBuilder
MakeBinaryFuseBuilder creates a BinaryFuseBuilder with enough preallocated memory to allow building of binary fuse filters with fingerprint type T without allocations.
Note that the builder can be used with a smaller fingerprint type without reallocations. If it is used with a larger fingerprint type, there will be one reallocation for the fingerprints slice.
