Documentation ¶
Overview ¶
Copyright 2016 PingCAP, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func EditProperties(properties string) ([]*metapb.Column, error)
- func ParseProperties(properties string) ([]*metapb.Column, []*metapb.Column, error)
- func ToTableProperty(cols []*metapb.Column) (string, error)
- type ByPrimaryKey
- type Cluster
- func (c *Cluster) AddColumn(ctx context.Context, req *mspb.AddColumnRequest) (*mspb.AddColumnResponse, error)
- func (c *Cluster) AskSplit(ctx context.Context, req *mspb.AskSplitRequest) (*mspb.AskSplitResponse, error)
- func (c *Cluster) CreateDatabase(ctx context.Context, req *mspb.CreateDatabaseRequest) (*mspb.CreateDatabaseResponse, error)
- func (c *Cluster) CreateTable(ctx context.Context, req *mspb.CreateTableRequest) (*mspb.CreateTableResponse, error)
- func (c *Cluster) GetColumnById(ctx context.Context, req *mspb.GetColumnByIdRequest) (*mspb.GetColumnByIdResponse, error)
- func (c *Cluster) GetColumnByName(ctx context.Context, req *mspb.GetColumnByNameRequest) (*mspb.GetColumnByNameResponse, error)
- func (c *Cluster) GetColumns(ctx context.Context, req *mspb.GetColumnsRequest) (*mspb.GetColumnsResponse, error)
- func (c *Cluster) GetDB(ctx context.Context, req *mspb.GetDBRequest) (*mspb.GetDBResponse, error)
- func (c *Cluster) GetMSLeader(ctx context.Context, req *mspb.GetMSLeaderRequest) (*mspb.GetMSLeaderResponse, error)
- func (c *Cluster) GetNode(ctx context.Context, req *mspb.GetNodeRequest) (*mspb.GetNodeResponse, error)
- func (c *Cluster) GetNodeId(ctx context.Context, req *mspb.GetNodeIdRequest) (*mspb.GetNodeIdResponse, error)
- func (c *Cluster) GetRoute(ctx context.Context, req *mspb.GetRouteRequest) (*mspb.GetRouteResponse, error)
- func (c *Cluster) GetTable(ctx context.Context, req *mspb.GetTableRequest) (*mspb.GetTableResponse, error)
- func (c *Cluster) GetTableById(ctx context.Context, req *mspb.GetTableByIdRequest) (*mspb.GetTableByIdResponse, error)
- func (c *Cluster) NodeHeartbeat(ctx context.Context, req *mspb.NodeHeartbeatRequest) (*mspb.NodeHeartbeatResponse, error)
- func (c *Cluster) NodeLogin(ctx context.Context, req *mspb.NodeLoginRequest) (*mspb.NodeLoginResponse, error)
- func (c *Cluster) RangeHeartbeat(ctx context.Context, req *mspb.RangeHeartbeatRequest) (*mspb.RangeHeartbeatResponse, error)
- func (c *Cluster) ReportSplit(ctx context.Context, req *mspb.ReportSplitRequest) (*mspb.ReportSplitResponse, error)
- func (c *Cluster) SetDb(db *metapb.DataBase)
- func (c *Cluster) SetNode(node *metapb.Node)
- func (c *Cluster) SetRange(r *metapb.Range)
- func (c *Cluster) SetTable(t *metapb.Table)
- func (c *Cluster) Start()
- func (c *Cluster) Stop()
- func (c *Cluster) TruncateTable(context.Context, *mspb.TruncateTableRequest) (*mspb.TruncateTableResponse, error)
- type CreateTable
- type CreateTableCache
- type Database
- func (db *Database) AddTable(t *Table)
- func (db *Database) DeleteTableById(id uint64) error
- func (db *Database) DeleteTableByName(name string) error
- func (db *Database) FindTable(name string) (*Table, bool)
- func (db *Database) FindTableById(id uint64) (*Table, bool)
- func (db *Database) GetAllTable() []*Table
- func (db *Database) Lock()
- func (db *Database) Name() string
- func (db *Database) UnLock()
- type DbCache
- type GlobalTableCache
- type HttpReply
- type Range
- type RangeCache
- func (rc *RangeCache) Add(r *Range)
- func (rc *RangeCache) Delete(id uint64)
- func (rc *RangeCache) FindRangeByID(id uint64) (*Range, bool)
- func (rc *RangeCache) GetAllRange() []*Range
- func (rc *RangeCache) GetRandomRange() *Range
- func (rc *RangeCache) MultipleSearchRanges(key []byte, num int) ([]*Range, bool)
- func (rc *RangeCache) SearchRange(key []byte) (*Range, bool)
- func (rc *RangeCache) Size() int
- type Table
- func (t *Table) AddRange(r *Range)
- func (t *Table) DeleteRange(id uint64)
- func (t *Table) FindRange(id uint64) (*Range, bool)
- func (t *Table) GenColId() uint64
- func (t *Table) GetAllRanges() []*Range
- func (t *Table) GetColumnById(id uint64) (*metapb.Column, bool)
- func (t *Table) GetColumnByName(name string) (*metapb.Column, bool)
- func (t *Table) GetColumns() []*metapb.Column
- func (t *Table) GetPkColumns() []*metapb.Column
- func (t *Table) GetRangeNumber() int
- func (t *Table) MergeColumn(source []*metapb.Column, cluster *Cluster) error
- func (t *Table) MultipleSearchRanges(key []byte, num int) ([]*Range, bool)
- func (t *Table) Name() string
- func (t *Table) SearchRange(key []byte) (*Range, bool)
- func (t *Table) UpdateSchema(columns []*metapb.Column) ([]*metapb.Column, error)
- type TableCache
- func (tc *TableCache) Add(t *Table)
- func (tc *TableCache) DeleteById(id uint64)
- func (tc *TableCache) DeleteByName(name string)
- func (tc *TableCache) FindTableById(id uint64) (*Table, bool)
- func (tc *TableCache) FindTableByName(name string) (*Table, bool)
- func (tc *TableCache) GetAllTable() []*Table
- func (tc *TableCache) Size() int
- type TableProperty
Constants ¶
View Source
const ( HTTP_DB_NAME = "dbName" HTTP_DB_ID = "dbId" HTTP_TABLE_NAME = "tableName" HTTP_TABLE_ID = "tableId" HTTP_CLUSTER_ID = "clusterId" HTTP_RANGE_ID = "rangeId" HTTP_NODE_ID = "nodeId" HTTP_PEER_ID = "peerId" HTTP_NAME = "name" HTTP_PROPERTIES = "properties" HTTP_PKDUPCHECK = "pkDupCheck" )
Variables ¶
View Source
var ( ErrNotExistDatabase = errors.New("database not exist") ErrNotExistTable = errors.New("table not exist") ErrNotExistRange = errors.New("range not exist") ErrInvalidColumn = errors.New("invalid column") ErrColumnNameTooLong = errors.New("column name is too long") ErrDupColumnName = errors.New("duplicate column name") ErrPkMustNotNull = errors.New("primary key must be not nullable") ErrMissingPk = errors.New("missing primary key") ErrPkMustNotSetDefaultValue = errors.New("primary key should not set defaultvalue") ErrNotFound = errors.New("entity not found") )
View Source
var (
MAX_COLUMN_NAME_LENGTH = 128
)
View Source
var PREFIX_AUTO_FAILOVER_TABLE string = fmt.Sprintf("$auto_failover_table_%d")
View Source
var PREFIX_AUTO_TRANSFER_TABLE string = fmt.Sprintf("$auto_transfer_table_%d")
Functions ¶
func ParseProperties ¶
Types ¶
type ByPrimaryKey ¶
func (ByPrimaryKey) Len ¶
func (s ByPrimaryKey) Len() int
func (ByPrimaryKey) Less ¶
func (s ByPrimaryKey) Less(i, j int) bool
func (ByPrimaryKey) Swap ¶
func (s ByPrimaryKey) Swap(i, j int)
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
func NewCluster ¶
func (*Cluster) AddColumn ¶
func (c *Cluster) AddColumn(ctx context.Context, req *mspb.AddColumnRequest) (*mspb.AddColumnResponse, error)
func (*Cluster) AskSplit ¶
func (c *Cluster) AskSplit(ctx context.Context, req *mspb.AskSplitRequest) (*mspb.AskSplitResponse, error)
func (*Cluster) CreateDatabase ¶
func (c *Cluster) CreateDatabase(ctx context.Context, req *mspb.CreateDatabaseRequest) (*mspb.CreateDatabaseResponse, error)
func (*Cluster) CreateTable ¶
func (c *Cluster) CreateTable(ctx context.Context, req *mspb.CreateTableRequest) (*mspb.CreateTableResponse, error)
func (*Cluster) GetColumnById ¶
func (c *Cluster) GetColumnById(ctx context.Context, req *mspb.GetColumnByIdRequest) (*mspb.GetColumnByIdResponse, error)
func (*Cluster) GetColumnByName ¶
func (c *Cluster) GetColumnByName(ctx context.Context, req *mspb.GetColumnByNameRequest) (*mspb.GetColumnByNameResponse, error)
func (*Cluster) GetColumns ¶
func (c *Cluster) GetColumns(ctx context.Context, req *mspb.GetColumnsRequest) (*mspb.GetColumnsResponse, error)
func (*Cluster) GetDB ¶
func (c *Cluster) GetDB(ctx context.Context, req *mspb.GetDBRequest) (*mspb.GetDBResponse, error)
func (*Cluster) GetMSLeader ¶
func (c *Cluster) GetMSLeader(ctx context.Context, req *mspb.GetMSLeaderRequest) (*mspb.GetMSLeaderResponse, error)
func (*Cluster) GetNode ¶
func (c *Cluster) GetNode(ctx context.Context, req *mspb.GetNodeRequest) (*mspb.GetNodeResponse, error)
func (*Cluster) GetNodeId ¶
func (c *Cluster) GetNodeId(ctx context.Context, req *mspb.GetNodeIdRequest) (*mspb.GetNodeIdResponse, error)
func (*Cluster) GetRoute ¶
func (c *Cluster) GetRoute(ctx context.Context, req *mspb.GetRouteRequest) (*mspb.GetRouteResponse, error)
func (*Cluster) GetTable ¶
func (c *Cluster) GetTable(ctx context.Context, req *mspb.GetTableRequest) (*mspb.GetTableResponse, error)
func (*Cluster) GetTableById ¶
func (c *Cluster) GetTableById(ctx context.Context, req *mspb.GetTableByIdRequest) (*mspb.GetTableByIdResponse, error)
func (*Cluster) NodeHeartbeat ¶
func (c *Cluster) NodeHeartbeat(ctx context.Context, req *mspb.NodeHeartbeatRequest) (*mspb.NodeHeartbeatResponse, error)
func (*Cluster) NodeLogin ¶
func (c *Cluster) NodeLogin(ctx context.Context, req *mspb.NodeLoginRequest) (*mspb.NodeLoginResponse, error)
func (*Cluster) RangeHeartbeat ¶
func (c *Cluster) RangeHeartbeat(ctx context.Context, req *mspb.RangeHeartbeatRequest) (*mspb.RangeHeartbeatResponse, error)
func (*Cluster) ReportSplit ¶
func (c *Cluster) ReportSplit(ctx context.Context, req *mspb.ReportSplitRequest) (*mspb.ReportSplitResponse, error)
func (*Cluster) TruncateTable ¶
func (c *Cluster) TruncateTable(context.Context, *mspb.TruncateTableRequest) (*mspb.TruncateTableResponse, error)
type CreateTable ¶
type CreateTable struct { *Table // contains filtered or unexported fields }
func NewCreateTable ¶
func NewCreateTable(t *Table, n uint64) *CreateTable
type CreateTableCache ¶
type CreateTableCache struct {
// contains filtered or unexported fields
}
func NewCreateTableCache ¶
func NewCreateTableCache() *CreateTableCache
func (*CreateTableCache) Add ¶
func (tc *CreateTableCache) Add(t *CreateTable)
func (*CreateTableCache) Delete ¶
func (tc *CreateTableCache) Delete(id uint64)
func (*CreateTableCache) FindTable ¶
func (tc *CreateTableCache) FindTable(id uint64) (*CreateTable, bool)
func (*CreateTableCache) GetAllTable ¶
func (tc *CreateTableCache) GetAllTable() []*CreateTable
func (*CreateTableCache) Size ¶
func (tc *CreateTableCache) Size() int
type Database ¶
func NewDatabase ¶
func (*Database) DeleteTableByName ¶
仅仅从当前table列表中删除
func (*Database) FindTableById ¶
查找存在的table
func (*Database) GetAllTable ¶
type DbCache ¶
type DbCache struct {
// contains filtered or unexported fields
}
func NewDbCache ¶
func NewDbCache() *DbCache
func (*DbCache) GetAllDatabase ¶
type GlobalTableCache ¶
type GlobalTableCache struct {
// contains filtered or unexported fields
}
func NewGlobalTableCache ¶
func NewGlobalTableCache() *GlobalTableCache
func (*GlobalTableCache) Add ¶
func (tc *GlobalTableCache) Add(t *Table)
func (*GlobalTableCache) DeleteById ¶
func (tc *GlobalTableCache) DeleteById(id uint64)
func (*GlobalTableCache) FindTableById ¶
func (tc *GlobalTableCache) FindTableById(id uint64) (*Table, bool)
func (*GlobalTableCache) GetAllTable ¶
func (tc *GlobalTableCache) GetAllTable() []*Table
func (*GlobalTableCache) Size ¶
func (tc *GlobalTableCache) Size() int
type Range ¶
type Range struct { *metapb.Range Leader *metapb.Peer PeersStatus []*mspb.PeerStatus State metapb.RangeState // contains filtered or unexported fields }
type RangeCache ¶
type RangeCache struct {
// contains filtered or unexported fields
}
func NewRangeCache ¶
func NewRangeCache() *RangeCache
func (*RangeCache) Add ¶
func (rc *RangeCache) Add(r *Range)
func (*RangeCache) Delete ¶
func (rc *RangeCache) Delete(id uint64)
func (*RangeCache) FindRangeByID ¶
func (rc *RangeCache) FindRangeByID(id uint64) (*Range, bool)
func (*RangeCache) GetAllRange ¶
func (rc *RangeCache) GetAllRange() []*Range
func (*RangeCache) GetRandomRange ¶
func (rc *RangeCache) GetRandomRange() *Range
func (*RangeCache) MultipleSearchRanges ¶
func (rc *RangeCache) MultipleSearchRanges(key []byte, num int) ([]*Range, bool)
func (*RangeCache) SearchRange ¶
func (rc *RangeCache) SearchRange(key []byte) (*Range, bool)
func (*RangeCache) Size ¶
func (rc *RangeCache) Size() int
type Table ¶
func (*Table) DeleteRange ¶
func (*Table) GetAllRanges ¶
func (*Table) GetColumns ¶
func (*Table) GetPkColumns ¶
func (*Table) GetRangeNumber ¶
func (*Table) MergeColumn ¶
func (*Table) MultipleSearchRanges ¶
type TableCache ¶
type TableCache struct {
// contains filtered or unexported fields
}
func NewTableCache ¶
func NewTableCache() *TableCache
func (*TableCache) Add ¶
func (tc *TableCache) Add(t *Table)
func (*TableCache) DeleteById ¶
func (tc *TableCache) DeleteById(id uint64)
func (*TableCache) DeleteByName ¶
func (tc *TableCache) DeleteByName(name string)
func (*TableCache) FindTableById ¶
func (tc *TableCache) FindTableById(id uint64) (*Table, bool)
func (*TableCache) FindTableByName ¶
func (tc *TableCache) FindTableByName(name string) (*Table, bool)
func (*TableCache) GetAllTable ¶
func (tc *TableCache) GetAllTable() []*Table
func (*TableCache) Size ¶
func (tc *TableCache) Size() int
Click to show internal directories.
Click to hide internal directories.