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

util: Adjust binary collate behavior to do pattern matching in bytes #51113

Merged
merged 9 commits into from
Feb 21, 2024

Conversation

yibin87
Copy link
Contributor

@yibin87 yibin87 commented Feb 18, 2024

What problem does this PR solve?

Issue Number: close #50393

Problem Summary:

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Signed-off-by: yibin <huyibin@pingcap.com>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 18, 2024
Copy link

tiprow bot commented Feb 18, 2024

Hi @yibin87. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

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>
Copy link

codecov bot commented Feb 18, 2024

Codecov Report

Merging #51113 (4e404b0) into master (464a126) will decrease coverage by 17.6920%.
Report is 24 commits behind head on master.
The diff coverage is 91.0256%.

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     
Flag Coverage Δ
integration 36.8515% <83.3333%> (?)
unit 70.3163% <91.0256%> (-1.8625%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 53.9957% <ø> (-2.3172%) ⬇️
parser ∅ <ø> (∅)
br 50.6253% <ø> (+4.3016%) ⬆️

@yibin87
Copy link
Contributor Author

yibin87 commented Feb 18, 2024

/test check-dev2

Copy link

tiprow bot commented Feb 18, 2024

@yibin87: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test check-dev2

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>
@yibin87
Copy link
Contributor Author

yibin87 commented Feb 19, 2024

/test check-dev

Copy link

tiprow bot commented Feb 19, 2024

@yibin87: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test check-dev

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>
@yibin87
Copy link
Contributor Author

yibin87 commented Feb 19, 2024

/cc @windtalker @xzhangxian1008

Signed-off-by: yibin <huyibin@pingcap.com>
@yibin87
Copy link
Contributor Author

yibin87 commented Feb 19, 2024

/cc @xiongjiwei

Copy link

ti-chi-bot bot commented Feb 19, 2024

@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:

/cc @xiongjiwei

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.

@yibin87
Copy link
Contributor Author

yibin87 commented Feb 19, 2024

/cc @YangKeao

@ti-chi-bot ti-chi-bot bot requested a review from YangKeao February 19, 2024 06:26
Copy link
Member

@YangKeao YangKeao left a 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.

pkg/util/collate/bin.go Outdated Show resolved Hide resolved
pkg/util/stringutil/string_util.go Outdated Show resolved Hide resolved
pkg/util/stringutil/string_util.go Show resolved Hide resolved
Signed-off-by: yibin <huyibin@pingcap.com>
Copy link
Member

@YangKeao YangKeao left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Feb 19, 2024
@@ -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{}
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

// 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 {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@windtalker
Copy link
Contributor

And please double check if TiFlash has the same issue

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Feb 20, 2024
Copy link

ti-chi-bot bot commented Feb 20, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-02-19 09:50:17.272062459 +0000 UTC m=+264306.019685569: ☑️ agreed by YangKeao.
  • 2024-02-20 02:33:45.275741967 +0000 UTC m=+324514.023365077: ☑️ agreed by xiongjiwei.

Copy link

tiprow bot commented Feb 20, 2024

@yibin87: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
tiprow_fast_test 44d0ef8 link true /test tiprow_fast_test

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.

Copy link
Contributor

@xzhangxian1008 xzhangxian1008 left a 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>
@yibin87 yibin87 changed the title util: Add new pure binary collate to do pattern matching in bytes util: Adjust binary collate behavior to do pattern matching in bytes Feb 21, 2024
@yibin87
Copy link
Contributor Author

yibin87 commented Feb 21, 2024

And please double check if TiFlash has the same issue

The same issue detected in TiFlash, filed a issue to track it: pingcap/tiflash#8776

Copy link
Contributor

@windtalker windtalker left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

ti-chi-bot bot commented Feb 21, 2024

[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:
  • OWNERS [YangKeao,windtalker,xiongjiwei]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot merged commit 2041d49 into pingcap:master Feb 21, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Join between blob type with matching returns incorrect result.
5 participants