Documentation ¶
Index ¶
- Constants
- func BytesPrefixRange(prefix, start []byte) *util.Range
- type Batch
- type BatchWithID
- type BatchWriter
- type Batcher
- type Compacter
- type DB
- type DBPool
- func (p *DBPool) Close()
- func (p *DBPool) GetBlockInfo() (header *pb.BlockInfo, err error)
- func (p *DBPool) GetDB(id int32) (db DB, err error)
- func (p *DBPool) GetDBID(path string) (id int32, err error)
- func (p *DBPool) GetDBInfo() (info *pb.DBInfoList, err error)
- func (p *DBPool) Marshal(batchs []BatchWithID) (batchItems []*pb.Data, err error)
- func (p *DBPool) Open(dbInfo *pb.DBInfo, cacheSize int) (err error)
- func (p *DBPool) Register(id int32, path string, dbType string, db DB, isMetaDB bool)
- func (p *DBPool) WriteBatchItems(items []*pb.Data) (err error)
- func (p *DBPool) WriteBatchs(batchs []BatchWithID) (err error)
- func (p *DBPool) WriteBlockInfo(header *pb.BlockInfo) (err error)
- type Iteratee
- type Iterator
- type KeyValueReader
- type KeyValueStater
- type KeyValueWriter
- type LBatch
- type LDB
- func (l *LDB) Close() error
- func (l *LDB) Compact(start, limit []byte) error
- func (l *LDB) Delete(key []byte) error
- func (l *LDB) Get(key []byte) ([]byte, error)
- func (l *LDB) Has(key []byte) (bool, error)
- func (l *LDB) NewBatch() Batch
- func (l *LDB) NewBatchWithSize(size int) Batch
- func (l *LDB) NewIterator(prefix []byte, start []byte) Iterator
- func (l *LDB) NewIteratorWithRange(start, limit []byte) (Iterator, error)
- func (l *LDB) NewSnapshot() (Snapshot, error)
- func (l *LDB) Put(key, value []byte) error
- func (l *LDB) Stat(property string) (string, error)
- func (l *LDB) Stats() (map[string]string, error)
- type LIterator
- type LSnapshot
- type Replayer
- type Snapshot
- type Snapshotter
Constants ¶
const ( LastBlockInfo = "rpl_last_bk" DBInfo = "rpl_db_info" )
Variables ¶
This section is empty.
Functions ¶
func BytesPrefixRange ¶
BytesPrefixRange returns key range that satisfy - the given prefix, and - the given seek position
Types ¶
type Batch ¶
type Batch interface { KeyValueWriter BatchWriter // ValueSize retrieves the amount of data queued up for writing. ValueSize() int // Reset resets the batch for reuse. Reset() // Replay replays the batch contents. Replay(w KeyValueWriter) error }
Batch is a write-only put/del op set.
type BatchWithID ¶
type BatchWithID struct { ID int32 B BatchWriter }
type BatchWriter ¶
type Batcher ¶
type Batcher interface { // NewBatch creates a write-only database that buffers changes to its host db // until a final write is called. NewBatch() Batch // NewBatchWithSize creates a write-only database batch with pre-allocated buffer. NewBatchWithSize(size int) Batch }
Batcher wraps the NewBatch method of a backing data store.
type Compacter ¶
type Compacter interface { // Compact flattens the underlying data store for the given key range. In essence, // deleted and overwritten versions are discarded, and the data is rearranged to // reduce the cost of operations needed to access them. // // A nil start is treated as a key before all keys in the data store; a nil limit // is treated as a key after all keys in the data store. If both is nil then it // will compact entire data store. Compact(start []byte, limit []byte) error }
Compacter wraps the Compact method of a backing data store.
type DB ¶
type DB interface { KeyValueReader KeyValueWriter KeyValueStater Batcher Snapshotter Compacter Iteratee io.Closer }
DB is the interface that wraps the basic operations of a key-value data store.
type DBPool ¶
DBPool is a pool of Chain's All DBs.
func (*DBPool) GetBlockInfo ¶
GetBlockInfo returns the last BlockInfo from metaDB.
func (*DBPool) GetDBInfo ¶
func (p *DBPool) GetDBInfo() (info *pb.DBInfoList, err error)
GetDBInfo returns all opened DBs.
func (*DBPool) Marshal ¶
func (p *DBPool) Marshal(batchs []BatchWithID) (batchItems []*pb.Data, err error)
Marshal marshals write batchs to bytes.
func (*DBPool) Register ¶
RegisterMetaDB registers a DB. if isMetaDB is true, this DB will be used to store msgHead.
func (*DBPool) WriteBatchItems ¶
WriteBatchItems writes batchItems to DBs.
func (*DBPool) WriteBatchs ¶
func (p *DBPool) WriteBatchs(batchs []BatchWithID) (err error)
WriteBatchs writes batchs to DBs.
type Iteratee ¶
type Iteratee interface { // NewIterator creates a binary-alphabetical iterator over a subset // of database content with a particular key prefix, starting at a particular // initial key (or after, if it does not exist). // // Note: This method assumes that the prefix is NOT part of the start, so there's // no need for the caller to prepend the prefix to the start NewIterator(prefix []byte, start []byte) Iterator // NewIteratorWithRange creates an iterator over a domain of keys in ascending order. The caller must call NewIteratorWithRange(start []byte, limit []byte) (Iterator, error) }
Iteratee wraps the NewIterator methods of a backing data store.
type Iterator ¶
type Iterator interface { Next() bool // Error returns any accumulated error. Exhausting all the key/value pairs // is not considered to be an error. Error() error // Key returns the key of the current key/value pair, or nil if done. The caller // should not modify the contents of the returned slice, and its contents may // change on the next call to Next. Key() []byte // Value returns the value of the current key/value pair, or nil if done. The // caller should not modify the contents of the returned slice, and its contents // may change on the next call to Next. Value() []byte // Release releases associated resources. Release should always succeed and can // be called multiple times without causing error. Release() }
type KeyValueReader ¶
type KeyValueReader interface { // Has retrieves if a key is present in the key-value data store. Has(key []byte) (bool, error) // Get retrieves the given key if it's present in the key-value data store. Get(key []byte) ([]byte, error) }
KeyValueReader wraps the Has and Get method of a backing data store.
type KeyValueStater ¶
type KeyValueStater interface { // Stat returns a particular internal stat of the database. Stat(property string) (string, error) // Stats returns a map of property values for all keys and the size of the cache. Stats() (map[string]string, error) }
KeyValueStater wraps the Stat method of a backing data store.
type KeyValueWriter ¶
type LDB ¶
func (*LDB) NewBatchWithSize ¶
func (*LDB) NewIteratorWithRange ¶
func (*LDB) NewSnapshot ¶
type Replayer ¶
type Replayer struct { Writer KeyValueWriter Failure error }
type Snapshot ¶
type Snapshot interface { KeyValueReader // Release releases associated resources. Release should always succeed and can // be called multiple times without causing error. Release() }
type Snapshotter ¶
type Snapshotter interface { // NewSnapshot creates a database snapshot based on the current state. // The created snapshot will not be affected by all following mutations // happened on the database. // Note don't forget to release the snapshot once it's used up, otherwise // the stale data will never be cleaned up by the underlying compactor. NewSnapshot() (Snapshot, error) }
Snapshotter wraps the Snapshot method of a backing data store.