MCPcopy
hub / github.com/pingcap/tidb / indexJoinPathTmpInit

Function indexJoinPathTmpInit

pkg/planner/core/index_join_path.go:485–514  ·  view source on GitHub ↗

Reset the 'curIdxOff2KeyOff', 'curNotUsedIndexCols' and 'curNotUsedColLens' by innerKeys and idxCols * For each idxCols, If column can be found in innerKeys save offset of innerKeys in 'curIdxOff2KeyOff' Else, save -1 in 'curIdxOff2KeyOff' */ For example, innerKeys[t1.a, t1.sum_b, t1.c], idxCo

(
	sctx planctx.PlanContext,
	indexJoinInfo *indexJoinPathInfo,
	idxCols []*expression.Column,
	colLens []int)

Source from the content-addressed store, hash-verified

483// For example, innerKeys[t1.a, t1.sum_b, t1.c], idxCols [a, b, c]
484// 'curIdxOff2KeyOff' = [0, -1, 2]
485func indexJoinPathTmpInit(
486 sctx planctx.PlanContext,
487 indexJoinInfo *indexJoinPathInfo,
488 idxCols []*expression.Column,
489 colLens []int) *indexJoinPathTmp {
490 tmpSchema := expression.NewSchema(indexJoinInfo.innerJoinKeys...)
491 buildTmp := new(indexJoinPathTmp)
492 buildTmp.curIdxOff2KeyOff = make([]int, len(idxCols))
493 buildTmp.curNotUsedIndexCols = make([]*expression.Column, 0, len(idxCols))
494 buildTmp.curNotUsedColLens = make([]int, 0, len(idxCols))
495 for i, idxCol := range idxCols {
496 buildTmp.curIdxOff2KeyOff[i] = tmpSchema.ColumnIndex(idxCol)
497 if buildTmp.curIdxOff2KeyOff[i] >= 0 {
498 // Don't use the join columns if their collations are unmatched and the new collation is enabled.
499 if collate.NewCollationEnabled() && types.IsString(idxCol.RetType.GetType()) && types.IsString(indexJoinInfo.outerJoinKeys[buildTmp.curIdxOff2KeyOff[i]].RetType.GetType()) {
500 et, err := expression.CheckAndDeriveCollationFromExprs(sctx.GetExprCtx(), "equal", types.ETInt, idxCol, indexJoinInfo.outerJoinKeys[buildTmp.curIdxOff2KeyOff[i]])
501 if err != nil {
502 logutil.BgLogger().Error("Unexpected error happened during constructing index join", zap.Stack("stack"))
503 }
504 if !collate.CompatibleCollate(idxCol.GetStaticType().GetCollate(), et.Collation) {
505 buildTmp.curIdxOff2KeyOff[i] = -1
506 }
507 }
508 continue
509 }
510 buildTmp.curNotUsedIndexCols = append(buildTmp.curNotUsedIndexCols, idxCol)
511 buildTmp.curNotUsedColLens = append(buildTmp.curNotUsedColLens, colLens[i])
512 }
513 return buildTmp
514}
515
516// indexJoinPathFindUsefulEQIn analyzes the PushedDownConds held by inner child and split them to three parts.
517// usefulEqOrInFilters is the continuous eq/in conditions on current unused index columns.

Callers 1

indexJoinPathBuildFunction · 0.85

Calls 12

ColumnIndexMethod · 0.95
NewSchemaFunction · 0.92
NewCollationEnabledFunction · 0.92
IsStringFunction · 0.92
BgLoggerFunction · 0.92
CompatibleCollateFunction · 0.92
GetTypeMethod · 0.65
GetExprCtxMethod · 0.65
ErrorMethod · 0.65
GetCollateMethod · 0.45
GetStaticTypeMethod · 0.45

Tested by

no test coverage detected