Skip to content

Commit

Permalink
*: add table option: pre_split_regions (pingcap#287)
Browse files Browse the repository at this point in the history
* *: add table option: pre_split_resions

* refine code

* add PreSplitRegions in tableInfo

* Update misc.go

Co-Authored-By: crazycs520 <crazycs520@gmail.com>

* Update parser.y

Co-Authored-By: crazycs520 <crazycs520@gmail.com>

* address comment

* refine comment
  • Loading branch information
crazycs520 authored and kennytm committed Apr 15, 2019
1 parent a73b469 commit de4274a
Show file tree
Hide file tree
Showing 5 changed files with 5,256 additions and 5,232 deletions.
7 changes: 5 additions & 2 deletions ast/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@ const (
TableOptionRowFormat
TableOptionStatsPersistent
TableOptionShardRowID
TableOptionPreSplitRegion
TableOptionPackKeys
)

Expand Down Expand Up @@ -1324,8 +1325,10 @@ func (n *TableOption) Restore(ctx *RestoreCtx) error {
ctx.WritePlain(" /* TableOptionStatsPersistent is not supported */ ")
case TableOptionShardRowID:
ctx.WriteKeyWord("SHARD_ROW_ID_BITS ")
ctx.WritePlain("= ")
ctx.WritePlainf("%d", n.UintValue)
ctx.WritePlainf("= %d", n.UintValue)
case TableOptionPreSplitRegion:
ctx.WriteKeyWord("PRE_SPLIT_REGIONS ")
ctx.WritePlainf("= %d", n.UintValue)
case TableOptionPackKeys:
// TODO: not support
ctx.WriteKeyWord("PACK_KEYS ")
Expand Down
1 change: 1 addition & 0 deletions misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ var tokenMap = map[string]int{
"QUERIES": queries,
"QUICK": quick,
"SHARD_ROW_ID_BITS": shardRowIDBits,
"PRE_SPLIT_REGIONS": preSplitRegions,
"RANGE": rangeKwd,
"RECOVER": recover,
"READ": read,
Expand Down
4 changes: 4 additions & 0 deletions model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ type TableInfo struct {
ShardRowIDBits uint64
// MaxShardRowIDBits uses to record the max ShardRowIDBits be used so far.
MaxShardRowIDBits uint64 `json:"max_shard_row_id_bits"`
// PreSplitRegions specify the pre-split region when create table.
// The pre-split region num is 2^(PreSplitRegions-1).
// And the PreSplitRegions should less than or equal to ShardRowIDBits.
PreSplitRegions uint64 `json:"pre_split_regions"`

Partition *PartitionInfo `json:"partition"`

Expand Down
Loading

0 comments on commit de4274a

Please sign in to comment.