table

package
v3.0.18 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: Apache-2.0 Imports: 20 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.

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

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) 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) TableID

func (k Key) TableID() int64

TableID returns the table ID of the key, if the key is not table key, returns 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

func NewNamespace(id uint64, name string) *Namespace

NewNamespace creates a new namespace

func (*Namespace) AddStoreID

func (ns *Namespace) AddStoreID(storeID uint64)

AddStoreID adds a storeID to this namespace

func (*Namespace) AddTableID

func (ns *Namespace) AddTableID(tableID int64)

AddTableID adds a tableID to this namespace

func (*Namespace) GetID

func (ns *Namespace) GetID() uint64

GetID returns namespace's ID or 0

func (*Namespace) GetName

func (ns *Namespace) GetName() string

GetName returns namespace's Name or default 'global' value

Jump to

Keyboard shortcuts

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