db

package
v0.0.0-...-1d5e6b2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2016 License: Apache-2.0 Imports: 9 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDB

func CreateDB() error

CreateDB creates a rocks db database

Types

type OpenchainDB

type OpenchainDB struct {
	DB           *gorocksdb.DB
	BlockchainCF *gorocksdb.ColumnFamilyHandle
	StateCF      *gorocksdb.ColumnFamilyHandle
	StateDeltaCF *gorocksdb.ColumnFamilyHandle
	IndexesCF    *gorocksdb.ColumnFamilyHandle
	PersistCF    *gorocksdb.ColumnFamilyHandle
}

OpenchainDB encapsulates rocksdb's structures

func GetDBHandle

func GetDBHandle() *OpenchainDB

GetDBHandle returns a handle to OpenchainDB

func (*OpenchainDB) CloseDB

func (openchainDB *OpenchainDB) CloseDB()

CloseDB releases all column family handles and closes rocksdb

func (*OpenchainDB) Delete

func (openchainDB *OpenchainDB) Delete(cfHandler *gorocksdb.ColumnFamilyHandle, key []byte) error

Delete delets the given key in the specified column family

func (*OpenchainDB) DeleteState

func (openchainDB *OpenchainDB) DeleteState() error

DeleteState delets ALL state keys/values from the DB. This is generally only used during state synchronization when creating a new state from a snapshot.

func (*OpenchainDB) Get

func (openchainDB *OpenchainDB) Get(cfHandler *gorocksdb.ColumnFamilyHandle, key []byte) ([]byte, error)

Get returns the valud for the given column family and key

func (*OpenchainDB) GetBlockchainCFIterator

func (openchainDB *OpenchainDB) GetBlockchainCFIterator() *gorocksdb.Iterator

GetBlockchainCFIterator get iterator for column family - blockchainCF

func (*OpenchainDB) GetFromBlockchainCF

func (openchainDB *OpenchainDB) GetFromBlockchainCF(key []byte) ([]byte, error)

GetFromBlockchainCF get value for given key from column family - blockchainCF

func (*OpenchainDB) GetFromBlockchainCFSnapshot

func (openchainDB *OpenchainDB) GetFromBlockchainCFSnapshot(snapshot *gorocksdb.Snapshot, key []byte) ([]byte, error)

GetFromBlockchainCFSnapshot get value for given key from column family in a DB snapshot - blockchainCF

func (*OpenchainDB) GetFromIndexesCF

func (openchainDB *OpenchainDB) GetFromIndexesCF(key []byte) ([]byte, error)

GetFromIndexesCF get value for given key from column family - indexCF

func (*OpenchainDB) GetFromStateCF

func (openchainDB *OpenchainDB) GetFromStateCF(key []byte) ([]byte, error)

GetFromStateCF get value for given key from column family - stateCF

func (*OpenchainDB) GetFromStateDeltaCF

func (openchainDB *OpenchainDB) GetFromStateDeltaCF(key []byte) ([]byte, error)

GetFromStateDeltaCF get value for given key from column family - stateDeltaCF

func (*OpenchainDB) GetIterator

func (openchainDB *OpenchainDB) GetIterator(cfHandler *gorocksdb.ColumnFamilyHandle) *gorocksdb.Iterator

GetIterator returns an iterator for the given column family

func (*OpenchainDB) GetSnapshot

func (openchainDB *OpenchainDB) GetSnapshot() *gorocksdb.Snapshot

GetSnapshot returns a point-in-time view of the DB. You MUST call snapshot.Release() when you are done with the snapshot.

func (*OpenchainDB) GetStateCFIterator

func (openchainDB *OpenchainDB) GetStateCFIterator() *gorocksdb.Iterator

GetStateCFIterator get iterator for column family - stateCF

func (*OpenchainDB) GetStateCFSnapshotIterator

func (openchainDB *OpenchainDB) GetStateCFSnapshotIterator(snapshot *gorocksdb.Snapshot) *gorocksdb.Iterator

GetStateCFSnapshotIterator get iterator for column family - stateCF. This iterator is based on a snapshot and should be used for long running scans, such as reading the entire state. Remember to call iterator.Close() when you are done.

func (*OpenchainDB) GetStateDeltaCFIterator

func (openchainDB *OpenchainDB) GetStateDeltaCFIterator() *gorocksdb.Iterator

GetStateDeltaCFIterator get iterator for column family - stateDeltaCF

func (*OpenchainDB) Put

func (openchainDB *OpenchainDB) Put(cfHandler *gorocksdb.ColumnFamilyHandle, key []byte, value []byte) error

Put saves the key/value in the given column family

type TestDBWrapper

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

TestDBWrapper wraps the db. Can be used by other modules for testing

func NewTestDBWrapper

func NewTestDBWrapper() *TestDBWrapper

NewTestDBWrapper constructs a new TestDBWrapper

func (*TestDBWrapper) CloseDB

func (testDB *TestDBWrapper) CloseDB(t testing.TB)

CloseDB closes the db

func (*TestDBWrapper) CreateFreshDB

func (testDB *TestDBWrapper) CreateFreshDB(t testing.TB)

CreateFreshDB This method closes existing db, remove the db dir and create db again. Can be called before starting a test so that data from other tests does not interfere

func (*TestDBWrapper) CreateFreshDBGinkgo

func (testDB *TestDBWrapper) CreateFreshDBGinkgo() error

CreateFreshDBGinkgo creates a fresh database for ginkgo testing

func (*TestDBWrapper) GetDBStats

func (testDB *TestDBWrapper) GetDBStats() string

GetDBStats returns statistics for the database

func (*TestDBWrapper) GetEstimatedNumKeys

func (testDB *TestDBWrapper) GetEstimatedNumKeys(t testing.TB) map[string]string

GetEstimatedNumKeys returns estimated number of key-values in db. This is not accurate in all the cases

func (*TestDBWrapper) GetFromDB

func (testDB *TestDBWrapper) GetFromDB(t testing.TB, key []byte) []byte

GetFromDB gets the value for the given key from default column-family

func (*TestDBWrapper) GetFromStateCF

func (testDB *TestDBWrapper) GetFromStateCF(t testing.TB, key []byte) []byte

GetFromStateCF tests can use this method for getting value from StateCF column-family

func (*TestDBWrapper) GetFromStateDeltaCF

func (testDB *TestDBWrapper) GetFromStateDeltaCF(t testing.TB, key []byte) []byte

GetFromStateDeltaCF tests can use this method for getting value from StateDeltaCF column-family

func (*TestDBWrapper) WriteToDB

func (testDB *TestDBWrapper) WriteToDB(t testing.TB, writeBatch *gorocksdb.WriteBatch)

WriteToDB tests can use this method for persisting a given batch to db

Jump to

Keyboard shortcuts

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