Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ranger: some code clean up #8663

Merged
merged 5 commits into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/explaintest/r/explain_easy.result
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ id count task operator info
Limit_9 1.00 root offset:0, count:1
└─IndexLookUp_17 1.00 root
├─Selection_14 3.00 cop gt(test.t4.b, 1)
│ └─IndexScan_12 9.00 cop table:t4, index:a, b, range:(1 +inf,+inf +inf], keep order:false, stats:pseudo
│ └─IndexScan_12 9.00 cop table:t4, index:a, b, range:(1,+inf], keep order:false, stats:pseudo
└─Limit_16 1.00 cop offset:0, count:1
└─Selection_15 1.00 cop gt(test.t4.c, 1)
└─TableScan_13 3.00 cop table:t4, keep order:false
Expand Down
2 changes: 1 addition & 1 deletion planner/core/physical_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (s *testPlanSuite) TestDAGPlanBuilderSimpleCase(c *C) {
// Test DNF condition + Double Read.
{
sql: "select * from t where (t.c > 0 and t.c < 2) or (t.c > 4 and t.c < 6) or (t.c > 8 and t.c < 10) or (t.c > 12 and t.c < 14) or (t.c > 16 and t.c < 18)",
best: "IndexLookUp(Index(t.c_d_e)[(0 +inf,2 NULL) (4 +inf,6 NULL) (8 +inf,10 NULL) (12 +inf,14 NULL) (16 +inf,18 NULL)], Table(t))",
best: "IndexLookUp(Index(t.c_d_e)[(0,2) (4,6) (8,10) (12,14) (16,18)], Table(t))",
},
{
sql: "select * from t where (t.c > 0 and t.c < 1) or (t.c > 2 and t.c < 3) or (t.c > 4 and t.c < 5) or (t.c > 6 and t.c < 7) or (t.c > 9 and t.c < 10)",
Expand Down
16 changes: 0 additions & 16 deletions util/ranger/ranger.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,22 +333,6 @@ func buildCNFIndexRange(sc *stmtctx.StatementContext, cols []*expression.Column,
fixPrefixColRange(ranges, lengths, newTp)
}

if len(ranges) > 0 && len(ranges[0].LowVal) < len(cols) {
for _, ran := range ranges {
if ran.HighExclude || ran.LowExclude {
if ran.HighExclude {
ran.HighVal = append(ran.HighVal, types.NewDatum(nil))
} else {
ran.HighVal = append(ran.HighVal, types.MaxValueDatum())
}
if ran.LowExclude {
ran.LowVal = append(ran.LowVal, types.MaxValueDatum())
} else {
ran.LowVal = append(ran.LowVal, types.NewDatum(nil))
}
}
}
}
return ranges, nil
}

Expand Down
20 changes: 10 additions & 10 deletions util/ranger/ranger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,14 @@ func (s *testRangerSuite) TestIndexRange(c *C) {
exprStr: `a LIKE 'abc%'`,
accessConds: `[like(test.t.a, abc%, 92)]`,
filterConds: "[]",
resultStr: "[[\"abc\" NULL,\"abd\" NULL)]",
resultStr: "[[\"abc\",\"abd\")]",
},
{
indexPos: 0,
exprStr: "a LIKE 'abc_'",
accessConds: "[like(test.t.a, abc_, 92)]",
filterConds: "[like(test.t.a, abc_, 92)]",
resultStr: "[(\"abc\" +inf,\"abd\" NULL)]",
resultStr: "[(\"abc\",\"abd\")]",
},
{
indexPos: 0,
Expand Down Expand Up @@ -395,7 +395,7 @@ func (s *testRangerSuite) TestIndexRange(c *C) {
exprStr: `a LIKE "\\\\a%"`,
accessConds: `[like(test.t.a, \\a%, 92)]`,
filterConds: "[]",
resultStr: "[[\"\\a\" NULL,\"\\b\" NULL)]",
resultStr: "[[\"\\a\",\"\\b\")]",
},
{
indexPos: 0,
Expand Down Expand Up @@ -444,7 +444,7 @@ func (s *testRangerSuite) TestIndexRange(c *C) {
exprStr: "c not in (1, 2, 3)",
accessConds: "[not(in(test.t.c, 1, 2, 3))]",
filterConds: "[]",
resultStr: "[(NULL +inf,1 NULL) (1 +inf,2 NULL) (2 +inf,3 NULL) (3 +inf,+inf +inf]]",
resultStr: "[(NULL,1) (1,2) (2,3) (3,+inf]]",
},
{
indexPos: 1,
Expand Down Expand Up @@ -500,28 +500,28 @@ func (s *testRangerSuite) TestIndexRange(c *C) {
exprStr: "(a > 'b' and a < 'bbb') or (a < 'cb' and a > 'a')",
accessConds: "[or(and(gt(test.t.a, b), lt(test.t.a, bbb)), and(lt(test.t.a, cb), gt(test.t.a, a)))]",
filterConds: "[]",
resultStr: "[(\"a\" +inf,\"cb\" NULL)]",
resultStr: "[(\"a\",\"cb\")]",
},
{
indexPos: 0,
exprStr: "(a > 'a' and a < 'b') or (a >= 'b' and a < 'c')",
accessConds: "[or(and(gt(test.t.a, a), lt(test.t.a, b)), and(ge(test.t.a, b), lt(test.t.a, c)))]",
filterConds: "[]",
resultStr: "[(\"a\" +inf,\"c\" NULL)]",
resultStr: "[(\"a\",\"c\")]",
},
{
indexPos: 0,
exprStr: "(a > 'a' and a < 'b' and b < 1) or (a >= 'b' and a < 'c')",
accessConds: "[or(and(gt(test.t.a, a), lt(test.t.a, b)), and(ge(test.t.a, b), lt(test.t.a, c)))]",
filterConds: "[or(and(and(gt(test.t.a, a), lt(test.t.a, b)), lt(test.t.b, 1)), and(ge(test.t.a, b), lt(test.t.a, c)))]",
resultStr: "[(\"a\" +inf,\"c\" NULL)]",
resultStr: "[(\"a\",\"c\")]",
},
{
indexPos: 0,
exprStr: "(a in ('a', 'b') and b < 1) or (a >= 'b' and a < 'c')",
accessConds: "[or(and(in(test.t.a, a, b), lt(test.t.b, 1)), and(ge(test.t.a, b), lt(test.t.a, c)))]",
filterConds: "[]",
resultStr: `[["a" -inf,"a" 1) ["b" NULL,"c" NULL)]`,
resultStr: `[["a" -inf,"a" 1) ["b","c")]`,
},
{
indexPos: 0,
Expand Down Expand Up @@ -952,9 +952,9 @@ func (s *testRangerSuite) TestIndexRangeElimininatedProjection(c *C) {
testKit.MustQuery("explain select * from (select * from t union all select ifnull(a,b), b from t) sub where a > 0").Check(testkit.Rows(
"Union_11 2.00 root ",
"├─IndexReader_17 1.00 root index:IndexScan_16",
"│ └─IndexScan_16 1.00 cop table:t, index:a, b, range:(0 +inf,+inf +inf], keep order:false",
"│ └─IndexScan_16 1.00 cop table:t, index:a, b, range:(0,+inf], keep order:false",
"└─IndexReader_23 1.00 root index:IndexScan_22",
" └─IndexScan_22 1.00 cop table:t, index:a, b, range:(0 +inf,+inf +inf], keep order:false",
" └─IndexScan_22 1.00 cop table:t, index:a, b, range:(0,+inf], keep order:false",
))
testKit.MustQuery("select * from (select * from t union all select ifnull(a,b), b from t) sub where a > 0").Check(testkit.Rows(
"1 2",
Expand Down