Skip to content

Commit e04f61d

Browse files
authored
Merge pull request pingcap#5 from hanfei1991/join-merge-pass-test
pass unit tests
2 parents 7774284 + ed3065d commit e04f61d

File tree

8 files changed

+21
-27
lines changed

8 files changed

+21
-27
lines changed

executor/builder.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2314,7 +2314,6 @@ func (b *executorBuilder) buildTableReader(v *plannercore.PhysicalTableReader) *
23142314
}
23152315

23162316
ts := v.GetTableScan()
2317-
logutil.BgLogger().Info("build table reader", zap.Int64("my table id", ts.Table.ID), zap.String("table name", ts.Table.Name.L), zap.String("range str", ts.Ranges[0].String()))
23182317
ret.ranges = ts.Ranges
23192318
sctx := b.ctx.GetSessionVars().StmtCtx
23202319
sctx.TableIDs = append(sctx.TableIDs, ts.Table.ID)

executor/table_readers_required_rows_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func buildMockDAGRequest(sctx sessionctx.Context) *tipb.DAGRequest {
128128
Columns: []*model.ColumnInfo{},
129129
Table: &model.TableInfo{ID: 12345, PKIsHandle: false},
130130
Desc: false,
131-
}})
131+
}}, kv.TiKV)
132132
if err != nil {
133133
panic(err)
134134
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/pingcap/tidb
22

33
replace github.com/pingcap/tipb v0.0.0-20200212061130-c4d518eb1d60 => github.com/hanfei1991/tipb v0.0.0-20200308103915-5f3b53798f00
44

5-
replace github.com/pingcap/parser v0.0.0-20200326020624-68d423641be5 => github.com/windtalker/parser v0.0.0-20200330084704-cc2bee1a3633
5+
replace github.com/pingcap/parser v0.0.0-20200407074807-436f1c8c4cff => github.com/hanfei1991/parser v0.0.0-20200420101937-63e37f36ae0c
66

77
require (
88
github.com/BurntSushi/toml v0.3.1

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqC
163163
github.com/gtank/cryptopasta v0.0.0-20170601214702-1f550f6f2f69/go.mod h1:YLEMZOtU+AZ7dhN9T/IpGhXVGly2bvkJQ+zxj3WeVQo=
164164
github.com/hanfei1991/parser v0.0.0-20200307135251-fda93fd3e461 h1:0PegpI/0sFxkvKSRj8MT6NG4DpqoT7oVWMnO9hyBd9U=
165165
github.com/hanfei1991/parser v0.0.0-20200307135251-fda93fd3e461/go.mod h1:9v0Edh8IbgjGYW2ArJr19E+bvL8zKahsFp+ixWeId+4=
166+
github.com/hanfei1991/parser v0.0.0-20200420095648-f4bcaaa96aa8 h1:JwAXZcOCNZ1Jb9qzDZu19N/sUdg6aTq6mZrNZDbu6V0=
167+
github.com/hanfei1991/parser v0.0.0-20200420095648-f4bcaaa96aa8/go.mod h1:9v0Edh8IbgjGYW2ArJr19E+bvL8zKahsFp+ixWeId+4=
168+
github.com/hanfei1991/parser v0.0.0-20200420101937-63e37f36ae0c h1:akJYnz7Fe6AXtCTcZai3gf+HrZxuoVbnaGXxEmtxvpo=
169+
github.com/hanfei1991/parser v0.0.0-20200420101937-63e37f36ae0c/go.mod h1:9v0Edh8IbgjGYW2ArJr19E+bvL8zKahsFp+ixWeId+4=
166170
github.com/hanfei1991/tipb v0.0.0-20200308103915-5f3b53798f00 h1:wRO6S3mWrAcoS78mGn1hvjPQjqTgA+MBzbq5NkKRQRM=
167171
github.com/hanfei1991/tipb v0.0.0-20200308103915-5f3b53798f00/go.mod h1:nPMpOLbGpW71jAalpqgYYjMAZfCGk+DdSPhoIVVizkU=
168172
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=

planner/core/exhaust_physical_plans.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ func (p *LogicalJoin) tryToGetBroadCastJoin(prop *property.PhysicalProperty) []P
15191519
preferredBuildIndex = 1
15201520
}
15211521
preferredGlobalIndex := preferredBuildIndex
1522-
if prop.TaskTp != property.CopTiFlashGlobalReadTaskType && getAllDataSourceTotalRowSize(p.children[preferredGlobalIndex]) > getAllDataSourceTotalRowSize(p.children[1 - preferredGlobalIndex]) {
1522+
if prop.TaskTp != property.CopTiFlashGlobalReadTaskType && getAllDataSourceTotalRowSize(p.children[preferredGlobalIndex]) > getAllDataSourceTotalRowSize(p.children[1-preferredGlobalIndex]) {
15231523
preferredGlobalIndex = 1 - preferredGlobalIndex
15241524
}
15251525
// todo: currently, build side is the one has less rowcount and global read side
@@ -1815,7 +1815,10 @@ func (la *LogicalAggregation) getHashAggs(prop *property.PhysicalProperty) []Phy
18151815
return nil
18161816
}
18171817
hashAggs := make([]PhysicalPlan, 0, len(prop.GetAllPossibleChildTaskTypes()))
1818-
taskTypes := []property.TaskType{property.CopSingleReadTaskType, property.CopDoubleReadTaskType, property.CopTiFlashLocalReadTaskType}
1818+
taskTypes := []property.TaskType{property.CopSingleReadTaskType, property.CopDoubleReadTaskType}
1819+
if la.ctx.GetSessionVars().AllowBCJ {
1820+
taskTypes = append(taskTypes, property.CopTiFlashLocalReadTaskType)
1821+
}
18191822
if la.HasDistinct() {
18201823
// TODO: remove this logic after the cost estimation of distinct pushdown is implemented.
18211824
// If AllowDistinctAggPushDown is set to true, we should not consider RootTask.

planner/core/find_best_task.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func (p *baseLogicalPlan) findBestTask(prop *property.PhysicalProperty) (bestTas
190190
// combine best child tasks with parent physical plan.
191191
curTask := pp.attach2Task(childTasks...)
192192

193-
if prop.TaskTp == property.CopTiFlashLocalReadTaskType || prop.TaskTp == property.CopTiFlashGlobalReadTaskType {
193+
if prop.IsFlashOnlyProp() {
194194
if _, ok := curTask.(*copTask); !ok {
195195
continue
196196
}
@@ -377,7 +377,7 @@ func (ds *DataSource) skylinePruning(prop *property.PhysicalProperty) []*candida
377377
currentCandidate = ds.getTableCandidate(path, prop)
378378
}
379379
} else {
380-
if !path.IsGlobalRead {
380+
if !path.IsGlobalRead && !prop.IsFlashOnlyProp() {
381381
currentCandidate = ds.getTableCandidate(path, prop)
382382
}
383383
}
@@ -1112,18 +1112,12 @@ func (ds *DataSource) convertToTableScan(prop *property.PhysicalProperty, candid
11121112
tblColHists: ds.TblColHists,
11131113
cst: cost,
11141114
}
1115-
if ts.StoreType == kv.TiFlash {
1116-
if prop.TaskTp != property.CopTiFlashLocalReadTaskType && prop.TaskTp != property.RootTaskType && prop.TaskTp != property.CopTiFlashGlobalReadTaskType {
1117-
logutil.BgLogger().Error("invalid task:", zap.String("type", prop.TaskTp.String()))
1118-
return invalidTask, nil
1119-
}
1120-
}
11211115
task = copTask
11221116
if candidate.isMatchProp {
11231117
copTask.keepOrder = true
11241118
}
11251119
ts.addPushedDownSelection(copTask, ds.stats.ScaleByExpectCnt(prop.ExpectedCnt))
1126-
if (prop.TaskTp == property.CopTiFlashGlobalReadTaskType || prop.TaskTp == property.CopTiFlashLocalReadTaskType) && len(copTask.rootTaskConds) != 0 {
1120+
if prop.IsFlashOnlyProp() && len(copTask.rootTaskConds) != 0 {
11271121
return invalidTask, nil
11281122
}
11291123
if prop.TaskTp == property.RootTaskType {

planner/core/task.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
package core
1515

1616
import (
17-
"github.com/pingcap/tidb/util/logutil"
18-
"go.uber.org/zap"
1917
"math"
2018

2119
"github.com/pingcap/parser/ast"
@@ -101,7 +99,6 @@ func (t *copTask) copy() task {
10199
}
102100

103101
func (t *copTask) plan() PhysicalPlan {
104-
//logutil.BgLogger().Info("index finish", zap.Bool("index finish", t.indexPlanFinished), zap.Bool("table is nil?", t.tablePlan == nil))
105102
if t.indexPlanFinished {
106103
return t.tablePlan
107104
}
@@ -525,12 +522,10 @@ func (p *PhysicalHashJoin) attach2Task(tasks ...task) task {
525522
lTask := finishCopTask(p.ctx, tasks[0].copy())
526523
rTask := finishCopTask(p.ctx, tasks[1].copy())
527524
p.SetChildren(lTask.plan(), rTask.plan())
528-
p.schema = BuildPhysicalJoinSchema(p.JoinType, p)
529525
task := &rootTask{
530526
p: p,
531527
cst: lTask.cost() + rTask.cost() + p.GetCost(lTask.count(), rTask.count()),
532528
}
533-
logutil.BgLogger().Info("hash join cost", zap.Float64("hj cost", task.cst))
534529
return task
535530
}
536531

@@ -603,13 +598,12 @@ func (p *PhysicalBroadCastJoin) attach2Task(tasks ...task) task {
603598
}
604599
}
605600

606-
task := & copTask {
607-
tblColHists: rTask.tblColHists,
601+
task := &copTask{
602+
tblColHists: rTask.tblColHists,
608603
indexPlanFinished: true,
609-
tablePlan: p,
610-
cst: lCost + rCost + p.GetCost(lTask.count(), rTask.count()),
604+
tablePlan: p,
605+
cst: lCost + rCost + p.GetCost(lTask.count(), rTask.count()),
611606
}
612-
logutil.BgLogger().Info("bc join cost", zap.Float64("bc cost", task.cst))
613607
return task
614608
}
615609

store/tikv/region_cache.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ type RegionCache struct {
216216
}
217217
storeMu struct {
218218
sync.RWMutex
219-
stores map[uint64]*Store
219+
stores map[uint64]*Store
220220
flashStoreNumber int32
221221
}
222222
notifyDieCh chan []string
@@ -955,7 +955,7 @@ func (c *RegionCache) getStoreAddr(bo *Backoffer, region *Region, store *Store,
955955
addr, err = store.initResolve(bo, c)
956956
if store.storeType == kv.TiFlash {
957957
c.storeMu.Lock()
958-
if _,exists := c.storeMu.stores[store.storeID]; exists {
958+
if _, exists := c.storeMu.stores[store.storeID]; exists {
959959
c.storeMu.flashStoreNumber++
960960
}
961961
c.storeMu.Unlock()
@@ -1380,7 +1380,7 @@ func (s *Store) reResolve(c *RegionCache) {
13801380
newStore := &Store{storeID: s.storeID, addr: addr, storeType: storeType}
13811381
newStore.state = *(*uint64)(unsafe.Pointer(&state))
13821382
c.storeMu.Lock()
1383-
orgStore,exists := c.storeMu.stores[newStore.storeID]
1383+
orgStore, exists := c.storeMu.stores[newStore.storeID]
13841384
if exists && orgStore.storeType == kv.TiFlash {
13851385
c.storeMu.flashStoreNumber--
13861386
}

0 commit comments

Comments
 (0)