tikvdbprovider

package module
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	//StoreBlockDBDir blockdb folder name
	StoreBlockDBDir = "store_block"
	//StoreStateDBDir statedb folder name
	StoreStateDBDir = "store_state"
	//StoreHistoryDBDir historydb folder name
	StoreHistoryDBDir = "store_history"
	//StoreResultDBDir resultdb folder name
	StoreResultDBDir = "store_result"
	//PrefixSeparator prefix and raw key separator
	PrefixSeparator = "#"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator

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

Iterator will walk through the key between startKey and endKey and return paired value. since protocol.ParametersValueMaxLength == 1024 * 1024 byte == 1MB, so we can just fetch a batch of values in memory without worrying about too much memory occupied, default batchSize is 10 (can modify in need), and we will keep this batch of in use kvs in memory, and fresh it if iter entered next or previous batch

func NewIterator

func NewIterator(db *rawkv.Client, start []byte, end []byte, limit int,
	batchSize int, keyPrefix []byte, encryptor crypto.SymmetricKey) (*Iterator, error)

NewIterator construct an iterator @param *rawkv.Client dbclient @param []byte start @param []byte end @param int limit @param int batchSize @param []byte keyPrefix @return *Iterator @return error

func (*Iterator) Error

func (iter *Iterator) Error() error

Error return nil @return error (default nil)

func (*Iterator) First

func (iter *Iterator) First() bool

First reset the iterator @return bool

func (*Iterator) Key

func (iter *Iterator) Key() []byte

Key return current key @return []byte key

func (*Iterator) Next

func (iter *Iterator) Next() bool

Next check iterator whether it has next element @return bool

func (*Iterator) Release

func (iter *Iterator) Release()

Release close the db ,release the iterator

func (*Iterator) Value

func (iter *Iterator) Value() []byte

Value return current value @return []byte value located at currentIndex

type NewTikvDBOptions

type NewTikvDBOptions struct {
	Config    *TiKVDbConfig
	Logger    protocol.Logger
	Encryptor crypto.SymmetricKey
	ChainId   string
	DbName    string
}

NewTikvDBOptions used to build TiKVDBHandle

type TiKVDBHandle

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

TiKVDBHandle encapsulated handle to tikvdb

func NewTiKVDBHandle

func NewTiKVDBHandle(input *NewTikvDBOptions) *TiKVDBHandle

NewTiKVDBHandle use NewTikvDBOptions to build TiKVDBHandle @param NewTikvDBOptions config @return *TiKVDBHandle dbhandler

func (*TiKVDBHandle) Close

func (h *TiKVDBHandle) Close() error

Close closes the tikvdb

func (*TiKVDBHandle) CompactRange

func (h *TiKVDBHandle) CompactRange(_, _ []byte) error

CompactRange compacts the underlying DB for the given key range. @param []byte @param []byte @return error

func (*TiKVDBHandle) Delete

func (h *TiKVDBHandle) Delete(key []byte) error

Delete deletes the given key @param []byte key @return error

func (*TiKVDBHandle) Get

func (h *TiKVDBHandle) Get(key []byte) ([]byte, error)

Get returns the value for the given key, or returns nil if none exists @param []byte key @return []byte value @return error

func (*TiKVDBHandle) GetDbType

func (h *TiKVDBHandle) GetDbType() string

GetDbType returns db type @ return string

func (*TiKVDBHandle) GetKeys

func (h *TiKVDBHandle) GetKeys(keys [][]byte) ([][]byte, error)

GetKeys returns the value for the given key

func (*TiKVDBHandle) GetWriteBatchSize

func (h *TiKVDBHandle) GetWriteBatchSize() uint64

GetWriteBatchSize return writeBatchSize @return uint64

func (*TiKVDBHandle) Has

func (h *TiKVDBHandle) Has(key []byte) (bool, error)

Has return true if the given key exist, or return false if none exists @param []byte key @return bool ,whether key exists @return error

func (*TiKVDBHandle) NewIteratorWithPrefix

func (h *TiKVDBHandle) NewIteratorWithPrefix(prefix []byte) (protocol.Iterator, error)

NewIteratorWithPrefix returns an iterator that contains all the key-values with given prefix @param []byte prefix @return protocol.Iterator @return error

func (*TiKVDBHandle) NewIteratorWithRange

func (h *TiKVDBHandle) NewIteratorWithRange(startKey []byte, limitKey []byte) (protocol.Iterator, error)

NewIteratorWithRange returns an iterator that contains all the key-values between given key ranges start is included in the results and limit is excluded. @param []byte startKey @param []byte limitKey @return protocol.Iterator @return error

func (*TiKVDBHandle) Put

func (h *TiKVDBHandle) Put(key []byte, value []byte) error

Put saves the key-values @param []byte key @param []byte value @return error

func (*TiKVDBHandle) WriteBatch

func (h *TiKVDBHandle) WriteBatch(batch protocol.StoreBatcher, _ bool) error

WriteBatch writes a batch in an atomic operation @param protocol.StoreBatcher @param bool @return error

type TiKVDbConfig

type TiKVDbConfig struct {
	Endpoints            string `mapstructure:"endpoints"`
	MaxBatchCount        uint   `mapstructure:"max_batch_count"`
	GrpcConnectionCount  uint   `mapstructure:"grpc_connection_count"`
	GrpcKeepAliveTime    uint   `mapstructure:"grpc_keep_alive_time"`
	GrpcKeepAliveTimeout uint   `mapstructure:"grpc_keep_alive_timeout"`
	WriteBatchSize       uint64 `mapstructure:"write_batch_size"`
	MaxScanLimit         uint64 `mapstructure:"max_scan_limit"`
	ScanBatchSize        uint64 `mapstructure:"scan_batch_size"`
	DbPrefix             string `mapstructure:"db_prefix"`
}

TiKVDbConfig encapsulated connecton configuration to tikv

Jump to

Keyboard shortcuts

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