-
Notifications
You must be signed in to change notification settings - Fork 379
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
add mmaped b+ tree #207
add mmaped b+ tree #207
Conversation
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.
Reviewed 2 of 2 files at r6.
Reviewable status: 1 of 2 files reviewed, 6 unresolved discussions (waiting on @jarifibrahim, @manishrjain, @martinmr, and @NamanJain8)
z/btree.go, line 29 at r6 (raw file):
nextPage: 1, } t.newNode(0)
Add a comment here saying that this is the root.
z/btree.go, line 31 at r6 (raw file):
t.newNode(0) // This acts as the rightmost pointer (all the keys are <= this key). // This is necessary for B+ tree property that, all leaf nodes should
Remove comment about B+ tree property.
z/btree.go, line 64 at r6 (raw file):
func (t *Tree) Set(k, v uint64) { if k == math.MaxUint64 || k == 0 { panic("Does not support setting MaxUint64/Zero")
setting zero or MaxUint64.
z/btree.go, line 237 at r6 (raw file):
func (n node) uint32(start int) uint32 { return *(*uint32)(unsafe.Pointer(&n[start])) } func keyOffset(i int) int { return 16 * i } // Last 16 bytes are kept off limits.
Remove this comment.
z/btree.go, line 292 at r6 (raw file):
1000
z/btree.go, line 334 at r6 (raw file):
// If the value is non-zero, move the kv to left. // TODO(naman): Add test for second condition. if v != 0 || k == math.MaxUint64-1 {
Add a comment for this.
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.
Reviewable status: 0 of 2 files reviewed, 6 unresolved discussions (waiting on @jarifibrahim, @manishrjain, @martinmr, and @NamanJain8)
z/btree.go, line 31 at r6 (raw file):
Previously, manishrjain (Manish R Jain) wrote…
Remove comment about B+ tree property.
Done.
z/btree.go, line 64 at r6 (raw file):
Previously, manishrjain (Manish R Jain) wrote…
setting zero or MaxUint64.
Done.
z/btree.go, line 237 at r6 (raw file):
Previously, manishrjain (Manish R Jain) wrote…
Remove this comment.
Done.
z/btree.go, line 334 at r6 (raw file):
Previously, manishrjain (Manish R Jain) wrote…
Add a comment for this.
Not needed now.
This PR adds a custom mmaped B+ tree. This data structure creates a mapping from uint64 to uint64.
Structure of node:
Each node in the node is of size pageSize. Two kinds of nodes. Leaf nodes and internal nodes.
Leaf nodes only contain the data. Internal nodes would contain the key and the offset to the child node.
Internal node would have first entry as:
<0 offset to child>, <1000 offset>, <5000 offset>, and so on...
Leaf nodes would just have: <key, value>, <key, value>, and so on...
Last 16 bytes of the node are off limits.
| pageID (8 bytes) | metaBits (1 byte) | 3 free bytes | numKeys (4 bytes) |
This change is