tblctx

package
v1.1.0-beta.0...-9958228 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllocatorContext

type AllocatorContext interface {
	// AlternativeAllocators returns an alternative `autoid.Allocators` for the table.
	// If the second return value is nil, it means there are no alternative allocators in the context.
	// Currently, it provides alternative allocators for temporary tables to alloc IDs in session.
	AlternativeAllocators(tbl *model.TableInfo) (autoid.Allocators, bool)
}

AllocatorContext is used to provide context for method `table.Allocators`.

type CachedTableSupport

type CachedTableSupport interface {
	// AddCachedTableHandleToTxn adds a cached handle to the current transaction
	// to handle cached table when committing txn.
	// The handle argument should implement `table.CachedTable` interface, but here is `any` to avoid import cycle.
	AddCachedTableHandleToTxn(tableID int64, handle any)
}

CachedTableSupport is used for cached table operations

type CheckRowBuffer

type CheckRowBuffer struct {
	// contains filtered or unexported fields
}

CheckRowBuffer is used to check row constraints

func (*CheckRowBuffer) AddColVal

func (b *CheckRowBuffer) AddColVal(val types.Datum)

AddColVal adds a column value to the buffer for checking.

func (*CheckRowBuffer) GetRowToCheck

func (b *CheckRowBuffer) GetRowToCheck() chunk.Row

GetRowToCheck gets the row data for constraint check.

func (*CheckRowBuffer) Reset

func (b *CheckRowBuffer) Reset(capacity int)

Reset resets the inner buffer to a capacity.

type ColSizeDeltaBuffer

type ColSizeDeltaBuffer struct {
	// contains filtered or unexported fields
}

ColSizeDeltaBuffer is a buffer to store the change of column size.

func (*ColSizeDeltaBuffer) AddColSizeDelta

func (b *ColSizeDeltaBuffer) AddColSizeDelta(colID int64, size int64)

AddColSizeDelta adds the column size delta to the buffer.

func (*ColSizeDeltaBuffer) Reset

func (b *ColSizeDeltaBuffer) Reset(capacity int)

Reset resets the inner buffers to a capacity.

func (*ColSizeDeltaBuffer) UpdateColSizeMap

func (b *ColSizeDeltaBuffer) UpdateColSizeMap(m map[int64]int64) map[int64]int64

UpdateColSizeMap updates the column size map which uses columID as the map key and column size as the value.

type EncodeRowBuffer

type EncodeRowBuffer struct {
	// contains filtered or unexported fields
}

EncodeRowBuffer is used to encode a row.

func (*EncodeRowBuffer) AddColVal

func (b *EncodeRowBuffer) AddColVal(colID int64, val types.Datum)

AddColVal adds a column value to the buffer.

func (*EncodeRowBuffer) EncodeBinlogRowData

func (b *EncodeRowBuffer) EncodeBinlogRowData(loc *time.Location, ec errctx.Context) ([]byte, error)

EncodeBinlogRowData encodes the row data for binlog and returns the encoded row value. The returned slice is not referenced in the buffer, so you can cache and modify them freely.

func (*EncodeRowBuffer) Reset

func (b *EncodeRowBuffer) Reset(capacity int)

Reset resets the inner buffers to a capacity.

func (*EncodeRowBuffer) WriteMemBufferEncoded

func (b *EncodeRowBuffer) WriteMemBufferEncoded(
	cfg RowEncodingConfig, loc *time.Location, ec errctx.Context,
	memBuffer kv.MemBuffer, key kv.Key, handle kv.Handle, flags ...kv.FlagsOp,
) error

WriteMemBufferEncoded writes the encoded row to the memBuffer.

type ExchangePartitionDMLSupport

type ExchangePartitionDMLSupport interface {
	// GetInfoSchemaToCheckExchangeConstraint is used by DML to get the exchanged table to check
	// constraints when exchanging partition.
	GetInfoSchemaToCheckExchangeConstraint() infoschema.MetaOnlyInfoSchema
}

ExchangePartitionDMLSupport is used for DML operations when the table exchanging a partition.

type MutateBuffers

type MutateBuffers struct {
	// contains filtered or unexported fields
}

MutateBuffers is a memory pool for table related memory allocation that aims to reuse memory and saves allocation. It is used in table operations like AddRecord/UpdateRecord/DeleteRecord. You can use `GetXXXBufferWithCap` to get the buffer and reset its inner slices to a capacity. Because inner slices are reused, you should not call the get methods again before finishing the previous usage. Otherwise, the previous data will be overwritten.

func NewMutateBuffers

func NewMutateBuffers(stmtBufs *variable.WriteStmtBufs) *MutateBuffers

NewMutateBuffers creates a new `MutateBuffers`.

func (*MutateBuffers) GetCheckRowBufferWithCap

func (b *MutateBuffers) GetCheckRowBufferWithCap(capacity int) *CheckRowBuffer

GetCheckRowBufferWithCap gets the buffer to check row constraints. Usage: 1. Call `GetCheckRowBufferWithCap` to get the buffer. 2. Call `CheckRowBuffer.AddColVal` for every column to add column values. 3. Call `CheckRowBuffer.GetRowToCheck` to get the row data for constraint check. Because the inner slices are reused, you should not call this method again before finishing the previous usage. Otherwise, the previous data will be overwritten.

func (*MutateBuffers) GetColSizeDeltaBufferWithCap

func (b *MutateBuffers) GetColSizeDeltaBufferWithCap(capacity int) *ColSizeDeltaBuffer

GetColSizeDeltaBufferWithCap gets the buffer for column size delta collection and resets the capacity of its inner slice. Usage: 1. Call `GetColSizeDeltaBufferWithCap` to get the buffer. 2. Call `ColSizeDeltaBuffer.AddColSizeDelta` for every column to add column size delta. 3. Call `ColSizeDeltaBuffer.UpdateColSizeMap` to update a column size map. Because the inner slices are reused, you should not call this method again before finishing the previous usage. Otherwise, the previous data will be overwritten.

