tidb: github.com/pingcap/tidb/structure Index | Files

package structure

import "github.com/pingcap/tidb/structure"

Index

Package Files

hash.go list.go string.go structure.go type.go

type HashPair Uses

type HashPair struct {
    Field []byte
    Value []byte
}

HashPair is the pair for (field, value) in a hash.

type TxStructure Uses

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

TxStructure supports some simple data structures like string, hash, list, etc... and you can use these in a transaction.

func NewStructure Uses

func NewStructure(reader kv.Retriever, readWriter kv.RetrieverMutator, prefix []byte) *TxStructure

NewStructure creates a TxStructure with Retriever, RetrieverMutator and key prefix.

func (*TxStructure) Clear Uses

func (t *TxStructure) Clear(key []byte) error

Clear removes the string value of the key.

func (*TxStructure) EncodeHashAutoIDKeyValue Uses

func (t *TxStructure) EncodeHashAutoIDKeyValue(key []byte, field []byte, val int64) (k, v []byte)

EncodeHashAutoIDKeyValue returns the hash key-value generated by the key and the field

func (*TxStructure) EncodeHashDataKey Uses

func (t *TxStructure) EncodeHashDataKey(key []byte, field []byte) kv.Key

EncodeHashDataKey exports for tests.

func (*TxStructure) Get Uses

func (t *TxStructure) Get(key []byte) ([]byte, error)

Get gets the string value of a key.

func (*TxStructure) GetInt64 Uses

func (t *TxStructure) GetInt64(key []byte) (int64, error)

GetInt64 gets the int64 value of a key.

func (*TxStructure) HClear Uses

func (t *TxStructure) HClear(key []byte) error

HClear removes the hash value of the key.

func (*TxStructure) HDel Uses

func (t *TxStructure) HDel(key []byte, fields ...[]byte) error

HDel deletes one or more hash fields.

func (*TxStructure) HGet Uses

func (t *TxStructure) HGet(key []byte, field []byte) ([]byte, error)

HGet gets the value of a hash field.

func (*TxStructure) HGetAll Uses

func (t *TxStructure) HGetAll(key []byte) ([]HashPair, error)

HGetAll gets all the fields and values in a hash.

func (*TxStructure) HGetInt64 Uses

func (t *TxStructure) HGetInt64(key []byte, field []byte) (int64, error)

HGetInt64 gets int64 value of a hash field.

func (*TxStructure) HGetLastN Uses

func (t *TxStructure) HGetLastN(key []byte, num int) ([]HashPair, error)

HGetLastN gets latest N fields and values in hash.

func (*TxStructure) HInc Uses

func (t *TxStructure) HInc(key []byte, field []byte, step int64) (int64, error)

HInc increments the integer value of a hash field, by step, returns the value after the increment.

func (*TxStructure) HKeys Uses

func (t *TxStructure) HKeys(key []byte) ([][]byte, error)

HKeys gets all the fields in a hash.

func (*TxStructure) HLen Uses

func (t *TxStructure) HLen(key []byte) (int64, error)

HLen gets the number of fields in a hash.

func (*TxStructure) HSet Uses

func (t *TxStructure) HSet(key []byte, field []byte, value []byte) error

HSet sets the string value of a hash field.

func (*TxStructure) Inc Uses

func (t *TxStructure) Inc(key []byte, step int64) (int64, error)

Inc increments the integer value of a key by step, returns the value after the increment.

func (*TxStructure) LClear Uses

func (t *TxStructure) LClear(key []byte) error

LClear removes the list of the key.

func (*TxStructure) LGetAll Uses

func (t *TxStructure) LGetAll(key []byte) ([][]byte, error)

LGetAll gets all elements of this list in order from right to left.

func (*TxStructure) LIndex Uses

func (t *TxStructure) LIndex(key []byte, index int64) ([]byte, error)

LIndex gets an element from a list by its index.

func (*TxStructure) LLen Uses

func (t *TxStructure) LLen(key []byte) (int64, error)

LLen gets the length of a list.

func (*TxStructure) LPop Uses

func (t *TxStructure) LPop(key []byte) ([]byte, error)

LPop removes and gets the first element in a list.

func (*TxStructure) LPush Uses

func (t *TxStructure) LPush(key []byte, values ...[]byte) error

LPush prepends one or multiple values to a list.

func (*TxStructure) LSet Uses

func (t *TxStructure) LSet(key []byte, index int64, value []byte) error

LSet updates an element in the list by its index.

func (*TxStructure) RPop Uses

func (t *TxStructure) RPop(key []byte) ([]byte, error)

RPop removes and gets the last element in a list.

func (*TxStructure) RPush Uses

func (t *TxStructure) RPush(key []byte, values ...[]byte) error

RPush appends one or multiple values to a list.

func (*TxStructure) Set Uses

func (t *TxStructure) Set(key []byte, value []byte) error

Set sets the string value of the key.

type TypeFlag Uses

type TypeFlag byte

TypeFlag is for data structure meta/data flag.

const (
    // StringMeta is the flag for string meta.
    StringMeta TypeFlag = 'S'
    // StringData is the flag for string data.
    StringData TypeFlag = 's'
    // HashMeta is the flag for hash meta.
    HashMeta TypeFlag = 'H'
    // HashData is the flag for hash data.
    HashData TypeFlag = 'h'
    // ListMeta is the flag for list meta.
    ListMeta TypeFlag = 'L'
    // ListData is the flag for list data.
    ListData TypeFlag = 'l'
)

Package structure imports 8 packages (graph) and is imported by 27 packages. Updated 2019-08-16. Refresh now. Tools for package owners.