Documentation ¶
Index ¶
- Constants
- Variables
- func ComposeTS(physical, logical int64) uint64
- type BatchType
- type EncodedKey
- type Iterator
- func (i *Iterator) Error() error
- func (it *Iterator) First() bool
- func (it *Iterator) Key() []byte
- func (it *Iterator) Last() bool
- func (it *Iterator) Next() bool
- func (it *Iterator) Prev() bool
- func (i *Iterator) Release()
- func (it *Iterator) Seek(key []byte) bool
- func (it *Iterator) Value() []byte
- type Key
- type KeyRange
- type RawKVClient
- func (c *RawKVClient) BatchDelete(keys [][]byte) error
- func (c *RawKVClient) BatchGet(keys [][]byte) ([][]byte, error)
- func (c *RawKVClient) BatchPut(keys, values [][]byte) error
- func (c *RawKVClient) Close() error
- func (c *RawKVClient) ClusterID() uint64
- func (c *RawKVClient) Delete(key []byte) error
- func (c *RawKVClient) DeleteRange(startKey []byte, endKey []byte) error
- func (c *RawKVClient) Get(key []byte) ([]byte, error)
- func (c *RawKVClient) GetKeyRegion(bo *retry.Backoffer, key []byte) (*locate.KeyLocation, error)
- func (c *RawKVClient) NewIterator(startKey, endKey []byte, batchSize int, version uint64) (*Iterator, error)
- func (c *RawKVClient) Put(key, value []byte) error
- func (c *RawKVClient) Scan(startKey []byte, limit int) (keys [][]byte, values [][]byte, err error)
- func (c *RawKVClient) WriteRegionBatch(bo *retry.Backoffer, b *RegionBatch) (err error)
- type RegionBatch
Constants ¶
const ( ReadTimeoutMedium = 60 * time.Second // For requests that may need scan region. ReadTimeoutLong = 150 * time.Second // For requests that may need scan region multiple times. GCTimeout = 5 * time.Minute UnsafeDestroyRangeTimeout = 5 * time.Minute )
Timeout durations.
Variables ¶
var ( // MaxRawKVScanLimit is the maximum scan limit for rawkv Scan. MaxRawKVScanLimit = 10240 // ErrMaxScanLimitExceeded is returned when the limit for rawkv Scan is to large. ErrMaxScanLimitExceeded = errors.New("limit should be less than MaxRawKVScanLimit") )
var ErrBodyMissing = errors.New("response body is missing")
var ErrInitIterator = errors.New("failed to init iterator")
Functions ¶
Types ¶
type EncodedKey ¶
type EncodedKey []byte
EncodedKey represents encoded key in low-level storage engine.
func (EncodedKey) Cmp ¶
func (k EncodedKey) Cmp(another EncodedKey) int
Cmp returns the comparison result of two key. The result will be 0 if a==b, -1 if a < b, and +1 if a > b.
func (EncodedKey) Next ¶
func (k EncodedKey) Next() EncodedKey
Next returns the next key in byte-order.
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
func NewIterator ¶
type Key ¶
type Key []byte
Key represents high-level Key type.
func (Key) Cmp ¶
Cmp returns the comparison result of two key. The result will be 0 if a==b, -1 if a < b, and +1 if a > b.
func (Key) PrefixNext ¶
PrefixNext returns the next prefix key.
Assume there are keys like:
rowkey1 rowkey1_column1 rowkey1_column2 rowKey2
If we seek 'rowkey1' Next, we will get 'rowkey1_column1'. If we seek 'rowkey1' PrefixNext, we will get 'rowkey2'.
type RawKVClient ¶
type RawKVClient struct {
// contains filtered or unexported fields
}
RawKVClient is a client of TiKV server which is used as a key-value storage, only GET/PUT/DELETE commands are supported.
func NewRawKVClient ¶
func NewRawKVClient(pdAddrs []string, security config.Security) (*RawKVClient, error)
NewRawKVClient creates a client with PD cluster addrs.
func (*RawKVClient) BatchDelete ¶
func (c *RawKVClient) BatchDelete(keys [][]byte) error
BatchDelete deletes key-value pairs from TiKV
func (*RawKVClient) BatchGet ¶
func (c *RawKVClient) BatchGet(keys [][]byte) ([][]byte, error)
BatchGet queries values with the keys.
func (*RawKVClient) BatchPut ¶
func (c *RawKVClient) BatchPut(keys, values [][]byte) error
BatchPut stores key-value pairs to TiKV.
func (*RawKVClient) ClusterID ¶
func (c *RawKVClient) ClusterID() uint64
ClusterID returns the TiKV cluster ID.
func (*RawKVClient) Delete ¶
func (c *RawKVClient) Delete(key []byte) error
Delete deletes a key-value pair from TiKV.
func (*RawKVClient) DeleteRange ¶
func (c *RawKVClient) DeleteRange(startKey []byte, endKey []byte) error
DeleteRange deletes all key-value pairs in a range from TiKV
func (*RawKVClient) Get ¶
func (c *RawKVClient) Get(key []byte) ([]byte, error)
Get queries value with the key. When the key does not exist, it returns `nil, nil`.
func (*RawKVClient) GetKeyRegion ¶
func (c *RawKVClient) GetKeyRegion(bo *retry.Backoffer, key []byte) (*locate.KeyLocation, error)
func (*RawKVClient) NewIterator ¶
func (*RawKVClient) Put ¶
func (c *RawKVClient) Put(key, value []byte) error
Put stores a key-value pair to TiKV.
func (*RawKVClient) Scan ¶
Scan queries continuous kv pairs, starts from startKey, up to limit pairs. If you want to exclude the startKey, append a '\0' to the key: `Scan(append(startKey, '\0'), limit)`.
func (*RawKVClient) WriteRegionBatch ¶
func (c *RawKVClient) WriteRegionBatch(bo *retry.Backoffer, b *RegionBatch) (err error)
type RegionBatch ¶
type RegionBatch struct {
// contains filtered or unexported fields
}
func NewRegionBatch ¶
func NewRegionBatch(regionID locate.RegionVerID, t BatchType) *RegionBatch
func (*RegionBatch) Delete ¶
func (batch *RegionBatch) Delete(key []byte) error
func (*RegionBatch) Full ¶
func (batch *RegionBatch) Full() bool
func (*RegionBatch) Put ¶
func (batch *RegionBatch) Put(key, value []byte) error