-
Notifications
You must be signed in to change notification settings - Fork 220
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
Conversation
Signed-off-by: you06 <[email protected]>
Signed-off-by: you06 <[email protected]>
return nil | ||
} | ||
|
||
func (i *SnapIter) setValue() 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.
For boolean returning value function, better to name it like IsValueSet
.
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.
This function actually set the value, and the return boolean of this function is whether set value successful.
What about rename it to trySetValue
?
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.
Perhaps trySetValueRef
is better, also renaming the value
field of SnapIter
to valueRef
, because it dose not own the value content.
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.
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, |
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.
Is there a potential edge case or theoretical scenario where this implementation could lead to unexpected behavior?
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.
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.
[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 |
ref pingcap/tidb#55287
This PR implements Snapshot and other methods of
MemBuffer
interface for ART.