storage

package
v0.0.0-...-aac2b88 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrReadOnly     = errors.New("storage: read-only transcation")
	ErrSerializable = errors.New("storage: serialization failure, retry transcation")
)
View Source
var ErrNotFound = errors.New("storage: not found")

ErrNotFound is returned when a key is not found in the engine.

Functions

This section is empty.

Types

type BitCaskEngine

type BitCaskEngine struct {
}

type Engine

type Engine interface {
	// Get returns the value for the given key, or any error that occurred.
	// If the key does not exist, it returns ErrNotFound.
	Get(key []byte) ([]byte, error)
	// Set sets the value for the given key.
	Set(key, value []byte) error
	// Delete deletes the value for the given key. Deleting a non-existing key
	// is a no-op.
	Delete(key []byte) error
	// Flush flushes all the pending writes to the underlying storage medium.
	Flush() error
	// Scan returns an iterator that yields all key-value pairs with a key
	// that satisfies the given range bounds, in ascending order.
	Scan(start, end rangeutil.Bound) (itertools.Iterator[KeyValue], error)
	// ReverseScan returns an iterator that yields all key-value pairs with a
	// key that satisfies the given range bounds, in descending order.
	ReverseScan(start, end rangeutil.Bound) (itertools.Iterator[KeyValue], error)
	// ScanPrefix returns an iterator that yields all key-value pairs with a
	// key that has the given prefix, in ascending order.
	ScanPrefix(prefix []byte) (itertools.Iterator[KeyValue], error)
	// ReverseScanPrefix returns an iterator that yields all key-value pairs
	// with a key that has the given prefix, in descending order.
	ReverseScanPrefix(prefix []byte) (itertools.Iterator[KeyValue], error)
	// Status returns the current status of the engine.
	Status() (*storagepb.EngineStatus, error)
	// Close closes the engine.
	Close() error
}

Engine is a key/value storage engine, where both keys and values are arbitrary byte string between 0 B and 2 GB, stored in lexicographical key order. Writes are only guaranteed durable after calling Flush().

This interface is designed to be used by a single goroutine, and implementations are not required to be thread-safe.

type KeyValue

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

KeyValue represents a key-value pair.

func MakeKeyValue

func MakeKeyValue(key, value []byte) KeyValue

MakeKeyValue creates a KeyValue from the given key and value.

type MVCC

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

func NewMVCC

func NewMVCC(engine Engine) *MVCC

func (*MVCC) Begin

func (m *MVCC) Begin() (*MVCCTxn, error)

func (*MVCC) BeginAsOf

func (m *MVCC) BeginAsOf(version MVCCVersion) (*MVCCTxn, error)

func (*MVCC) BeginReadOnly

func (m *MVCC) BeginReadOnly() (*MVCCTxn, error)

func (*MVCC) GetUnversioned

func (m *MVCC) GetUnversioned(key []byte) ([]byte, error)

func (*MVCC) Resume

func (m *MVCC) Resume(state *storagepb.MVCCTxnState) (*MVCCTxn, error)

func (*MVCC) SetUnversioned

func (m *MVCC) SetUnversioned(key, value []byte) error

func (*MVCC) Status

func (m *MVCC) Status() (*storagepb.MVCCStatus, error)

type MVCCTxn

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

func (*MVCCTxn) Commit

func (t *MVCCTxn) Commit() error

func (*MVCCTxn) Delete

func (t *MVCCTxn) Delete(key []byte) error

func (*MVCCTxn) Get

func (t *MVCCTxn) Get(key []byte) ([]byte, error)

func (*MVCCTxn) ReadOnly

func (t *MVCCTxn) ReadOnly() bool

func (*MVCCTxn) ReverseScan

func (t *MVCCTxn) ReverseScan(start, end rangeutil.Bound) (itertools.Iterator[KeyValue], error)

func (*MVCCTxn) Rollback

func (t *MVCCTxn) Rollback() error

func (*MVCCTxn) Scan

func (t *MVCCTxn) Scan(start, end rangeutil.Bound) (itertools.Iterator[KeyValue], error)

func (*MVCCTxn) Set

func (t *MVCCTxn) Set(key, value []byte) error

func (*MVCCTxn) State

func (t *MVCCTxn) State() *storagepb.MVCCTxnState

func (*MVCCTxn) Version

func (t *MVCCTxn) Version() MVCCVersion

type MVCCVersion

type MVCCVersion = uint64

type Memory

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

func NewMemory

func NewMemory() *Memory

func (*Memory) Close

func (m *Memory) Close() error

func (*Memory) Delete

func (m *Memory) Delete(key []byte) error

func (*Memory) Flush

func (m *Memory) Flush() error

func (*Memory) Get

func (m *Memory) Get(key []byte) ([]byte, error)

func (*Memory) ReverseScan

func (m *Memory) ReverseScan(start, end rangeutil.Bound) (itertools.Iterator[KeyValue], error)

func (*Memory) ReverseScanPrefix

func (b *Memory) ReverseScanPrefix(prefix []byte) (itertools.Iterator[KeyValue], error)

func (*Memory) Scan

func (m *Memory) Scan(start, end rangeutil.Bound) (itertools.Iterator[KeyValue], error)

func (*Memory) ScanPrefix

func (b *Memory) ScanPrefix(prefix []byte) (itertools.Iterator[KeyValue], error)

func (*Memory) Set

func (m *Memory) Set(key, value []byte) error

func (*Memory) Status

func (m *Memory) Status() (*storagepb.EngineStatus, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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