utils

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BloomBitsPerKey

func BloomBitsPerKey(numEntries int, fp float64) int

BloomBitsPerKey returns the bits per key required by bloomfilter based on the false positive rate.

func CalculateChecksum

func CalculateChecksum(data []byte) uint64

func FID

func FID(name string) uint64

FID 根据file name 获取其fid;

func FileNameSSTable

func FileNameSSTable(dir string, id uint64) string

func Hash

func Hash(b []byte) uint32

func LoadIDMap

func LoadIDMap(dir string) map[uint64]struct{}

func SyncDir

func SyncDir(dir string) error

func VerifyChecksum

func VerifyChecksum(data []byte, expected []byte) error

func VlogFilePath

func VlogFilePath(dirPath string, fid uint32) string

Types

type Closer

type Closer struct {
	CloseSignal chan struct{}
	// contains filtered or unexported fields
}

func NewCloser

func NewCloser(add int) *Closer

func (*Closer) Add

func (c *Closer) Add(n int)

func (*Closer) CloseAndWait

func (c *Closer) CloseAndWait()

func (*Closer) Done

func (c *Closer) Done()

type FileOptions

type FileOptions struct {
	FID      uint64
	FileName string
	Dir      string
	Path     string
	Flag     int
	MaxSz    int32
}

type Filter

type Filter []byte

func NewFilter

func NewFilter(keys []uint32, bitsPerKey int) Filter

NewFilter returns a new Bloom filter that encodes a set of []byte keys with the given number of bits per key, approximately.

A good bitsPerKey value is 10, which yields a filter with ~ 1% false positive rate.

func (Filter) MayContain

func (f Filter) MayContain(h uint32) bool

MayContain returns whether the filter may contain given key. False positives are possible, where it returns true for keys not in the original set.

func (Filter) MayContainKey

func (f Filter) MayContainKey(k []byte) bool

type Throttle

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

func NewThrottle

func NewThrottle(max int) *Throttle

func (*Throttle) Do

func (t *Throttle) Do() error

func (*Throttle) Done

func (t *Throttle) Done(err error)

func (*Throttle) Finish

func (t *Throttle) Finish() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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