incrservice

package
v1.2.2-20240715 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetAutoIncrementServiceByID added in v1.0.0

func SetAutoIncrementServiceByID(id string, v AutoIncrementService)

SetAutoIncrementServiceByID set auto increment service instance into process level runtime.

Types

type AutoColumn

type AutoColumn struct {
	TableID  uint64
	ColName  string
	ColIndex int
	Offset   uint64
	Step     uint64
}

AutoColumn model

func GetAutoColumnFromDef

func GetAutoColumnFromDef(def *plan.TableDef) []AutoColumn

GetAutoColumnFromDef get auto columns from table def

type AutoIncrementService

type AutoIncrementService interface {
	// UUID returns the uuid of this increment service, which comes from CN service.
	UUID() string
	// Create a separate transaction is used to create the cache service and insert records
	// into catalog.AutoIncrTableName before the transaction that created the table is committed.
	// When the transaction that created the table is rolled back, the corresponding records in
	// catalog.AutoIncrTableName are deleted.
	Create(ctx context.Context, tableID uint64, caches []AutoColumn, txn client.TxnOperator) error
	// Reset consists of delete+create, if keep is true, then the new self-incrementing column cache
	// will retain the value of the old cache
	Reset(ctx context.Context, oldTableID, newTableID uint64, keep bool, txn client.TxnOperator) error
	// Delete until the delete table transaction is committed, no operation is performed, only the
	// records to be deleted are recorded. When the delete table transaction is committed, the
	// delete operation is triggered.
	Delete(ctx context.Context, tableID uint64, txn client.TxnOperator) error
	// InsertValues insert auto columns values into bat.
	InsertValues(ctx context.Context, tableID uint64, bat *batch.Batch, estimate int64) (uint64, error)
	// CurrentValue return current incr column value.
	CurrentValue(ctx context.Context, tableID uint64, col string) (uint64, error)
	// Reload reload auto increment cache.
	Reload(ctx context.Context, tableID uint64) error
	// Close close the auto increment service
	Close()
}

AutoIncrementService provides data service for the columns of auto-increment. Each CN contains a service instance. Whenever a table containing an auto-increment column is created, the service internally creates a data cache for the auto-increment column to avoid updating the sequence values of these auto-increment columns each time data is inserted.

func GetAutoIncrementService

func GetAutoIncrementService(ctx context.Context) AutoIncrementService

GetAutoIncrementService get increment service from process level runtime

func NewIncrService

func NewIncrService(
	uuid string,
	store IncrValueStore,
	cfg Config) AutoIncrementService

type Config

type Config struct {
	// CountPerAllocate how many ids are cached in the current cn node for each assignment
	CountPerAllocate int `toml:"count-per-allocate"`
	// LowCapacity when the remaining number of ids is less than this value, the current cn
	// node will initiate asynchronous task assignment in advance
	LowCapacity int `toml:"low-capacity"`
}

Config auto increment config

type IncrValueStore

type IncrValueStore interface {
	// GetColumns return auto columns of table.
	GetColumns(ctx context.Context, tableID uint64, txnOp client.TxnOperator) ([]AutoColumn, error)
	// Create add metadata records into catalog.AutoIncrTableName.
	Create(ctx context.Context, tableID uint64, cols []AutoColumn, txnOp client.TxnOperator) error
	// Allocate allocate new range for auto-increment column.
	Allocate(ctx context.Context, tableID uint64, col string, count int, txnOp client.TxnOperator) (uint64, uint64, error)
	// UpdateMinValue update auto column min value to specified value.
	UpdateMinValue(ctx context.Context, tableID uint64, col string, minValue uint64, txnOp client.TxnOperator) error
	// Delete remove metadata records from catalog.AutoIncrTableName.
	Delete(ctx context.Context, tableID uint64) error
	// Close the store
	Close()
}

IncrValueStore is used to add and delete metadata records for auto-increment columns.

func NewMemStore

func NewMemStore() IncrValueStore

NewMemStore new mem store

Jump to

Keyboard shortcuts

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