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

expression: implement vectorized evaluation for builtinLocate3ArgsSig #12510

Merged
merged 12 commits into from
Oct 14, 2019

Conversation

b41sh
Copy link
Member

@b41sh b41sh commented Oct 1, 2019

What problem does this PR solve?

Implement vectorized evaluation for builtinLocate3ArgsSig.
12106

What is changed and how it works?

goos: darwin
goarch: amd64
pkg: github.com/pingcap/tidb/expression
BenchmarkVectorizedBuiltinStringFunc/builtinLocate3ArgsSig-VecBuiltinFunc-4     5688  213284 ns/op  13488 B/op  932 allocs/op
BenchmarkVectorizedBuiltinStringFunc/builtinLocate3ArgsSig-NonVecBuiltinFunc-4  4701  258709 ns/op  13488 B/op  932 allocs/op

Check List

Tests

  • Unit test
  • Integration test

@sre-bot sre-bot added the contribution This PR is from a community contributor. label Oct 1, 2019
@zz-jason zz-jason requested review from qw4990 and fzhedu October 1, 2019 15:42
@qw4990 qw4990 requested review from zz-jason and Reminiscent October 2, 2019 03:42
@qw4990
Copy link
Contributor

qw4990 commented Oct 2, 2019

/run-unit-test

@codecov
Copy link

codecov bot commented Oct 2, 2019

Codecov Report

Merging #12510 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #12510   +/-   ##
===========================================
  Coverage   80.1145%   80.1145%           
===========================================
  Files           464        464           
  Lines        106500     106500           
===========================================
  Hits          85322      85322           
  Misses        14992      14992           
  Partials       6186       6186

@qw4990
Copy link
Contributor

qw4990 commented Oct 8, 2019

/run-unit-test

Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@XuHuaiyu XuHuaiyu added the status/LGT1 Indicates that a PR has LGTM 1. label Oct 8, 2019
result.MergeNulls(buf, buf1)
i64s := result.Int64s()
for i := 0; i < n; i++ {
if result.IsNull(i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider this case, b.args[2] is null but the result is not null.

mysql> SELECT LOCATE('bar', 'foobarbar', NULL);
+----------------------------------+
| LOCATE('bar', 'foobarbar', NULL) |
+----------------------------------+
|                                0 |
+----------------------------------+
1 row in set (0.00 sec)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My test result is correct

mysql> SELECT LOCATE('bar', 'foobarbar', NULL);
+----------------------------------+
| LOCATE('bar', 'foobarbar', NULL) |
+----------------------------------+
|                             NULL |
+----------------------------------+
1 row in set (0.00 sec)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can args[0] and args[1] be null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, any args is null will result in null

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider this case, b.args[2] is null but the result is not null.

mysql> SELECT LOCATE('bar', 'foobarbar', NULL);
+----------------------------------+
| LOCATE('bar', 'foobarbar', NULL) |
+----------------------------------+
|                                0 |
+----------------------------------+
1 row in set (0.00 sec)

In MySQL 8.x, this SQL returns NULL.

@zz-jason zz-jason removed their request for review October 9, 2019 08:53
Copy link
Contributor

@qw4990 qw4990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@qw4990 qw4990 added status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Oct 14, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Oct 14, 2019

Your auto merge job has been accepted, waiting for 12662

@sre-bot
Copy link
Contributor

sre-bot commented Oct 14, 2019

/run-all-tests

@sre-bot sre-bot merged commit d01dcd5 into pingcap:master Oct 14, 2019
XiaTianliang pushed a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression contribution This PR is from a community contributor. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants