common

package
v0.0.0-...-d3d32da Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INIT   int = -1
	CLOSED int = -2
)
View Source
const TEST_DIR string = "/tmp/lsmt/"

Variables

View Source
var (
	ERR_LSMT_CLOSED              = errors.New("lsmt is closed")
	ERR_ITER_CLOSED              = errors.New("iterator is closed")
	ERR_KEY_NIL_OR_EMPTY         = errors.New("key must not be nil and must not be empty")
	ERR_VAL_NIL_OR_EMPTY         = errors.New("value must not be nil and must not be empty")
	ERR_KEY_TOO_LARGE            = errors.New("key must not be greater than the maximum key size")
	ERR_VAL_TOO_LARGE            = errors.New("value must not be greater than the maximum value size")
	ERR_START_NIL_OR_EMPTY       = errors.New("start must not be nil and must not be empty")
	ERR_END_NIL_OR_EMPTY         = errors.New("end must not be nil and must not be empty")
	ERR_START_GREATER_THAN_END   = errors.New("start must be less than end")
	ERR_NIL_ITERATOR             = errors.New("unable to flush nil iterator")
	ERR_ITER_GET_INVOKED_ON_INIT = errors.New("Get() invoked before Next()")
	ERR_BLOCK_UNDERFLOW          = errors.New("unable to read all used bytes for in block")
)
View Source
var EMPTY_LEVELS []*config.Level = []*config.Level{}
View Source
var SINGLETON *emptyIterator = &emptyIterator{}
View Source
var Tombstone = []byte{}

Tombstones are values used to represent a deleted key

Functions

func CompareGet

func CompareGet(iter Iterator, key, value []byte, t *testing.T)

func CompareNext

func CompareNext(iter Iterator, expected bool, t *testing.T)

func EmptyIterator

func EmptyIterator() *emptyIterator

func NewMergedIterator

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

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.

func SetUp

func SetUp(t *testing.T)

func TearDown

func TearDown(t *testing.T)

Types

type BloomFilter

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

func NewBloomFilter

func NewBloomFilter(size uint32) *BloomFilter

Creates a new instance of a BloomFilter. Accepts the size, in bytes, of the bitfield.

func (*BloomFilter) Insert

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

Insert a new entry into the set of entries.

func (*BloomFilter) Test

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

Test 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
}

Iterators allow for the sequential movement through ordered data structures Next() 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
}

Container for a key/value pair

type Semaphore

type Semaphore chan placeholder

func NewSemaphore

func NewSemaphore(size int) Semaphore

Creates a new semaphore allowing for a fixed size of locks.

func (Semaphore) IsLocked

func (s Semaphore) IsLocked() bool

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

func (Semaphore) TryLock

func (s Semaphore) TryLock() bool

Try 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()

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