-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
util: Adjust binary collate behavior to do pattern matching in bytes #51113
Conversation
Signed-off-by: yibin <huyibin@pingcap.com>
Hi @yibin87. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Signed-off-by: yibin <huyibin@pingcap.com>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #51113 +/- ##
=================================================
- Coverage 72.3189% 54.6270% -17.6920%
=================================================
Files 1467 1576 +109
Lines 361663 605400 +243737
=================================================
+ Hits 261551 330712 +69161
- Misses 80822 251623 +170801
- Partials 19290 23065 +3775
Flags with carried forward coverage won't be shown. Click here to find out more.
|
/test check-dev2 |
@yibin87: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Signed-off-by: yibin <huyibin@pingcap.com>
Signed-off-by: yibin <huyibin@pingcap.com>
/test check-dev |
@yibin87: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Signed-off-by: yibin <huyibin@pingcap.com>
Signed-off-by: yibin <huyibin@pingcap.com>
Signed-off-by: yibin <huyibin@pingcap.com>
/cc @xiongjiwei |
@yibin87: GitHub didn't allow me to request PR reviews from the following users: xiongjiwei. Note that only pingcap members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/cc @YangKeao |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM.
BTW, I have checked that the behavior of TiKV is correct 👍 . It decodes the character according to the charset.
Signed-off-by: yibin <huyibin@pingcap.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
pkg/util/collate/collate.go
Outdated
@@ -400,8 +400,8 @@ func init() { | |||
newCollatorMap = make(map[string]Collator) | |||
newCollatorIDMap = make(map[int]Collator) | |||
|
|||
newCollatorMap["binary"] = &binCollator{} | |||
newCollatorIDMap[CollationName2ID("binary")] = &binCollator{} | |||
newCollatorMap["binary"] = &binPureCollator{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about rename binPureCollator
to binaryCollator
since in TiDB/MySQL binary
and xxx_bin
is different collators, and this collator is for binary
so there is no need to use a name like binPure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
pkg/util/stringutil/string_util.go
Outdated
func CompilePatternBytes(pattern string, escape byte) (patChars, patTypes []byte) { | ||
patWeights, patTypes := CompilePatternInner(pattern, escape) | ||
patChars = []byte(string(patWeights)) | ||
|
||
return patChars, patTypes | ||
} | ||
|
||
// CompilePattern is a adapter for `CompilePatternInner`, `pattern` can be any unicode string. | ||
// CompilePatternPureBytes is used for binary strings. | ||
func CompilePatternPureBytes(pattern string, escape byte) (patChars, patTypes []byte) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about rename
CompilePatternPureBytes
to CompilePatternBinary
and
CompilePatternInnerBytes
to CompilePatternInnerBinary
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
pkg/util/stringutil/string_util.go
Outdated
// DoMatchInner matches the string with patChars and patTypes. | ||
// The algorithm has linear time complexity. | ||
// https://research.swtch.com/glob | ||
func DoMatchInner(lenPatWeights int, lenChars int, patTypes []byte, matcher func(a, b int) bool) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If DoMatchInner
is not used by other package, we can make it as a private function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
And please double check if TiFlash has the same issue |
[LGTM Timeline notifier]Timeline:
|
@yibin87: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: yibin <huyibin@pingcap.com>
The same issue detected in TiFlash, filed a issue to track it: pingcap/tiflash#8776 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: windtalker, xiongjiwei, xzhangxian1008, YangKeao The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What problem does this PR solve?
Issue Number: close #50393
Problem Summary:
What changed and how does it work?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.