bff

package module
v0.0.0-...-95ce3e6 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WithCustomMapper = func(f func(size, seed int) func([]byte) int) option {
	return func(opts *Options) {
		opts.CreateMapperFunc = f
	}
}
View Source
var WithErrorRate = func(float64) option {
	panic("not implemented")
}

WithErrorRate - calculate NMappers using expectations for number of elements inserted and false-positive error rate. See https://en.wikipedia.org/wiki/Bloom_filter#Probability_of_false_positives

View Source
var WithNMappers = func(nMappers int) option {
	return func(opts *Options) {
		opts.NMappers = nMappers
	}
}

Functions

This section is empty.

Types

type BloomFiltersController

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

func New

func New(size int, opts ...option) *BloomFiltersController

func (*BloomFiltersController) Acquire

func (bf *BloomFiltersController) Acquire() []uint64

Acquire - get a slice from pool / create new to use as a storage for a bloom filter.

func (*BloomFiltersController) Add

func (bf *BloomFiltersController) Add(data []uint64, s []byte)

Add - encode string into data

func (*BloomFiltersController) Debug

func (bf *BloomFiltersController) Debug(data []uint64, v []byte) string

Debug - print current data state in binary form and highlight bits, that represent value v.

func (*BloomFiltersController) MayContain

func (bf *BloomFiltersController) MayContain(data []uint64, s []byte) bool

MayContain - check that data [possibly] contains s

func (*BloomFiltersController) PreAllocate

func (bf *BloomFiltersController) PreAllocate(n int)

PreAllocate - pre-create several slices and put them into pool in advance to make Acquire() faster

func (*BloomFiltersController) Release

func (bf *BloomFiltersController) Release(v []uint64)

Release - free v for future use

func (*BloomFiltersController) Size

func (bf *BloomFiltersController) Size() int

Size - number of bits

type Index

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

Index - search index implementation using Bloom filters.

func NewIndex

func NewIndex(nParallel int, verifier Verifier, opts ...option) *Index

func (*Index) Add

func (idx *Index) Add(id uint64, searchTerms [][]byte)

func (*Index) Lookup

func (idx *Index) Lookup(searchTerms [][]byte) ([]uint64, error)

type Options

type Options struct {
	CreateMapperFunc func(size, seed int) func([]byte) int
	NMappers         int
}

type SearchEngine

type SearchEngine[T, Q any] struct {
	// contains filtered or unexported fields
}

SearchEngine performs indexing and lookup operations for objects of type T

func NewSearchEngine

func NewSearchEngine[T, Q any](
	termsExtractor TermsExtractor[T, Q],
	verifier Verifier,
	indexOptions ...option,
) *SearchEngine[T, Q]

func (*SearchEngine[T, Q]) Index

func (se *SearchEngine[T, Q]) Index(id uint64, input T)

func (*SearchEngine[T, Q]) Lookup

func (se *SearchEngine[T, Q]) Lookup(query Q) ([]uint64, error)

type TermsExtractor

type TermsExtractor[T, Q any] interface {
	ExtractValueTerms(input T) [][]byte
	ExtractQueryTerms(input Q) [][]byte
}

type Verifier

type Verifier interface {
	Verify(id uint64, terms [][]byte) (bool, error)
}

Jump to

Keyboard shortcuts

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