db

package
v2.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 19 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DBTypeGoLevelDB DBType = "goleveldb"
	DBTypeRocksDB   DBType = "rocksdb"
	DBTypePebbleDB  DBType = "pebbledb"
	DBTypePrefixDB  DBType = "prefixdb"

	DBFileSuffix string = ".db"
)

Variables

This section is empty.

Functions

func IteratePrefix

func IteratePrefix(db corestore.KVStore, prefix []byte) (corestore.Iterator, error)

IteratePrefix is a convenience function for iterating over a key domain restricted by prefix.

func NewDB

func NewDB(dbType DBType, name, dataDir string, opts coreserver.DynamicConfig) (corestore.KVStoreWithBatch, error)

Types

type DBType

type DBType string

type GoLevelDB

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

GoLevelDB implements corestore.KVStore using github.com/syndtr/goleveldb/leveldb. It is used for only store v2 migration, since some clients use goleveldb as the IAVL v0/v1 backend.

func NewGoLevelDB

func NewGoLevelDB(name, dir string, opts coreserver.DynamicConfig) (*GoLevelDB, error)

func NewGoLevelDBWithOpts

func NewGoLevelDBWithOpts(name, dir string, o *opt.Options) (*GoLevelDB, error)

func (*GoLevelDB) Close

func (db *GoLevelDB) Close() error

Close implements corestore.KVStore.

func (*GoLevelDB) Delete

func (db *GoLevelDB) Delete(key []byte) error

Delete implements corestore.KVStore.

func (*GoLevelDB) DeleteSync

func (db *GoLevelDB) DeleteSync(key []byte) error

DeleteSync implements corestore.KVStore.

func (*GoLevelDB) ForceCompact

func (db *GoLevelDB) ForceCompact(start, limit []byte) error

func (*GoLevelDB) Get

func (db *GoLevelDB) Get(key []byte) ([]byte, error)

Get implements corestore.KVStore.

func (*GoLevelDB) Has

func (db *GoLevelDB) Has(key []byte) (bool, error)

Has implements corestore.KVStore.

func (*GoLevelDB) Iterator

func (db *GoLevelDB) Iterator(start, end []byte) (corestore.Iterator, error)

Iterator implements corestore.KVStore.

func (*GoLevelDB) NewBatch

func (db *GoLevelDB) NewBatch() corestore.Batch

NewBatch implements corestore.BatchCreator.

func (*GoLevelDB) NewBatchWithSize

func (db *GoLevelDB) NewBatchWithSize(size int) corestore.Batch

NewBatchWithSize implements corestore.BatchCreator.

func (*GoLevelDB) Print

func (db *GoLevelDB) Print() error

Print implements corestore.KVStore.

func (*GoLevelDB) RawDB

func (db *GoLevelDB) RawDB() *leveldb.DB

func (*GoLevelDB) ReverseIterator

func (db *GoLevelDB) ReverseIterator(start, end []byte) (corestore.Iterator, error)

ReverseIterator implements corestore.KVStore.

func (*GoLevelDB) Set

func (db *GoLevelDB) Set(key, value []byte) error

Set implements corestore.KVStore.

func (*GoLevelDB) SetSync

func (db *GoLevelDB) SetSync(key, value []byte) error

SetSync implements corestore.KVStore.

func (*GoLevelDB) Stats

func (db *GoLevelDB) Stats() map[string]string

Stats implements corestore.KVStore.

type MemDB

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

MemDB is an in-memory database backend using a B-tree for storage.

For performance reasons, all given and returned keys and values are pointers to the in-memory database, so modifying them will cause the stored values to be modified as well. All DB methods already specify that keys and values should be considered read-only, but this is especially important with MemDB.

func NewMemDB

func NewMemDB() *MemDB

NewMemDB creates a new in-memory database.

func (*MemDB) Close

func (db *MemDB) Close() error

Close implements DB.

func (*MemDB) Delete

func (db *MemDB) Delete(key []byte) error

Delete implements DB.

func (*MemDB) DeleteSync

func (db *MemDB) DeleteSync(key []byte) error

DeleteSync implements DB.

func (*MemDB) Get

func (db *MemDB) Get(key []byte) ([]byte, error)

Get implements DB.

func (*MemDB) Has

func (db *MemDB) Has(key []byte) (bool, error)

Has implements DB.

func (*MemDB) Iterator

func (db *MemDB) Iterator(start, end []byte) (corestore.Iterator, error)

Iterator implements DB. Takes out a read-lock on the database until the iterator is closed.

func (*MemDB) IteratorNoMtx

func (db *MemDB) IteratorNoMtx(start, end []byte) (corestore.Iterator, error)

IteratorNoMtx makes an iterator with no mutex.

func (*MemDB) NewBatch

func (db *MemDB) NewBatch() corestore.Batch

NewBatch implements DB.

func (*MemDB) NewBatchWithSize

func (db *MemDB) NewBatchWithSize(size int) corestore.Batch

NewBatchWithSize implements DB. It does the same thing as NewBatch because we can't pre-allocate memDBBatch

func (*MemDB) Print

func (db *MemDB) Print() error

Print implements DB.

func (*MemDB) ReverseIterator

func (db *MemDB) ReverseIterator(start, end []byte) (corestore.Iterator, error)

