table

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2017 License: Apache-2.0 Imports: 18 Imported by: 180

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultIDDecoder defaultIDDecoder

DefaultIDDecoder is the default decoder. unit test will use other mocked decoder.

Functions

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 IsPureTableID

func IsPureTableID(b []byte) bool

IsPureTableID return true iff b is consist of tablePrefix and 8-byte tableID

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 IDDecoder

type IDDecoder interface {
	DecodeTableID(key Key) int64
}

IDDecoder defines method to extract tableID from key

type Key

type Key []byte

Key represents high-level Key type.

func (Key) HasPrefix

func (k Key) HasPrefix(prefix Key) bool

HasPrefix tests whether the Key begins with prefix.

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"`
}

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