cache

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JobStatusWaiting means the job hasn't started
	JobStatusWaiting JobStatus = "waiting"
	// JobStatusRunning means this job is running
	JobStatusRunning = "running"
	// JobStatusCancelling means this job is being canceled, but not canceled yet
	JobStatusCancelling = "cancelling"
	// JobStatusCancelled means this job has been canceled successfully
	JobStatusCancelled = "cancelled"
	// JobStatusTimeout means this job has timeout
	JobStatusTimeout = "timeout"
)

Variables

This section is empty.

Functions

func GetNextBytesHandleDatum

func GetNextBytesHandleDatum(key kv.Key, recordPrefix []byte) (d types.Datum)

GetNextBytesHandleDatum is used for a table with one binary or string column common handle. It returns the minValue whose encoded key is or after argument `key` If it cannot find a valid value, a null datum will be returned.

func GetNextIntHandle

func GetNextIntHandle(key kv.Key, recordPrefix []byte) kv.Handle

GetNextIntHandle is used for int handle tables. It returns the min handle whose encoded key is or after argument `key` If it cannot find a valid value, a null datum will be returned.

func SelectFromTTLTableStatusWithID

func SelectFromTTLTableStatusWithID(tableID int64) (string, []interface{})

SelectFromTTLTableStatusWithID returns an SQL statement to get the table status from table id

Types

type InfoSchemaCache

type InfoSchemaCache struct {
	Tables map[int64]*PhysicalTable
	// contains filtered or unexported fields
}

InfoSchemaCache is the cache for InfoSchema, it builds a map from physical table id to physical table information

func NewInfoSchemaCache

func NewInfoSchemaCache(updateInterval time.Duration) *InfoSchemaCache

NewInfoSchemaCache creates the cache for info schema

func (*InfoSchemaCache) GetInterval

func (bc *InfoSchemaCache) GetInterval() time.Duration

func (*InfoSchemaCache) SetInterval

func (bc *InfoSchemaCache) SetInterval(interval time.Duration)

SetInterval sets the interval of updating cache

func (*InfoSchemaCache) ShouldUpdate

func (bc *InfoSchemaCache) ShouldUpdate() bool

ShouldUpdate returns whether this cache needs update

func (*InfoSchemaCache) Update

func (isc *InfoSchemaCache) Update(se session.Session) error

Update updates the info schema cache

type JobStatus

type JobStatus string

JobStatus represents the current status of a job

type PhysicalTable

type PhysicalTable struct {
	// ID is the physical ID of the table
	ID int64
	// Schema is the database name of the table
	Schema model.CIStr
	*model.TableInfo
	// Partition is the partition name
	Partition model.CIStr
	// PartitionDef is the partition definition
	PartitionDef *model.PartitionDefinition
	// KeyColumns is the cluster index key columns for the table
	KeyColumns []*model.ColumnInfo
	// KeyColumnTypes is the types of the key columns
	KeyColumnTypes []*types.FieldType
	// TimeColum is the time column used for TTL
	TimeColumn *model.ColumnInfo
}

PhysicalTable is used to provide some information for a physical table in TTL job

func NewPhysicalTable

func NewPhysicalTable(schema model.CIStr, tbl *model.TableInfo, partition model.CIStr) (*PhysicalTable, error)

NewPhysicalTable create a new PhysicalTable

func (*PhysicalTable) EvalExpireTime

func (t *PhysicalTable) EvalExpireTime(ctx context.Context, se session.Session, now time.Time) (expire time.Time, err error)

EvalExpireTime returns the expired time

func (*PhysicalTable) SplitScanRanges

func (t *PhysicalTable) SplitScanRanges(ctx context.Context, store kv.Storage, splitCnt int) ([]ScanRange, error)

SplitScanRanges split ranges for TTL scan

func (*PhysicalTable) ValidateKeyPrefix

func (t *PhysicalTable) ValidateKeyPrefix(key []types.Datum) error

ValidateKeyPrefix validates a key prefix

type ScanRange

type ScanRange struct {
	Start []types.Datum
	End   []types.Datum
}

ScanRange is the range to scan. The range is: [Start, End)

type TableStatus

type TableStatus struct {
	TableID       int64
	ParentTableID int64

	TableStatistics string

	LastJobID         string
	LastJobStartTime  time.Time
	LastJobFinishTime time.Time
	LastJobTTLExpire  time.Time
	LastJobSummary    string

	CurrentJobID          string
	CurrentJobOwnerID     string
	CurrentJobOwnerAddr   string
	CurrentJobOwnerHBTime time.Time
	CurrentJobStartTime   time.Time
	CurrentJobTTLExpire   time.Time

	CurrentJobState            string
	CurrentJobStatus           JobStatus
	CurrentJobStatusUpdateTime time.Time
}

TableStatus contains the corresponding information in the system table `mysql.tidb_ttl_table_status`

func RowToTableStatus

func RowToTableStatus(sctx sessionctx.Context, row chunk.Row) (*TableStatus, error)

RowToTableStatus converts a row to table status

type TableStatusCache

type TableStatusCache struct {
	Tables map[int64]*TableStatus
	// contains filtered or unexported fields
}

TableStatusCache is the cache for ttl table status, it builds a map from physical table id to the table status

func NewTableStatusCache

func NewTableStatusCache(updateInterval time.Duration) *TableStatusCache

NewTableStatusCache creates cache for ttl table status

func (*TableStatusCache) GetInterval

func (bc *TableStatusCache) GetInterval() time.Duration

func (*TableStatusCache) SetInterval

func (bc *TableStatusCache) SetInterval(interval time.Duration)

SetInterval sets the interval of updating cache

func (*TableStatusCache) ShouldUpdate

func (bc *TableStatusCache) ShouldUpdate() bool

ShouldUpdate returns whether this cache needs update

func (*TableStatusCache) Update

func (tsc *TableStatusCache) Update(ctx context.Context, se session.Session) error

Update updates the table status cache

Jump to

Keyboard shortcuts

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