ReverseIterator implements DB. Takes out a read-lock on the database until the iterator is closed.

func (*MemDB) ReverseIteratorNoMtx

func (db *MemDB) ReverseIteratorNoMtx(start, end []byte) (corestore.Iterator, error)

ReverseIteratorNoMtx makes an iterator with no mutex.

func (*MemDB) Set

func (db *MemDB) Set(key, value []byte) error

Set implements DB.

func (*MemDB) SetSync

func (db *MemDB) SetSync(key, value []byte) error

SetSync implements DB.

func (*MemDB) Stats

func (db *MemDB) Stats() map[string]string

Stats implements DB.

type PebbleDB

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

PebbleDB implements `corestore.KVStoreWithBatch` using PebbleDB as the underlying storage engine. It is used for only store v2 migration, since some clients use PebbleDB as the IAVL v0/v1 backend.

func NewPebbleDB

func NewPebbleDB(name, dataDir string) (*PebbleDB, error)

func NewPebbleDBWithOpts

func NewPebbleDBWithOpts(name, dataDir string, opts coreserver.DynamicConfig) (*PebbleDB, error)

func (*PebbleDB) Close

func (db *PebbleDB) Close() error

func (*PebbleDB) Delete

func (db *PebbleDB) Delete(key []byte) error

func (*PebbleDB) Get

func (db *PebbleDB) Get(key []byte) ([]byte, error)

func (*PebbleDB) Has

func (db *PebbleDB) Has(key []byte) (bool, error)

func (*PebbleDB) Iterator

func (db *PebbleDB) Iterator(start, end []byte) (corestore.Iterator, error)

func (*PebbleDB) NewBatch

func (db *PebbleDB) NewBatch() corestore.Batch

func (*PebbleDB) NewBatchWithSize

func (db *PebbleDB) NewBatchWithSize(size int) corestore.Batch

func (*PebbleDB) ReverseIterator

func (db *PebbleDB) ReverseIterator(start, end []byte) (corestore.Iterator, error)

func (*PebbleDB) Set

func (db *PebbleDB) Set(key, value []byte) error

type PrefixDB

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

PrefixDB wraps a namespace of another database as a logical database.

func NewPrefixDB

func NewPrefixDB(db corestore.KVStoreWithBatch, prefix []byte) *PrefixDB

NewPrefixDB lets you namespace multiple corestore.KVStores within a single corestore.KVStore.

func (*PrefixDB) Close

func (pdb *PrefixDB) Close() error

Close implements corestore.KVStore.

func (*PrefixDB) Delete

func (pdb *PrefixDB) Delete(key []byte) error

Delete implements corestore.KVStore.

func (*PrefixDB) Get

func (pdb *PrefixDB) Get(key []byte) ([]byte, error)

Get implements corestore.KVStore.

func (*PrefixDB) Has

func (pdb *PrefixDB) Has(key []byte) (bool, error)

Has implements corestore.KVStore.

func (*PrefixDB) Iterator

func (pdb *PrefixDB) Iterator(start, end []byte) (corestore.Iterator, error)

Iterator implements corestore.KVStore.

func (*PrefixDB) NewBatch

func (pdb *PrefixDB) NewBatch() corestore.Batch

NewBatch implements corestore.BatchCreator.

func (*PrefixDB) NewBatchWithSize

func (pdb *PrefixDB) NewBatchWithSize(size int) corestore.Batch

NewBatchWithSize implements corestore.BatchCreator.

func (*PrefixDB) Print

func (pdb *PrefixDB) Print() error

Print implements corestore.KVStore.

func (*PrefixDB) ReverseIterator

func (pdb *PrefixDB) ReverseIterator(start, end []byte) (corestore.Iterator, error)

ReverseIterator implements corestore.KVStore.

func (*PrefixDB) Set

func (pdb *PrefixDB) Set(key, value []byte) error

Set implements corestore.KVStore.

type RocksDB

type RocksDB struct{}

RocksDB implements `corestore.KVStoreWithBatch` using RocksDB as the underlying storage engine. It is used for only store v2 migration, since some clients use RocksDB as the IAVL v0/v1 backend.

func NewRocksDB

func NewRocksDB(name, dataDir string) (*RocksDB, error)

func NewRocksDBWithOpts

func NewRocksDBWithOpts(dataDir string, opts coreserver.DynamicConfig) (*RocksDB, error)

func (*RocksDB) Close

func (db *RocksDB) Close() error

func (*RocksDB) Delete

func (db *RocksDB) Delete(key []byte) error

func (*RocksDB) Get

func (db *RocksDB) Get(key []byte) ([]byte, error)

func (*RocksDB) Has

func (db *RocksDB) Has(key []byte) (bool, error)

func (*RocksDB) Iterator

func (db *RocksDB) Iterator(start, end []byte) (corestore.Iterator, error)

func (*RocksDB) NewBatch

func (db *RocksDB) NewBatch() corestore.Batch

func (*RocksDB) NewBatchWithSize

func (db *RocksDB) NewBatchWithSize(_ int) corestore.Batch

func (*RocksDB) ReverseIterator

func (db *RocksDB) ReverseIterator(start, end []byte) (corestore.Iterator, error)

func (*RocksDB) Set

func (db *RocksDB) Set(key, value []byte) error

Jump to

Keyboard shortcuts

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