func (*MutateBuffers) GetEncodeRowBufferWithCap

func (b *MutateBuffers) GetEncodeRowBufferWithCap(capacity int) *EncodeRowBuffer

GetEncodeRowBufferWithCap gets the buffer to encode a row. Usage: 1. Call `MutateBuffers.GetEncodeRowBufferWithCap` to get the buffer. 2. Call `EncodeRowBuffer.AddColVal` for every column to add column values. 3. Call `EncodeRowBuffer.WriteMemBufferEncoded` to encode row and write it to the memBuffer. Because the inner slices are reused, you should not call this method again before finishing the previous usage. Otherwise, the previous data will be overwritten.

func (*MutateBuffers) GetWriteStmtBufs

func (b *MutateBuffers) GetWriteStmtBufs() *variable.WriteStmtBufs

GetWriteStmtBufs returns the `*variable.WriteStmtBufs`

type MutateContext

type MutateContext interface {
	AllocatorContext
	// GetExprCtx returns the context to build or evaluate expressions
	GetExprCtx() exprctx.ExprContext
	// ConnectionID returns the id of the current connection.
	// If the current environment is not in a query from the client, the return value is 0.
	ConnectionID() uint64
	// InRestrictedSQL returns whether the current context is used in restricted SQL.
	InRestrictedSQL() bool
	// TxnAssertionLevel returns the assertion level of the current transaction.
	TxnAssertionLevel() variable.AssertionLevel
	// EnableMutationChecker returns whether to check data consistency for mutations.
	EnableMutationChecker() bool
	// GetRowEncodingConfig returns the RowEncodingConfig.
	GetRowEncodingConfig() RowEncodingConfig
	// GetMutateBuffers returns the MutateBuffers,
	// which is a buffer for table related structures that aims to reuse memory and
	// saves allocation.
	GetMutateBuffers() *MutateBuffers
	// GetRowIDShardGenerator returns the `RowIDShardGenerator` object to shard rows.
	GetRowIDShardGenerator() *variable.RowIDShardGenerator
	// GetReservedRowIDAlloc returns the `ReservedRowIDAlloc` object to allocate row id from reservation.
	GetReservedRowIDAlloc() (*stmtctx.ReservedRowIDAlloc, bool)
	// GetStatisticsSupport returns a `StatisticsSupport` if the context supports it.
	// If the context does not support statistics update, the second return value will be false.
	GetStatisticsSupport() (StatisticsSupport, bool)
	// GetCachedTableSupport returns a `CachedTableSupport` if the context supports it.
	// If the context does not support cached table, the second return value will be false.
	GetCachedTableSupport() (CachedTableSupport, bool)
	// GetTemporaryTableSupport returns a `TemporaryTableSupport` if the context supports it.
	// If the context does not support temporary table, the second return value will be false.
	GetTemporaryTableSupport() (TemporaryTableSupport, bool)
	// GetExchangePartitionDMLSupport returns a `ExchangePartitionDMLSupport` if the context supports it.
	// ExchangePartitionDMLSupport is used by DMLs when the table is exchanging a partition.
	GetExchangePartitionDMLSupport() (ExchangePartitionDMLSupport, bool)
}

MutateContext is used to when mutating a table.

type RowEncodingConfig

type RowEncodingConfig struct {
	// IsRowLevelChecksumEnabled indicates whether the row level checksum is enabled.
	IsRowLevelChecksumEnabled bool
	// RowEncoder is used to encode a row
	RowEncoder *rowcodec.Encoder
}

RowEncodingConfig is used to provide config for row encoding.

type StatisticsSupport

type StatisticsSupport interface {
	// UpdatePhysicalTableDelta updates the physical table delta.
	UpdatePhysicalTableDelta(physicalTableID int64, delta int64, count int64, cols variable.DeltaCols)
}

StatisticsSupport is used for statistics update operations.

type TemporaryTableHandler

type TemporaryTableHandler struct {
	// contains filtered or unexported fields
}

TemporaryTableHandler is used by `table.Table` to handle temporary table.

func NewTemporaryTableHandler

func NewTemporaryTableHandler(tbl tableutil.TempTable, data variable.TemporaryTableData) TemporaryTableHandler

NewTemporaryTableHandler creates a new TemporaryTableHandler

func (*TemporaryTableHandler) GetCommittedSize

func (h *TemporaryTableHandler) GetCommittedSize() int64

GetCommittedSize returns the committed data size of the temporary table

func (*TemporaryTableHandler) GetDirtySize

func (h *TemporaryTableHandler) GetDirtySize() int64

GetDirtySize returns the size of dirty data in txn of the temporary table

func (*TemporaryTableHandler) Meta

Meta returns the meta

func (*TemporaryTableHandler) UpdateTxnDeltaSize

func (h *TemporaryTableHandler) UpdateTxnDeltaSize(delta int)

UpdateTxnDeltaSize updates the size of dirty data statistics in txn of the temporary table

type TemporaryTableSupport

type TemporaryTableSupport interface {
	// GetTemporaryTableSizeLimit returns the size limit of a temporary table.
	GetTemporaryTableSizeLimit() int64
	// AddTemporaryTableToTxn adds a temporary table to txn to mark it is modified
	// and txn will handle it when committing.
	// It returns a `TemporaryTableHandler` object which provides some extra info for the temporary table.
	AddTemporaryTableToTxn(tblInfo *model.TableInfo) (TemporaryTableHandler, bool)
}

TemporaryTableSupport is used for temporary table operations

Jump to

Keyboard shortcuts

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