tikv

package module
v0.0.0-...-0ba58a8 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

README

tikv

Benchmark of TiKV

Usage

go get github.com/shafreeck/fperf/bin/fperf-build github.com/fperf/tikv
fperf-build github.com/fperf/tikv

./fperf -h

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call(c *Client, args []string) error

func Delete

func Delete(ctx *Context) error

func Get

func Get(ctx *Context) error

func New

func New(flag *fperf.FlagSet) fperf.Client

func Scan

func Scan(ctx *Context) error

func Set

func Set(ctx *Context) error

Types

type Client

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

func (*Client) Dial

func (c *Client) Dial(addr string) error

func (*Client) Request

func (c *Client) Request() error

type Codec

type Codec interface {
	EncodeBytes(b []byte, data []byte) []byte
	DecodeBytes(b []byte, buf []byte) ([]byte, []byte, error)
}

Codec encode bytes to be sortable

type Command

type Command func(ctx *Context) error

type Context

type Context struct {
	context.Context
	Name   string
	Args   []string
	Out    io.Writer
	Raw    bool
	Limit  int
	Client *Client
}

type Desc

type Desc struct {
	Proc  Command
	Arity int
}

type RawTiKVClient

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

RawTiKVClient is the client of TiKV raw API

func NewRawTiKVClient

func NewRawTiKVClient(addrs string, options ...TiKVOption) (*RawTiKVClient, error)

NewRawTiKVClient creates a TiKV raw client

func (*RawTiKVClient) BatchDelete

func (c *RawTiKVClient) BatchDelete(keys [][]byte) error

BatchDelete deletes key-value pairs from TiKV

func (*RawTiKVClient) BatchGet

func (c *RawTiKVClient) BatchGet(keys [][]byte) ([][]byte, error)

BatchGet queries values with the keys.

func (*RawTiKVClient) BatchPut

func (c *RawTiKVClient) BatchPut(keys, values [][]byte) error

BatchPut stores key-value pairs to TiKV.

func (*RawTiKVClient) Close

func (c *RawTiKVClient) Close() error

Close the client

func (*RawTiKVClient) ClusterID

func (c *RawTiKVClient) ClusterID() uint64

ClusterID returns the TiKV cluster ID.

func (*RawTiKVClient) Delete

func (c *RawTiKVClient) Delete(key []byte) error

Delete a key

func (*RawTiKVClient) Get

func (c *RawTiKVClient) Get(key []byte) ([]byte, error)

Get return the value of the key

func (*RawTiKVClient) Put

func (c *RawTiKVClient) Put(key, val []byte) error

Put a key value pair and return the version of the key

func (*RawTiKVClient) Scan

func (c *RawTiKVClient) Scan(startKey []byte, limit int) ([][]byte, [][]byte, error)

Scan queries continuous kv pairs, starts from startKey, up to limit pairs. | -clusterID : uint64 If you want to exclude the startKey, append a '\0' to the key: `Scan(append(startKey, '\0'), limit)`.

type TiKVCodec

type TiKVCodec struct{}

TiKVCodec implements interface Codec and encodes the key bytes the same as a txn client

func (*TiKVCodec) DecodeBytes

func (c *TiKVCodec) DecodeBytes(b []byte, buf []byte) ([]byte, []byte, error)

DecodeBytes decodes bytes which is encoded by EncodeBytes before, returns the leftover bytes and decoded value if no error. `buf` is used to buffer data to avoid the cost of makeslice in decodeBytes when DecodeBytes is called by Decoder.DecodeOne.

func (*TiKVCodec) EncodeBytes

func (c *TiKVCodec) EncodeBytes(b []byte, data []byte) []byte

EncodeBytes guarantees the encoded value is in ascending order for comparison, encoding with the following rule:

[group1][marker1]...[groupN][markerN]
group is 8 bytes slice which is padding with 0.
marker is `0xFF - padding 0 count`

For example:

[] -> [0, 0, 0, 0, 0, 0, 0, 0, 247]
[1, 2, 3] -> [1, 2, 3, 0, 0, 0, 0, 0, 250]
[1, 2, 3, 0] -> [1, 2, 3, 0, 0, 0, 0, 0, 251]
[1, 2, 3, 4, 5, 6, 7, 8] -> [1, 2, 3, 4, 5, 6, 7, 8, 255, 0, 0, 0, 0, 0, 0, 0, 0, 247]

Refer: https://github.com/facebook/mysql-5.6/wiki/MyRocks-record-format#memcomparable-format

type TiKVOption

type TiKVOption func(c *RawTiKVClient)

TiKVOption supplies options when new a TiKV client

func WithCodec

func WithCodec(codec Codec) TiKVOption

WithCodec set a codec to encode or decode keys

Jump to

Keyboard shortcuts

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