tikv

package module
v0.0.0-...-d674cee Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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")
)
View Source
var ErrBodyMissing = errors.New("response body is missing")
View Source
var ErrInitIterator = errors.New("failed to init iterator")

Functions

func ComposeTS

func ComposeTS(physical, logical int64) uint64

Types

type BatchType

type BatchType int
const (
	BatchTypePut BatchType = iota
	BatchTypeDel
)

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

func NewIterator(startKey, endKey []byte, batchSize int, client *RawKVClient, version uint64) (*Iterator, error)

func (*Iterator) Error

func (i *Iterator) Error() error

func (*Iterator) First

func (it *Iterator) First() bool

func (*Iterator) Key

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

func (*Iterator) Last

func (it *Iterator) Last() bool

func (*Iterator) Next

func (it *Iterator) Next() bool

func (*Iterator) Prev

func (it *Iterator) Prev() bool

func (*Iterator) Release

func (i *Iterator) Release()

func (*Iterator) Seek

func (it *Iterator) Seek(key []byte) bool

func (*Iterator) Value

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

type Key

type Key []byte

Key represents high-level Key type.

func (Key) Clone

func (k Key) Clone() Key

Clone returns a copy of the Key.

func (Key) Cmp

func (k Key) Cmp(another Key) 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 (Key) HasPrefix

func (k Key) HasPrefix(prefix Key) bool

HasPrefix tests whether the Key begins with prefix.

func (Key) Next

func (k Key) Next() Key

Next returns the next key in byte-order.

func (Key) PrefixNext

func (k Key) PrefixNext() Key

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 KeyRange

type KeyRange struct {
	StartKey Key
	EndKey   Key
}

KeyRange represents a range where StartKey <= key < EndKey.

func (*KeyRange) IsPoint

func (r *KeyRange) IsPoint() bool

IsPoint checks if the key range represents a point.

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) Close

func (c *RawKVClient) Close() error

Close closes the client.

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 (c *RawKVClient) NewIterator(startKey, endKey []byte, batchSize int, version uint64) (*Iterator, error)

func (*RawKVClient) Put

func (c *RawKVClient) Put(key, value []byte) error

Put stores a key-value pair to TiKV.

func (*RawKVClient) Scan

func (c *RawKVClient) Scan(startKey []byte, limit int) (keys [][]byte, values [][]byte, err error)

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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