tidb: github.com/pingcap/tidb/meta/autoid Index | Files

package autoid

import "github.com/pingcap/tidb/meta/autoid"

Index

Package Files

autoid.go errors.go

Variables

var (
    ErrAutoincReadFailed = terror.ClassAutoid.New(mysql.ErrAutoincReadFailed, mysql.MySQLErrName[mysql.ErrAutoincReadFailed])
    ErrWrongAutoKey      = terror.ClassAutoid.New(mysql.ErrWrongAutoKey, mysql.MySQLErrName[mysql.ErrWrongAutoKey])
)

Error instances.

func GenLocalSchemaID Uses

func GenLocalSchemaID() int64

GenLocalSchemaID generates a local schema ID.

func GetStep Uses

func GetStep() int64

GetStep is only used by tests

func NextStep Uses

func NextStep(curStep int64, consumeDur time.Duration) int64

NextStep return new auto id step according to previous step and consuming time.

func SetStep Uses

func SetStep(s int64)

SetStep is only used by tests

type Allocator Uses

type Allocator interface {
    // Alloc allocs N consecutive autoID for table with tableID, returning (min, max] of the allocated autoID batch.
    // It gets a batch of autoIDs at a time. So it does not need to access storage for each call.
    // The consecutive feature is used to insert multiple rows in a statement.
    Alloc(tableID int64, n uint64) (int64, int64, error)
    // Rebase rebases the autoID base for table with tableID and the new base value.
    // If allocIDs is true, it will allocate some IDs and save to the cache.
    // If allocIDs is false, it will not allocate IDs.
    Rebase(tableID, newBase int64, allocIDs bool) error
    // Base return the current base of Allocator.
    Base() int64
    // End is only used for test.
    End() int64
    // NextGlobalAutoID returns the next global autoID.
    NextGlobalAutoID(tableID int64) (int64, error)
}

Allocator is an auto increment id generator. Just keep id unique actually.

func NewAllocator Uses

func NewAllocator(store kv.Storage, dbID int64, isUnsigned bool) Allocator

NewAllocator returns a new auto increment id generator on the store.

Package autoid imports 15 packages (graph) and is imported by 254 packages. Updated 2019-11-11. Refresh now. Tools for package owners.