-
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
first MVCC support #209
first MVCC support #209
Conversation
add a simple mvcc get/scan for kv
pass the golint check.
speed up CI builds
PTAL |
// Next returns the next key in byte-order | ||
func (k Key) Next() Key { | ||
// add \x0 to the end of key | ||
return append(append([]byte(nil), []byte(k)...), 0) |
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 should allocate slice twice?
First allocing a slice with same size with k, then appending 0 also re-allocs another slice with size len(k) + 1 ?
buf := make([]byte, len(k) + 1)
copy(buf, k)
return buf
maybe more efficient, I don't know.
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.
That makes sense.
d60db6a
to
975a746
Compare
} | ||
|
||
// Cmp returns the comparison result of two key, if A > B returns 1, A = B | ||
// returns 0, if A < B returns -1. |
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.
Comment if A > B returns 1, else if A = B returns 0, else returns -1.
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 result will be 0 if a==b, -1 if a < b, and +1 if a > b.
See http://golang.org/pkg/bytes/#Compare
27e80f3
to
20180eb
Compare
Address code review comments
LGTM |
1 similar comment
LGTM |
) | ||
|
||
func init() { | ||
mc.cache = make(map[string]*dbStore) | ||
globalVerProvider = &LocalVersioProvider{} |
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.
LocalVersioProvider -> LocalVersionProvider
TODO (I'll put them in next commits, to avoid a big PR):
the structure of MVCC kv:
Key1 => 3 (newest version)
Key1_3 => ... (value of this version)
Key1_2 => ... (value of this version)
Key2 => 2
Key2_2 => Tombstone (this key is deleted in the version)
Key2_1 => ...
Key3 => 4
Key3_4 => ...