util

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

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneColInfos

func CloneColInfos(cols []*model.ColumnInfo) []*model.ColumnInfo

CloneColInfos uses (*ColumnInfo).Clone to clone a slice of *ColumnInfo.

func CloneCols

func CloneCols(cols []*expression.Column) []*expression.Column

CloneCols uses (*Column).Clone to clone a slice of *Column.

func CloneExprs

func CloneExprs(exprs []expression.Expression) []expression.Expression

CloneExprs uses Expression.Clone to clone a slice of Expression.

func CloneRanges

func CloneRanges(ranges []*ranger.Range) []*ranger.Range

CloneRanges uses (*Range).Clone to clone a slice of *Range.

func CompareCol2Len

func CompareCol2Len(c1, c2 Col2Len) (int, bool)

CompareCol2Len will compare the two Col2Len maps. The last return value is used to indicate whether they are comparable. When the second return value is true, the first return value: (1) -1 means that c1 is worse than c2; (2) 0 means that c1 equals to c2; (3) 1 means that c1 is better than c2;

Types

type AccessPath

type AccessPath struct {
	Index          *model.IndexInfo
	FullIdxCols    []*expression.Column
	FullIdxColLens []int
	IdxCols        []*expression.Column
	IdxColLens     []int
	// ConstCols indicates whether the column is constant under the given conditions for all index columns.
	ConstCols []bool
	Ranges    []*ranger.Range
	// CountAfterAccess is the row count after we apply range seek and before we use other filter to filter data.
	// For index merge path, CountAfterAccess is the row count after partial paths and before we apply table filters.
	CountAfterAccess float64
	// CountAfterIndex is the row count after we apply filters on index and before we apply the table filters.
	CountAfterIndex float64
	AccessConds     []expression.Expression
	EqCondCount     int
	EqOrInCondCount int
	IndexFilters    []expression.Expression
	TableFilters    []expression.Expression
	// PartialIndexPaths store all index access paths.
	// If there are extra filters, store them in TableFilters.
	PartialIndexPaths []*AccessPath
	// IndexMergeIsIntersection means whether it's intersection type or union type IndexMerge path.
	// It's only valid for a IndexMerge path.
	// Intersection type is for expressions connected by `AND` and union type is for `OR`.
	IndexMergeIsIntersection bool
	// IndexMergeAccessMVIndex indicates whether this IndexMerge path accesses a MVIndex.
	IndexMergeAccessMVIndex bool

	StoreType kv.StoreType

	IsDNFCond bool

	// IsIntHandlePath indicates whether this path is table path.
	IsIntHandlePath    bool
	IsCommonHandlePath bool
	// Forced means this path is generated by `use/force index()`.
	Forced           bool
	ForceKeepOrder   bool
	ForceNoKeepOrder bool
	// IsSingleScan indicates whether the path is a single index/table scan or table access after index scan.
	IsSingleScan bool

	// Maybe added in model.IndexInfo better, but the cache of model.IndexInfo may lead side effect
	IsUkShardIndexPath bool
}

AccessPath indicates the way we access a table: by using single index, or by using multiple indexes, or just by using table scan.

func (*AccessPath) Clone

func (path *AccessPath) Clone() *AccessPath

Clone returns a deep copy of the original AccessPath. Note that we rely on the Expression.Clone(), (*IndexInfo).Clone() and (*Range).Clone() in this method, so there are some fields like FieldType are not deep-copied.

func (*AccessPath) GetCol2LenFromAccessConds

func (path *AccessPath) GetCol2LenFromAccessConds() Col2Len

GetCol2LenFromAccessConds returns columns with lengths from path.AccessConds.

func (*AccessPath) IsTablePath

func (path *AccessPath) IsTablePath() bool

IsTablePath returns true if it's IntHandlePath or CommonHandlePath.

func (*AccessPath) OnlyPointRange

func (path *AccessPath) OnlyPointRange(sctx sessionctx.Context) bool

OnlyPointRange checks whether each range is a point(no interval range exists).

func (*AccessPath) SplitCorColAccessCondFromFilters

func (path *AccessPath) SplitCorColAccessCondFromFilters(ctx sessionctx.Context, eqOrInCount int) (access, remained []expression.Expression)

SplitCorColAccessCondFromFilters move the necessary filter in the form of index_col = corrlated_col to access conditions. The function consider the `idx_col_1 = const and index_col_2 = cor_col and index_col_3 = const` case. It enables more index columns to be considered. The range will be rebuilt in 'ResolveCorrelatedColumns'.

type ByItems

type ByItems struct {
	Expr expression.Expression
	Desc bool
}

ByItems wraps a "by" item.

func (*ByItems) Clone

func (by *ByItems) Clone() *ByItems

Clone makes a copy of ByItems.

func (*ByItems) Equal

func (by *ByItems) Equal(ctx sessionctx.Context, other *ByItems) bool

Equal checks whether two ByItems are equal.

func (*ByItems) MemoryUsage

func (by *ByItems) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of ByItems.

func (*ByItems) String

func (by *ByItems) String() string

String implements fmt.Stringer interface.

type Col2Len

type Col2Len map[int64]int

Col2Len maps expression.Column.UniqueID to column length

func ExtractCol2Len

func ExtractCol2Len(exprs []expression.Expression, idxCols []*expression.Column, idxColLens []int) Col2Len

ExtractCol2Len collects index/table columns with lengths from expressions. If idxCols and idxColLens are not nil, it collects index columns with lengths(maybe prefix lengths). Otherwise it collects table columns with full lengths.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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