Documentation ¶
Index ¶
- Constants
- Variables
- func BloomBitsPerKey(numEntries int, fp float64) int
- func BytesToU32(b []byte) uint32
- func BytesToU32Slice(b []byte) []uint32
- func BytesToU64(b []byte) uint64
- func BytesToU64Slice(b []byte) []uint64
- func DefaultLogger(level level) *defaultLog
- func FastRand() uint32
- func Hash(b []byte) uint32
- func Max(a, b int) int
- func Min(a, b int) int
- func U32SliceToBytes(u32s []uint32) []byte
- func U32ToBytes(v uint32) []byte
- func U64SliceToBytes(u64s []uint64) []byte
- func U64ToBytes(v uint64) []byte
- func VerifyCheckSum(data []byte, checksum []byte) bool
- func ZSTDCompress(dst, src []byte, compressionLevel int) ([]byte, error)
- func ZSTDCompressBound(srcSize int) int
- func ZSTDDecompress(dst, src []byte) ([]byte, error)
- type Arena
- type BloomFilter
- type CloseHandler
- type Closer
- type Comparator
- type DirLockGuard
- type HashReader
- type Iterator
- type Logger
- type MmapFile
- type Skiplist
- type Throttle
Constants ¶
const ( DEBUG level = iota INFO WARNING ERROR SLICENCE )
const CgoEnabled = true
CgoEnabled is used to check if CGO is enabled while building badger.
const (
MaxNodeSize = int(unsafe.Sizeof(node{}))
)
const RW_ = 0666
Variables ¶
var CastagnoliCrcTable = crc32.MakeTable(crc32.Castagnoli)
Functions ¶
func BloomBitsPerKey ¶
func BytesToU32 ¶
BytesToU32 converts the given byte slice to uint32
func BytesToU32Slice ¶
BytesToU32Slice converts the given byte slice to uint32 slice
func BytesToU64 ¶
BytesToU64 converts the given byte slice to uint64
func BytesToU64Slice ¶
BytesToU64Slice converts the given byte slice to uint64 slice
func DefaultLogger ¶
func DefaultLogger(level level) *defaultLog
func U32SliceToBytes ¶
U32SliceToBytes converts the given Uint32 slice to byte slice
func U64SliceToBytes ¶
U64SliceToBytes converts the given Uint64 slice to byte slice
func VerifyCheckSum ¶
func ZSTDCompress ¶
ZSTDCompress compresses a block using ZSTD algorithm.
func ZSTDCompressBound ¶
ZSTDCompressBound returns the worst case size needed for a destination buffer.
func ZSTDDecompress ¶
ZSTDDecompress decompresses a block using ZSTD algorithm.
Types ¶
type BloomFilter ¶
type BloomFilter []byte
func NewBloomFilter ¶
func NewBloomFilter(keys []uint32, bitsPerKey int) BloomFilter
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 (BloomFilter) MayContain ¶
func (bf BloomFilter) MayContain(key []byte) 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 (BloomFilter) MayContainHash ¶
func (bf BloomFilter) MayContainHash(hash uint32) bool
type CloseHandler ¶
type CloseHandler func()
type Closer ¶
type Closer struct {
// contains filtered or unexported fields
}
Closer holds the two things we need to close a goroutine and wait for it to finish: a chan to tell the goroutine to shut down, and a WaitGroup with which to wait for it to finish shutting down.
func (*Closer) AddRunning ¶
AddRunning Add()'s delta to the WaitGroup.
func (*Closer) Ctx ¶
Ctx can be used to get a context, which would automatically get cancelled when Signal is called.
func (*Closer) HasBeenClosed ¶
func (c *Closer) HasBeenClosed() <-chan struct{}
HasBeenClosed gets signaled when Signal() is called.
func (*Closer) SignalAndWait ¶
func (c *Closer) SignalAndWait()
SignalAndWait calls Signal(), then Wait().
type Comparator ¶
type DirLockGuard ¶
type DirLockGuard struct {
// contains filtered or unexported fields
}
dirLockGuard holds a lock on a directory and a pid file inside.
func AcquireDirLock ¶
func AcquireDirLock(dir string, pidFileName string) (*DirLockGuard, error)
AcquireDirLock gets a lock on the directory (using flock). It will also write our pid to dir/pidFileName for convenience.
func (*DirLockGuard) Release ¶
func (g *DirLockGuard) Release() error
Release deletes the pid file and releases lock on the directory.
type HashReader ¶
type HashReader struct {
// contains filtered or unexported fields
}
func NewHashReader ¶
func NewHashReader(r io.Reader) *HashReader
func (*HashReader) BytesRead ¶
func (t *HashReader) BytesRead() int
func (*HashReader) Read ¶
func (t *HashReader) Read(p []byte) (int, error)
Read reads len(p) bytes from the reader. Returns the number of bytes read, error on failure.
func (*HashReader) ReadByte ¶
func (t *HashReader) ReadByte() (byte, error)
ReadByte reads exactly one byte from the reader. Returns error on failure.
func (*HashReader) Sum32 ¶
func (t *HashReader) Sum32() uint32
Sum32 returns the sum32 of the underlying hash.
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
func (*Iterator) SeekToFirst ¶
func (i *Iterator) SeekToFirst()
func (*Iterator) SeekToLast ¶
func (i *Iterator) SeekToLast()
type MmapFile ¶
type MmapFile struct { Data []byte Fd *os.File NewFile bool // if a file is created when it open, this is true }
func OpenMmapFileWithFD ¶
func (*MmapFile) CloseWithTruncate ¶
type Skiplist ¶
type Skiplist struct { Hanlder CloseHandler // contains filtered or unexported fields }
func NewSkiplist ¶
func NewSkiplist(arenaSize uint32, cmp Comparator) *Skiplist
type Throttle ¶
type Throttle struct {
// contains filtered or unexported fields
}
Throttle allows a limited number of workers to run at a time. It also provides a mechanism to check for errors encountered by workers and wait for them to finish.
func NewThrottle ¶
NewThrottle creates a new throttle with a max number of workers.
func (*Throttle) Do ¶
Do should be called by workers before they start working. It blocks if there are already maximum number of workers working. If it detects an error from previously Done workers, it would return it.
func (*Throttle) Done ¶
Done should be called by workers when they finish working. They can also pass the error status of work done.