Documentation
¶
Index ¶
Constants ¶
View Source
const ( // ModeRaw represent a raw operation in TiKV. ModeRaw = iota // ModeTxn represent a transaction operation in TiKV. ModeTxn )
Variables ¶
View Source
var ( // DefaultKeyspaceID is the keyspaceID of the default keyspace. DefaultKeyspaceID uint32 = 0 // DefaultKeyspaceName is the name of the default keyspace. DefaultKeyspaceName = "DEFAULT" )
Functions ¶
func BuildKeyspaceName ¶
BuildKeyspaceName builds a keyspace name
func IsDecodeError ¶
IsDecodeError is used to determine if error is decode error.
Types ¶
type Codec ¶
type Codec interface {
// GetAPIVersion returns the api version of the codec.
GetAPIVersion() kvrpcpb.APIVersion
// GetKeyspace return the keyspace id of the codec in bytes.
GetKeyspace() []byte
// GetKeyspaceID return the keyspace id of the codec.
GetKeyspaceID() KeyspaceID
// EncodeRequest encodes with the given Codec.
// NOTE: req is reused on retry. MUST encode on cloned request, other than overwrite the original.
EncodeRequest(req *tikvrpc.Request) (*tikvrpc.Request, error)
// DecodeResponse decode the resp with the given codec.
DecodeResponse(req *tikvrpc.Request, resp *tikvrpc.Response) (*tikvrpc.Response, error)
// EncodeRegionKey encode region's key.
EncodeRegionKey(key []byte) []byte
// DecodeRegionKey decode region's key
DecodeRegionKey(encodedKey []byte) ([]byte, error)
// EncodeRegionRange encode region's start and end.
EncodeRegionRange(start, end []byte) ([]byte, []byte)
// DecodeRegionRange decode region's start and end.
DecodeRegionRange(encodedStart, encodedEnd []byte) ([]byte, []byte, error)
// EncodeRange encode a key range.
EncodeRange(start, end []byte) ([]byte, []byte)
// DecodeRange decode a key range.
DecodeRange(encodedStart, encodedEnd []byte) ([]byte, []byte, error)
// EncodeKey encode a key.
EncodeKey(key []byte) []byte
// DecodeKey decode a key.
DecodeKey(encoded []byte) ([]byte, error)
}
Codec is responsible for encode/decode requests.
func NewCodecV1 ¶
NewCodecV1 returns a codec that can be used to encode/decode keys and requests to and from APIv1 format.
type KeyspaceID ¶
type KeyspaceID uint32
KeyspaceID denotes the target keyspace of the request.
const ( // NulSpaceID is a special keyspace id that represents no keyspace exist. NulSpaceID KeyspaceID = 0xffffffff )
func ParseKeyspaceID ¶
func ParseKeyspaceID(b []byte) (KeyspaceID, error)
ParseKeyspaceID retrieves the keyspaceID from the given keyspace-encoded key. It returns error if the given key is not in proper api-v2 format.
Click to show internal directories.
Click to hide internal directories.