engine_util

package
v0.0.0-...-1338f1b Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CfDefault string = "default"
	CfWrite   string = "write"
	CfLock    string = "lock"
)

Variables

Functions

func CreateDB

func CreateDB(path string, raft bool) *badger.DB

CreateDB creates a new Badger DB on disk at path.

func DeleteCF

func DeleteCF(engine *badger.DB, cf string, key []byte) error

func DeleteRange

func DeleteRange(db *badger.DB, startKey, endKey []byte) error

func ExceedEndKey

func ExceedEndKey(current, endKey []byte) bool

func GetCF

func GetCF(db *badger.DB, cf string, key []byte) (val []byte, err error)

func GetCFFromTxn

func GetCFFromTxn(txn *badger.Txn, cf string, key []byte) (val []byte, err error)

func GetMeta

func GetMeta(engine *badger.DB, key []byte, msg proto.Message) error

func GetMetaFromTxn

func GetMetaFromTxn(txn *badger.Txn, key []byte, msg proto.Message) error

func KeyWithCF

func KeyWithCF(cf string, key []byte) []byte

func PutCF

func PutCF(engine *badger.DB, cf string, key []byte, val []byte) error

func PutMeta

func PutMeta(engine *badger.DB, key []byte, msg proto.Message) error

Types

type BadgerIterator

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

func NewCFIterator

func NewCFIterator(cf string, txn *badger.Txn) *BadgerIterator

func (*BadgerIterator) Close

func (it *BadgerIterator) Close()

func (*BadgerIterator) Item

func (it *BadgerIterator) Item() DBItem

func (*BadgerIterator) Next

func (it *BadgerIterator) Next()

func (*BadgerIterator) Rewind

func (it *BadgerIterator) Rewind()

func (*BadgerIterator) Seek

func (it *BadgerIterator) Seek(key []byte)

func (*BadgerIterator) Valid

func (it *BadgerIterator) Valid() bool

func (*BadgerIterator) ValidForPrefix

func (it *BadgerIterator) ValidForPrefix(prefix []byte) bool

type CFItem

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

func (*CFItem) EstimatedSize

func (i *CFItem) EstimatedSize() int64

func (*CFItem) IsDeleted

func (i *CFItem) IsDeleted() bool

func (*CFItem) IsEmpty

func (i *CFItem) IsEmpty() bool

func (*CFItem) Key

func (i *CFItem) Key() []byte

func (*CFItem) KeyCopy

func (i *CFItem) KeyCopy(dst []byte) []byte

func (*CFItem) String

func (i *CFItem) String() string

String returns a string representation of Item

func (*CFItem) UserMeta

func (i *CFItem) UserMeta() []byte

func (*CFItem) Value

func (i *CFItem) Value() ([]byte, error)

func (*CFItem) ValueCopy

func (i *CFItem) ValueCopy(dst []byte) ([]byte, error)

func (*CFItem) ValueSize

func (i *CFItem) ValueSize() int

func (*CFItem) Version

func (i *CFItem) Version() uint64

type DBItem

type DBItem interface {
	// Key returns the key.
	Key() []byte
	// KeyCopy returns a copy of the key of the item, writing it to dst slice.
	// If nil is passed, or capacity of dst isn't sufficient, a new slice would be allocated and
	// returned.
	KeyCopy(dst []byte) []byte
	// Value retrieves the value of the item.
	Value() ([]byte, error)
	// ValueSize returns the size of the value.
	ValueSize() int
	// ValueCopy returns a copy of the value of the item from the value log, writing it to dst slice.
	// If nil is passed, or capacity of dst isn't sufficient, a new slice would be allocated and
	// returned.
	ValueCopy(dst []byte) ([]byte, error)
}

type DBIterator

type DBIterator interface {
	// Item returns pointer to the current key-value pair.
	Item() DBItem
	// Valid returns false when iteration is done.
	Valid() bool
	// Next would advance the iterator by one. Always check it.Valid() after a Next()
	// to ensure you have access to a valid it.Item().
	Next()
	// Seek would seek to the provided key if present. If absent, it would seek to the next smallest key
	// greater than provided.
	Seek([]byte)

	// Close the iterator
	Close()
}

type Engines

type Engines struct {
	// Data, including data which is committed (i.e., committed across other nodes) and un-committed (i.e., only present
	// locally).
	Kv     *badger.DB
	KvPath string
	// Metadata used by Raft.
	Raft     *badger.DB
	RaftPath string
}

Engines keeps references to and data for the engines used by unistore. All engines are badger key/value databases. the Path fields are the filesystem path to where the data is stored.

func NewEngines

func NewEngines(kvEngine, raftEngine *badger.DB, kvPath, raftPath string) *Engines

func (*Engines) Close

func (en *Engines) Close() error

func (*Engines) Destroy

func (en *Engines) Destroy() error

func (*Engines) WriteKV

func (en *Engines) WriteKV(wb *WriteBatch) error

func (*Engines) WriteRaft

func (en *Engines) WriteRaft(wb *WriteBatch) error

type WriteBatch

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

func (*WriteBatch) DeleteCF

func (wb *WriteBatch) DeleteCF(cf string, key []byte)

func (*WriteBatch) DeleteMeta

func (wb *WriteBatch) DeleteMeta(key []byte)

func (*WriteBatch) Len

func (wb *WriteBatch) Len() int

func (*WriteBatch) MustWriteToDB

func (wb *WriteBatch) MustWriteToDB(db *badger.DB)

func (*WriteBatch) Reset

func (wb *WriteBatch) Reset()

func (*WriteBatch) RollbackToSafePoint

func (wb *WriteBatch) RollbackToSafePoint()

func (*WriteBatch) SetCF

func (wb *WriteBatch) SetCF(cf string, key, val []byte)

func (*WriteBatch) SetMeta

func (wb *WriteBatch) SetMeta(key []byte, msg proto.Message) error

func (*WriteBatch) SetSafePoint

func (wb *WriteBatch) SetSafePoint()

func (*WriteBatch) WriteToDB

func (wb *WriteBatch) WriteToDB(db *badger.DB) error

Jump to

Keyboard shortcuts

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