common

package
v0.0.0-...-5b112dc Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INIT   int = -1
	CLOSED int = -2
)

Variables

View Source
var (
	ErrLSMTClosed     = errors.New("[LSMT] lsmt is closed")
	ErrEmptyKey       = errors.New("[LSMT] key must not be nil and must not be empty")
	ErrMaxKeySize     = errors.New("[LSMT] key must not be greater than the maximum key size")
	ErrEmptyValue     = errors.New("[LSMT] value must not be nil and must not not be empty")
	ErrMaxValueSize   = errors.New("[LSMT] value must not be greater than the maximum value size")
	ErrKeyOutOfBounds = errors.New("[LSMT] one or more keys is out of the required bounds")
)
View Source
var Tombstone = []byte{}

Tombstone represents a "deleted" key

Functions

func NewMergedIterator

func NewMergedIterator(iterators []Iterator, returnTombstone bool) *mergedIterator

NewMergedIterator creates a new merged iterator from the given slice of iterators. The iterators are expected to be passed in priority order, meaning that if two or more iterators contain the same key then accept the pair from the iterator at the smaller index. Each key will only be returned once from a merged iterator and it is assumed that each key only appears once in each provided iterator.

Accepts a returnTombstone parameter which indicates whether to return pairs with a tombstone value.

Types

type BloomFilter

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

func NewBloomFilter

func NewBloomFilter(size uint32) *BloomFilter

NewBloomFilter creates a new instance of a BloomFilter. Accepts the size, in bytes, of the bitfield as well as the number of hashing functions to use. The number of hashing functions must be either 1 or 2.

func (*BloomFilter) Insert

func (bf *BloomFilter) Insert(bytes []byte)

Insert inserts a new entry into the set of entries.

func (*BloomFilter) Test

func (bf *BloomFilter) Test(bytes []byte) bool

Test tests whether an entry exists within the set of entries. The return value is probabilistic and only indicates whether an entry is definitively not present (false) or may be present (true).

type Iterator

type Iterator interface {
	Next() (bool, error)
	Get() (*Pair, error)
	Close() error
}

Iterator describes an interator interface and allows for the sequential movement through ordered data structures. The Next() method must always be called before Get(). If Next() returns false then there are no more values to Get() and Close() should be invoked.

type Pair

type Pair struct {
	Key   []byte
	Value []byte
}

Pair is a container for a key/value pair

type Semaphore

type Semaphore chan placeholder

func NewSemaphore

func NewSemaphore(size int) Semaphore

NewSemaphore creates a new semaphore allowing for a fixed size of locks.

func (Semaphore) IsLocked

func (s Semaphore) IsLocked() bool

IsLocked returns true if the semaphore is fully locked, false if there are still slots available

func (Semaphore) TryLock

func (s Semaphore) TryLock() bool

TryLock tries to acquire a lock, returns true if the lock was acquired and false otherwise. It is assumed that all calls to TryLock which succeed will be responsible for their own call to Unlock.

func (Semaphore) Unlock

func (s Semaphore) Unlock()

Unlock unlocks a lock. This function assumes that the caller had previously called TryLock successfully. This function also assumed that Unlock will be called only once per unlock attempt.

Jump to

Keyboard shortcuts

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