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

first MVCC support #209

Merged
merged 5 commits into from
Sep 21, 2015
Merged

first MVCC support #209

merged 5 commits into from
Sep 21, 2015

Conversation

c4pt0r
Copy link
Member

@c4pt0r c4pt0r commented Sep 21, 2015

  1. Add MVCC to original interfaces (alway handles newest version).
  2. Add some tests.

TODO (I'll put them in next commits, to avoid a big PR):

  1. Get/Scan specific version.
  2. Compact

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 => ...

@c4pt0r
Copy link
Member Author

c4pt0r commented Sep 21, 2015

@ngaut
@siddontang

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes sense.

@c4pt0r c4pt0r force-pushed the c4pt0r/MVCC-support branch from d60db6a to 975a746 Compare September 21, 2015 05:46
}

// Cmp returns the comparison result of two key, if A > B returns 1, A = B
// returns 0, if A < B returns -1.
Copy link
Member

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.

Copy link
Member

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

@c4pt0r c4pt0r force-pushed the c4pt0r/MVCC-support branch 2 times, most recently from 27e80f3 to 20180eb Compare September 21, 2015 06:37
Address code review comments
@c4pt0r
Copy link
Member Author

c4pt0r commented Sep 21, 2015

@qiuyesuifeng
@ngaut
@siddontang
PTAL

@siddontang
Copy link
Member

LGTM

1 similar comment
@qiuyesuifeng
Copy link
Member

LGTM

c4pt0r added a commit that referenced this pull request Sep 21, 2015
@c4pt0r c4pt0r merged commit aa78175 into master Sep 21, 2015
)

func init() {
mc.cache = make(map[string]*dbStore)
globalVerProvider = &LocalVersioProvider{}
Copy link
Member

Choose a reason for hiding this comment

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

LocalVersioProvider -> LocalVersionProvider

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants