engine

package
v0.0.0-...-81f3bb6 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BadgerDB

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

func (*BadgerDB) Clear

func (b *BadgerDB) Clear(key []byte) error

func (*BadgerDB) Close

func (b *BadgerDB) Close()

func (*BadgerDB) Get

func (b *BadgerDB) Get(key []byte) ([]byte, error)

func (*BadgerDB) NewBatch

func (b *BadgerDB) NewBatch(update bool) Batch

func (*BadgerDB) NewIterator

func (b *BadgerDB) NewIterator() Iterator

func (*BadgerDB) NewSnapshot

func (b *BadgerDB) NewSnapshot() Reader

NewSnapshot creates a snapshot handle from engine and returns a read-only rocksDBSnapshot engine.

func (*BadgerDB) Put

func (b *BadgerDB) Put(key []byte, value []byte) error

func (*BadgerDB) QuickBackupDone

func (b *BadgerDB) QuickBackupDone() error

func (*BadgerDB) QuickBackupPrepare

func (b *BadgerDB) QuickBackupPrepare() ([]*os.File, error)

type Batch

type Batch interface {
	ReadWriter
	// Commit atomically applies any batched updates to the underlying
	// engine. This is a noop unless the engine was created via NewBatch(). If
	// sync is true, the batch is synchronously committed to disk.
	Commit() error
}

Batch is the interface for batch specific operations.

type Engine

type Engine interface {
	ReadWriter
	//// Not thread safe.
	//GetAuxiliaryDir() string
	// NewBatch returns a new instance of a batched engine which wraps
	// this engine. Batched engines accumulate all mutations and apply
	// them atomically on a call to Commit().
	NewBatch(update bool) Batch
	// NewSnapshot returns a new instance of a read-only snapshot
	// engine. Snapshots are instantaneous and, as long as they're
	// released relatively quickly, inexpensive. Snapshots are released
	// by invoking Close(). Note that snapshots must not be used after the
	// original engine has been stopped.
	NewSnapshot() Reader
}

Engine is the interface that wraps the core operations of a key/value store.

func NewBadgerDB

func NewBadgerDB(opt *KVOpt) (Engine, error)

type ItemIntf

type ItemIntf interface {
	Key() []byte
	Value() ([]byte, error)
}

type Iterator

type Iterator interface {
	SimpleIterator

	Item() ItemIntf
}

type KVOpt

type KVOpt struct {
	Dir string
}

type ReadWriter

type ReadWriter interface {
	Reader
	Writer
}

ReadWriter is the read/write interface to an engine's data.

type Reader

type Reader interface {
	// Close closes the reader, freeing up any outstanding resources. Note that
	// various implementations have slightly different behaviors. In particular,
	// Distinct() batches release their parent batch for future use while
	// Engines, Snapshots and Batches free the associated C++ resources.
	Close()
	// Get returns the value for the given key, nil otherwise.
	Get(key []byte) ([]byte, error)
	// NewIterator returns a new instance of an Iterator over this engine. When
	// prefix is true, Seek will use the user-key prefix of the supplied MVCC key
	// to restrict which sstables are searched, but iteration (using Next) over
	// keys without the same user-key prefix will not work correctly (keys may be
	// skipped). The caller must invoke Iterator.Close() when finished with the
	// iterator to free resources.
	NewIterator() Iterator
}

Reader is the read interface to an engine's data.

type SimpleIterator

type SimpleIterator interface {
	// Close frees up resources held by the iterator.
	Close()
	// Seek advances the iterator to the first key in the engine which
	// is >= the provided key.
	Seek(key []byte)
	// Valid must be called after any call to Seek(), Next(), Prev(), or
	// similar methods. It returns (true, nil) if the iterator points to
	// a valid key (it is undefined to call Key(), Value(), or similar
	// methods unless Valid() has returned (true, nil)). It returns
	// (false, nil) if the iterator has moved past the end of the valid
	// range, or (false, err) if an error has occurred. Valid() will
	// never return true with a non-nil error.
	Valid() bool
	ValidForPrefix(prefix []byte) bool
	// Next advances the iterator to the next key/value in the
	// iteration. After this call, Valid() will be true if the
	// iterator was not positioned at the last key.
	Next()

	Rewind()
}

SimpleIterator is an interface for iterating over key/value pairs in an engine. SimpleIterator implementations are thread safe unless otherwise noted. SimpleIterator is a subset of the functionality offered by Iterator.

type Writer

type Writer interface {
	//// Clear removes the item from the db with the given key.
	//// Note that clear actually removes entries from the storage
	//// engine, rather than inserting tombstones.
	Clear(key []byte) error

	//// The logic for merges is written in db.cc in order to be compatible with RocksDB.
	//Merge(key MVCCKey, value []byte) error
	// Put sets the given key to the value provided.
	Put(key []byte, value []byte) error
}

Writer is the write interface to an engine's data.

Jump to

Keyboard shortcuts

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