Documentation
¶
Index ¶
- Constants
- type Iterator
- type NewTikvDBOptions
- type TiKVDBHandle
- func (h *TiKVDBHandle) Close() error
- func (h *TiKVDBHandle) CompactRange(_, _ []byte) error
- func (h *TiKVDBHandle) Delete(key []byte) error
- func (h *TiKVDBHandle) Get(key []byte) ([]byte, error)
- func (h *TiKVDBHandle) GetDbType() string
- func (h *TiKVDBHandle) GetWriteBatchSize() uint64
- func (h *TiKVDBHandle) Has(key []byte) (bool, error)
- func (h *TiKVDBHandle) NewIteratorWithPrefix(prefix []byte) (protocol.Iterator, error)
- func (h *TiKVDBHandle) NewIteratorWithRange(startKey []byte, limitKey []byte) (protocol.Iterator, error)
- func (h *TiKVDBHandle) Put(key []byte, value []byte) error
- func (h *TiKVDBHandle) WriteBatch(batch protocol.StoreBatcher, _ bool) error
- type TiKVDbConfig
Constants ¶
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 ¶
type NewTikvDBOptions ¶
type NewTikvDBOptions struct { Config *TiKVDbConfig Logger protocol.Logger Encryptor crypto.SymmetricKey ChainId string DbName string }
type TiKVDBHandle ¶
type TiKVDBHandle struct {
// contains filtered or unexported fields
}
TiKVDBHandle encapsulated handle to tikvdb
func NewTiKVDBHandle ¶
func NewTiKVDBHandle(input *NewTikvDBOptions) *TiKVDBHandle
func (*TiKVDBHandle) CompactRange ¶
func (h *TiKVDBHandle) CompactRange(_, _ []byte) error
CompactRange compacts the underlying DB for the given key range.
func (*TiKVDBHandle) Delete ¶
func (h *TiKVDBHandle) Delete(key []byte) error
Delete deletes the given key
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
func (*TiKVDBHandle) GetDbType ¶
func (h *TiKVDBHandle) GetDbType() string
GetDbType returns db type
func (*TiKVDBHandle) GetWriteBatchSize ¶
func (h *TiKVDBHandle) GetWriteBatchSize() 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
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
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.
func (*TiKVDBHandle) Put ¶
func (h *TiKVDBHandle) Put(key []byte, value []byte) error
Put saves the key-values
func (*TiKVDBHandle) WriteBatch ¶
func (h *TiKVDBHandle) WriteBatch(batch protocol.StoreBatcher, _ bool) error
WriteBatch writes a batch in an atomic operation
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"` }