codec

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBytes

func DecodeBytes(b []byte) ([]byte, []byte, error)

DecodeBytes decodes bytes which is encoded by EncodeBytes before, returns the leftover bytes and decoded value if no error.

func DecodeInt

func DecodeInt(b []byte) ([]byte, int64, error)

DecodeInt decodes value encoded by EncodeInt before. It returns the leftover un-decoded slice, decoded value if no error.

func EncodeInt

func EncodeInt(b []byte, v int64) []byte

EncodeInt appends the encoded value to slice b and returns the appended slice. EncodeInt guarantees that the encoded value is in ascending order for comparison.

func GenerateRowKey

func GenerateRowKey(tableID, rowID int64) []byte

GenerateRowKey generates a row key.

func GenerateTableKey

func GenerateTableKey(tableID int64) []byte

GenerateTableKey generates a table split key.

Types

type Key

type Key []byte

Key represents high-level Key type.

func EncodeBytes

func EncodeBytes(data []byte) Key

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

func (Key) IndexID

func (k Key) IndexID() int64

IndexID returns the row ID of the key, if the key is not table key, returns 0.

func (Key) MetaOrTable

func (k Key) MetaOrTable() (bool, int64)

MetaOrTable checks if the key is a meta key or table key. If the key is a meta key, it returns true and 0. If the key is a table key, it returns false and table ID. Otherwise, it returns false and 0.

func (Key) RowID

func (k Key) RowID() int64

RowID returns the row ID of the key, if the key is not table key, returns 0.

func (Key) TableID

func (k Key) TableID() int64

TableID returns the table ID of the key, if the key is not table key, returns 0.

Jump to

Keyboard shortcuts

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