internal

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0, UNKNOWN, UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Overview

Package internal exposes internal functions used within db packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BenchmarkRandomReadsWrites

func BenchmarkRandomReadsWrites(b *testing.B, db db.DB)

func NonNilBytes

func NonNilBytes(bz []byte) []byte

NonNilBytes ensures that bz is a non-nil byte slice (ie. []byte{}).

We defensively turn nil keys or values into []byte{} for most operations.

func RandStr

func RandStr(length int) string

RandStr constructs a random alphanumeric string of given length.

Types

type AtomicSetDeleter

type AtomicSetDeleter interface {
	Mutex() *sync.Mutex
	SetNoLock(key, value []byte)
	SetNoLockSync(key, value []byte)
	DeleteNoLock(key []byte)
	DeleteNoLockSync(key []byte)
}

type MemBatch

type MemBatch struct {
	DB  AtomicSetDeleter
	Ops []Operation
}

func (*MemBatch) Close

func (mBatch *MemBatch) Close()

func (*MemBatch) Delete

func (mBatch *MemBatch) Delete(key []byte)

func (*MemBatch) Set

func (mBatch *MemBatch) Set(key, value []byte)

func (*MemBatch) Write

func (mBatch *MemBatch) Write()

func (*MemBatch) WriteSync

func (mBatch *MemBatch) WriteSync()

type MemIterator

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

We need a copy of all of the keys. Not the best, but probably not a bottleneck depending.

func NewMemIterator

func NewMemIterator(db db.DB, keys []string, start, end []byte) *MemIterator

Keys is expected to be in reverse order for reverse iterators.

func (*MemIterator) Close

func (itr *MemIterator) Close()

Implements Iterator.

func (*MemIterator) Domain

func (itr *MemIterator) Domain() ([]byte, []byte)

Implements Iterator.

func (*MemIterator) Key

func (itr *MemIterator) Key() []byte

Implements Iterator.

func (*MemIterator) Next

func (itr *MemIterator) Next()

Implements Iterator.

func (*MemIterator) Valid

func (itr *MemIterator) Valid() bool

Implements Iterator.

func (*MemIterator) Value

func (itr *MemIterator) Value() []byte

Implements Iterator.

type MockIterator

type MockIterator struct{}

func (MockIterator) Close

func (MockIterator) Close()

func (MockIterator) Domain

func (MockIterator) Domain() (start []byte, end []byte)

func (MockIterator) Key

func (MockIterator) Key() []byte

func (MockIterator) Next

func (MockIterator) Next()

func (MockIterator) Valid

func (MockIterator) Valid() bool

func (MockIterator) Value

func (MockIterator) Value() []byte

type OpType

type OpType int
const (
	OpTypeSet    OpType = 1
	OpTypeDelete OpType = 2
)

type Operation

type Operation struct {
	OpType
	Key   []byte
	Value []byte
}

Jump to

Keyboard shortcuts

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