bloom

package
v0.0.0-...-a3b3266 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package bloom is a generated GoMock package.

Package bloom is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OptimalHashFunctions

func OptimalHashFunctions(size uint, expectedElements int) uint

OptimalHashFunctions calculates the optimal number of hash functions for a Bloom filter

func OptimalSize

func OptimalSize(expectedElements int, falsePositiveRate float64) uint

OptimalSize calculates the optimal size of the Bloom filter

func SaveFilterToFile

func SaveFilterToFile(bf *Filter, filename string, logger *slog.Logger) error

SaveFilterToFile saves a Bloom filter to a file

Types

type Filter

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

Filter represents a Bloom filter data structure

func LoadFilterFromFile

func LoadFilterFromFile(filename string, logger *slog.Logger) (*Filter, error)

LoadFilterFromFile loads a Bloom filter from a file

func NewBloomFilter

func NewBloomFilter(size uint, numHashFuncs uint, logger *slog.Logger) *Filter

NewBloomFilter creates a new Bloom filter with the given size and number of hash functions

func (*Filter) Add

func (bf *Filter) Add(element []byte)

Add adds an element to the Bloom filter

func (*Filter) Contains

func (bf *Filter) Contains(element []byte) bool

Contains checks if an element might be in the Bloom filter

func (*Filter) FalsePositiveRate

func (bf *Filter) FalsePositiveRate() float64

FalsePositiveRate calculates the current false positive rate of the Bloom filter

func (*Filter) Load

func (bf *Filter) Load(r io.Reader, logger *slog.Logger) error

Load deserializes the Bloom filter from a reader

func (*Filter) Save

func (bf *Filter) Save(w io.Writer) error

Save serializes the Bloom filter to a writer

type MockFileOperations

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

MockFileOperations is a mock of FileOperations interface.

func NewMockFileOperations

func NewMockFileOperations(ctrl *gomock.Controller) *MockFileOperations

NewMockFileOperations creates a new mock instance.

func (*MockFileOperations) Create

func (m *MockFileOperations) Create(arg0 string) (io.WriteCloser, error)

Create mocks base method.

func (*MockFileOperations) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockFileOperations) Open

func (m *MockFileOperations) Open(arg0 string) (io.ReadCloser, error)

Open mocks base method.

type MockFileOperationsMockRecorder

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

MockFileOperationsMockRecorder is the mock recorder for MockFileOperations.

func (*MockFileOperationsMockRecorder) Create

func (mr *MockFileOperationsMockRecorder) Create(arg0 interface{}) *gomock.Call

Create indicates an expected call of Create.

func (*MockFileOperationsMockRecorder) Open

func (mr *MockFileOperationsMockRecorder) Open(arg0 interface{}) *gomock.Call

Open indicates an expected call of Open.

type MockReadCloser

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

MockReadCloser is a mock of ReadCloser interface.

func NewMockReadCloser

func NewMockReadCloser(ctrl *gomock.Controller) *MockReadCloser

NewMockReadCloser creates a new mock instance.

func (*MockReadCloser) Close

func (m *MockReadCloser) Close() error

Close mocks base method.

func (*MockReadCloser) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockReadCloser) Read

func (m *MockReadCloser) Read(arg0 []byte) (int, error)

Read mocks base method.

type MockReadCloserMockRecorder

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

MockReadCloserMockRecorder is the mock recorder for MockReadCloser.

func (*MockReadCloserMockRecorder) Close

func (mr *MockReadCloserMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close.

func (*MockReadCloserMockRecorder) Read

func (mr *MockReadCloserMockRecorder) Read(arg0 interface{}) *gomock.Call

Read indicates an expected call of Read.

type MockWriteCloser

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

MockWriteCloser is a mock of WriteCloser interface.

func NewMockWriteCloser

func NewMockWriteCloser(ctrl *gomock.Controller) *MockWriteCloser

NewMockWriteCloser creates a new mock instance.

func (*MockWriteCloser) Close

func (m *MockWriteCloser) Close() error

Close mocks base method.

func (*MockWriteCloser) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockWriteCloser) Write

func (m *MockWriteCloser) Write(arg0 []byte) (int, error)

Write mocks base method.

type MockWriteCloserMockRecorder

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

MockWriteCloserMockRecorder is the mock recorder for MockWriteCloser.

func (*MockWriteCloserMockRecorder) Close

Close indicates an expected call of Close.

func (*MockWriteCloserMockRecorder) Write

func (mr *MockWriteCloserMockRecorder) Write(arg0 interface{}) *gomock.Call

Write indicates an expected call of Write.

Jump to

Keyboard shortcuts

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