Documentation ¶
Index ¶
- func AnalyzeTable(ctx context.Context, db *sql.DB, tableName string) error
- func CalculateChunkSize(rowCount int64) int64
- func CompareData(map1, map2 map[string]*dbutil.ColumnData, ...) (equal bool, cmp int32, err error)
- func CompareStruct(upstreamTableInfos []*model.TableInfo, downstreamTableInfo *model.TableInfo) (isEqual bool, isPanic bool)
- func EscapeName(name string) string
- func GenerateDeleteDML(data map[string]*dbutil.ColumnData, table *model.TableInfo, schema string) string
- func GenerateReplaceDML(data map[string]*dbutil.ColumnData, table *model.TableInfo, schema string) string
- func GenerateReplaceDMLWithAnnotation(source, target map[string]*dbutil.ColumnData, table *model.TableInfo, ...) string
- func GetApproximateMidBySize(ctx context.Context, db *sql.DB, schema, table string, ...) (map[string]string, error)
- func GetBetterIndex(ctx context.Context, db *sql.DB, schema, table string, ...) ([]*model.IndexInfo, error)
- func GetChunkIDFromSQLFileName(fileIDStr string) (int, int, int, int, error)
- func GetColumnsFromIndex(index *model.IndexInfo, tableInfo *model.TableInfo) []*model.ColumnInfo
- func GetCountAndCRC32Checksum(ctx context.Context, db *sql.DB, schemaName, tableName string, ...) (int64, int64, error)
- func GetPDAddrs(ctx context.Context, db *sql.DB) ([]string, error)
- func GetPDClientForGC(ctx context.Context, db *sql.DB) (pd.Client, error)
- func GetSQLFileName(index *chunk.ChunkID) string
- func GetSelectivity(ctx context.Context, db *sql.DB, schemaName, tableName, columnName string, ...) (float64, error)
- func GetSnapshot(ctx context.Context, db *sql.DB) ([]string, error)
- func GetSpecifiedColumnValueAndClose(rows *sql.Rows, columnName string) ([]string, error)
- func GetTableRowsQueryFormat(schema, table string, tableInfo *model.TableInfo, collation string) (string, []*model.ColumnInfo)
- func GetTableSize(ctx context.Context, db *sql.DB, schemaName, tableName string) (int64, error)
- func MinLenInSlices(slices [][]string) int
- func NeedQuotes(tp byte) bool
- func ResetColumns(tableInfo *model.TableInfo, columns []string) (*model.TableInfo, bool)
- func SliceToMap(slice []string) map[string]interface{}
- func StartGCSavepointUpdateService(ctx context.Context, pdCli pd.Client, db *sql.DB, snapshot string) error
- func UniqueID(schema string, table string) string
- type Worker
- type WorkerPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnalyzeTable ¶
AnalyzeTable do 'ANALYZE TABLE `table`' SQL.
func CalculateChunkSize ¶
CalculateChunkSize returns chunkSize according to table rows count.
func CompareData ¶
func CompareData(map1, map2 map[string]*dbutil.ColumnData, orderKeyCols, columns []*model.ColumnInfo) (equal bool, cmp int32, err error)
CompareData compare two row datas. equal = true: map1 = map2 equal = false:
- cmp = 0: map1 and map2 have the same orderkeycolumns, but other columns are in difference.
- cmp = -1: map1 < map2 (by comparing the orderkeycolumns)
- cmp = 1: map1 > map2
func CompareStruct ¶
func CompareStruct(upstreamTableInfos []*model.TableInfo, downstreamTableInfo *model.TableInfo) (isEqual bool, isPanic bool)
CompareStruct compare tables' columns and indices from upstream and downstream. There are 2 return values:
isEqual : result of comparing tables' columns and indices isPanic : the differences of tables' struct can not be ignored. Need to skip data comparing.
func GenerateDeleteDML ¶
func GenerateDeleteDML(data map[string]*dbutil.ColumnData, table *model.TableInfo, schema string) string
GerateReplaceDMLWithAnnotation returns the delete SQL for the specific row.
func GenerateReplaceDML ¶
func GenerateReplaceDML(data map[string]*dbutil.ColumnData, table *model.TableInfo, schema string) string
GenerateReplaceDML returns the insert SQL for the specific row values.
func GenerateReplaceDMLWithAnnotation ¶
func GenerateReplaceDMLWithAnnotation(source, target map[string]*dbutil.ColumnData, table *model.TableInfo, schema string) string
GerateReplaceDMLWithAnnotation returns the replace SQL for the specific 2 rows. And add Annotations to show the different columns.
func GetApproximateMidBySize ¶
func GetApproximateMidBySize(ctx context.Context, db *sql.DB, schema, table string, indexColumns []*model.ColumnInfo, limitRange string, args []interface{}, count int64) (map[string]string, error)
GetApproximateMidBySize return the `count`th row in rows that meet the `limitRange`.
func GetBetterIndex ¶
func GetBetterIndex(ctx context.Context, db *sql.DB, schema, table string, tableInfo *model.TableInfo) ([]*model.IndexInfo, error)
GetBetterIndex returns the index more dinstict. If the index is primary key or unique, it can be return directly. Otherwise select the index which has higher value of `COUNT(DISTINCT a)/COUNT(*)`.
func GetChunkIDFromSQLFileName ¶
GetChunkIDFromSQLFileName convert the filename to chunk's `Index`.
func GetColumnsFromIndex ¶
GetColumnsFromIndex returns `ColumnInfo`s of the specified index.
func GetCountAndCRC32Checksum ¶
func GetCountAndCRC32Checksum(ctx context.Context, db *sql.DB, schemaName, tableName string, tbInfo *model.TableInfo, limitRange string, args []interface{}) (int64, int64, error)
GetCountAndCRC32Checksum returns checksum code and count of some data by given condition
func GetPDAddrs ¶
GetPDAddrs gets PD address from TiDB
func GetPDClientForGC ¶
GetPDClientForGC is an initialization step.
func GetSQLFileName ¶
GetSQLFileName returns filename of fix-SQL identified by chunk's `Index`.
func GetSelectivity ¶
func GetSelectivity(ctx context.Context, db *sql.DB, schemaName, tableName, columnName string, tbInfo *model.TableInfo) (float64, error)
GetSelectivity returns the value of `COUNT(DISTINCT col)/COUNT(1)` SQL.
func GetSpecifiedColumnValueAndClose ¶
GetSpecifiedColumnValueAndClose get columns' values whose name is equal to columnName and close the given rows
func GetTableRowsQueryFormat ¶
func GetTableRowsQueryFormat(schema, table string, tableInfo *model.TableInfo, collation string) (string, []*model.ColumnInfo)
GetTableRowsQueryFormat returns a rowsQuerySQL template for the specific table.
e.g. SELECT /*!40001 SQL_NO_CACHE */ `a`, `b` FROM `schema`.`table` WHERE %s ORDER BY `a`.
func GetTableSize ¶
GetTableSize loads the TableSize from `information_schema`.`tables`.
func MinLenInSlices ¶
MinLenInSlices returns the smallest length among slices.
func NeedQuotes ¶
NeedQuotes determines whether an escape character is required for `'`.
func ResetColumns ¶
ResetColumns removes index from `tableInfo.Indices`, whose columns appear in `columns`. And removes column from `tableInfo.Columns`, which appears in `columns`. And initializes the offset of the column of each index to new `tableInfo.Columns`.
Return the new tableInfo and the flag whether the columns have timestamp type.
func SliceToMap ¶
SliceToMap converts Slice to Set
Types ¶
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool contains a pool of workers. The number of workers in the channel represents how many goruntines can be created to execute the task. After the task is done, worker will be sent back to the channel.
func NewWorkerPool ¶
func NewWorkerPool(limit uint, name string) *WorkerPool
NewWorkerPool returns a WorkerPool with `limit` workers in the channel.
func (*WorkerPool) Apply ¶
func (pool *WorkerPool) Apply(fn taskFunc)
Apply wait for an idle worker to run `taskFunc`. Notice: function `Apply` and `WaitFinished` cannot be called in parallel
func (*WorkerPool) HasWorker ¶
func (pool *WorkerPool) HasWorker() bool
HasWorker checks if the pool has unallocated workers.
func (*WorkerPool) WaitFinished ¶
func (pool *WorkerPool) WaitFinished()
WaitFinished waits till the pool finishs all the tasks.