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

membuffer: improve ART's code and test coverage #1477

Merged
merged 15 commits into from
Oct 31, 2024

Conversation

you06
Copy link
Contributor

@you06 you06 commented Oct 16, 2024

ref pingcap/tidb#55287
This PR tries to make the code simplify and increase the test coverage (only some unreachable paths are not covered).

Signed-off-by: you06 <[email protected]>
Signed-off-by: you06 <[email protected]>
Signed-off-by: you06 <[email protected]>
Signed-off-by: you06 <[email protected]>
Signed-off-by: you06 <[email protected]>
@ti-chi-bot ti-chi-bot bot added dco-signoff: yes Indicates the PR's author has signed the dco. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 16, 2024
internal/unionstore/art/art_iterator.go Outdated Show resolved Hide resolved
internal/unionstore/art/art_iterator.go Outdated Show resolved Hide resolved
internal/unionstore/art/art_iterator.go Outdated Show resolved Hide resolved
internal/unionstore/art/art_iterator.go Outdated Show resolved Hide resolved
internal/unionstore/art/art_iterator.go Show resolved Hide resolved
internal/unionstore/art/art.go Outdated Show resolved Hide resolved
internal/unionstore/art/art.go Outdated Show resolved Hide resolved
internal/unionstore/art/art.go Outdated Show resolved Hide resolved
@@ -300,11 +306,7 @@ func (t *ART) expandLeaf(key artKey, depth uint32, prev, current artNode) (arena
newAn.addChild(&t.allocator, l2Key.charAt(int(depth)), !l2Key.valid(int(depth)), leaf2Addr)

// swap the old leaf with the new node4.
if prev == nullArtNode {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can we remove the check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the root node can't be a leaf, so when we expanding a leaf, the prev node is definitely not null.

Consider this case:

1. t.root == nullArtNode
2. insert a key [1, 2], t.root becomes a node4
3. insert a key [1, 3], t.root.findChild(1) is a leaf, so expandLeaf will be invoked, prev is t.root now

Signed-off-by: you06 <[email protected]>
Signed-off-by: you06 <[email protected]>
internal/unionstore/art/art_iterator.go Outdated Show resolved Hide resolved
internal/unionstore/art/art_iterator.go Outdated Show resolved Hide resolved
internal/unionstore/art/art_iterator.go Outdated Show resolved Hide resolved
internal/unionstore/art/art_iterator.go Show resolved Hide resolved
Copy link
Contributor

@ekexium ekexium left a comment

Choose a reason for hiding this comment

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

Some minor grammar tweaks would make these comments better. May let LLM do this.

@@ -212,6 +212,14 @@ func (e *ErrTxnTooLarge) Error() string {
return fmt.Sprintf("txn too large, size: %v.", e.Size)
}

type ErrKeyTooLarge struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Kind reminder: TiDB should have corresponding conversions.

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Oct 29, 2024
Signed-off-by: you06 <[email protected]>
internal/unionstore/art/art_iterator.go Show resolved Hide resolved
internal/unionstore/art/art_iterator.go Outdated Show resolved Hide resolved
internal/unionstore/art/art_iterator.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Oct 30, 2024
Signed-off-by: you06 <[email protected]>
@ti-chi-bot ti-chi-bot bot removed the lgtm label Oct 30, 2024
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Oct 30, 2024
@cfzjywxk cfzjywxk requested a review from ekexium October 30, 2024 12:42
@cfzjywxk
Copy link
Contributor

@ekexium PTAL again

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

ti-chi-bot bot commented Oct 31, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfzjywxk, ekexium

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

ti-chi-bot bot commented Oct 31, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-10-29 04:31:11.664201369 +0000 UTC m=+324184.503356909: ☑️ agreed by ekexium.
  • 2024-10-30 09:03:18.419791509 +0000 UTC m=+426911.258947320: ☑️ agreed by cfzjywxk.
  • 2024-10-30 10:00:00.637676742 +0000 UTC m=+430313.476832288: ✖️🔁 reset by you06-pingcap.
  • 2024-10-30 12:42:05.032249396 +0000 UTC m=+440037.871404942: ☑️ agreed by cfzjywxk.
  • 2024-10-31 01:33:18.219568732 +0000 UTC m=+486311.058724278: ☑️ agreed by ekexium.

@ti-chi-bot ti-chi-bot bot merged commit 0232600 into tikv:master Oct 31, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants