Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
winoros committed Aug 31, 2018
1 parent 968f347 commit 5c9e133
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions expression/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"time"
"unicode"

"github.com/cznic/mathutil"
"github.com/juju/errors"
"github.com/pingcap/tidb/ast"
"github.com/pingcap/tidb/mysql"
Expand Down Expand Up @@ -451,18 +450,16 @@ func (s *exprStack) len() int {
return len(s.stack)
}

// ColumnSliceIntersect intersects two column slice.
// You need to make sure that at least each element in s2 is unique.
func ColumnSliceIntersect(s1, s2 []*Column) []*Column {
// ColumnSliceIsIntersect checks whether two column slice is intersected.
func ColumnSliceIsIntersect(s1, s2 []*Column) bool {
intSet := map[int64]struct{}{}
for _, col := range s1 {
intSet[col.UniqueID] = struct{}{}
}
result := make([]*Column, 0, mathutil.Min(len(s1), len(s2)))
for _, col := range s2 {
if _, ok := intSet[col.UniqueID]; ok {
result = append(result, col)
return true
}
}
return result
return false
}
2 changes: 1 addition & 1 deletion plan/exhaust_physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ func (p *LogicalJoin) buildFakeEqCondsForIndexJoin(keys, idxCols []*expression.C
remained = make([]expression.Expression, 0, len(innerFilters))
for _, filter := range innerFilters {
affectedCols := expression.ExtractColumns(filter)
if len(expression.ColumnSliceIntersect(affectedCols, usableKeys)) > 0 {
if expression.ColumnSliceIsIntersect(affectedCols, usableKeys) {
remained = append(remained, filter)
continue
}
Expand Down

0 comments on commit 5c9e133

Please sign in to comment.