Documentation ¶
Index ¶
- func DecodeBytes(b []byte) ([]byte, []byte, error)
- func DecodeInt(b []byte) ([]byte, int64, error)
- func EncodeInt(b []byte, v int64) []byte
- func GenerateRowKey(tableID, rowID int64) []byte
- func GenerateTableKey(tableID int64) []byte
- func NewTableNamespaceClassifier(kv *core.KV, idAlloc core.IDAllocator) (namespace.Classifier, error)
- type Key
- type Namespace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeBytes ¶
DecodeBytes decodes bytes which is encoded by EncodeBytes before, returns the leftover bytes and decoded value if no error.
func DecodeInt ¶
DecodeInt decodes value encoded by EncodeInt before. It returns the leftover un-decoded slice, decoded value if no error.
func EncodeInt ¶
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 ¶
GenerateRowKey generates a row key.
func GenerateTableKey ¶
GenerateTableKey generates a table split key.
func NewTableNamespaceClassifier ¶
func NewTableNamespaceClassifier(kv *core.KV, idAlloc core.IDAllocator) (namespace.Classifier, error)
NewTableNamespaceClassifier creates a new namespace classifier that classifies stores and regions by table range.
Types ¶
type Key ¶
type Key []byte
Key represents high-level Key type.
func EncodeBytes ¶
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) MetaOrTable ¶
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.
type Namespace ¶
type Namespace struct { ID uint64 `json:"ID"` Name string `json:"Name"` TableIDs map[int64]bool `json:"table_ids,omitempty"` StoreIDs map[uint64]bool `json:"store_ids,omitempty"` Meta bool `json:"meta,omitempty"` }
Namespace defines two things: 1. relation between a Name and several tables 2. relation between a Name and several stores It is used to bind tables with stores
func NewNamespace ¶
NewNamespace creates a new namespace
func (*Namespace) AddStoreID ¶
AddStoreID adds a storeID to this namespace
func (*Namespace) AddTableID ¶
AddTableID adds a tableID to this namespace