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: implement snapshot get and iterator for ART #1467

Merged
merged 2 commits into from
Sep 25, 2024

Conversation

you06
Copy link
Contributor

@you06 you06 commented Sep 24, 2024

ref pingcap/tidb#55287

This PR implements Snapshot and other methods of MemBuffer interface for ART.

@ti-chi-bot ti-chi-bot bot added dco-signoff: yes Indicates the PR's author has signed the dco. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 24, 2024
return nil
}

func (i *SnapIter) setValue() bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

For boolean returning value function, better to name it like IsValueSet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function actually set the value, and the return boolean of this function is whether set value successful.

What about rename it to trySetValue?

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps trySetValueRef is better, also renaming the value field of SnapIter to valueRef, because it dose not own the value content.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not a big problem, trySetValue is ok too.

@@ -50,7 +50,10 @@ func (t *ART) iter(lowerBound, upperBound []byte, reverse, includeFlags bool) (*
inner: &baseIter{
allocator: &t.allocator,
},
currAddr: arena.BadAddr, // the default value of currAddr is not equal to any valid address
// the default value of currAddr is not equal to any valid address
// arena.BadAddr's idx is maxuint32 - 1, which is impossible in common cases,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a potential edge case or theoretical scenario where this implementation could lead to unexpected behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The currAddr will be set to valid or null address when first time call Next, so the only purpose of BadAddr is to avoid currAddr == endAddr at the beginning.

BadAddr can never appear in valid usages, because the max size of block is set, so the offset maxuint32 is impossible.

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Sep 25, 2024
Copy link

ti-chi-bot bot commented Sep 25, 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

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

ti-chi-bot bot commented Sep 25, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-25 06:20:12.31913758 +0000 UTC m=+1633282.059561520: ☑️ agreed by ekexium.
  • 2024-09-25 06:59:07.275939121 +0000 UTC m=+1635617.016363055: ☑️ agreed by cfzjywxk.

@ti-chi-bot ti-chi-bot bot merged commit 58f3322 into tikv:master Sep 25, 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/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.

3 participants