pull/34/head
Ben Johnson 2014-01-28 17:03:52 -05:00
parent da6d48abe9
commit dcc5c661e2
3 changed files with 4 additions and 4 deletions

View File

@ -17,11 +17,11 @@ type lnode struct {
// key returns a byte slice of the node key.
func (n *lnode) key() []byte {
buf := (*[maxAllocSize]byte)(unsafe.Pointer(n))
return buf[n.pos:n.pos+n.ksize]
return buf[n.pos : n.pos+n.ksize]
}
// value returns a byte slice of the node value.
func (n *lnode) value() []byte {
buf := (*[maxAllocSize]byte)(unsafe.Pointer(n))
return buf[n.pos+n.ksize:n.pos+n.ksize+n.vsize]
return buf[n.pos+n.ksize : n.pos+n.ksize+n.vsize]
}

View File

@ -6,7 +6,7 @@ import (
"unsafe"
)
// tpage represents a temporary, in-memory leaf page.
// tpage represents a temporary in-memory leaf page.
// It is deserialized from an memory-mapped page and is not restricted by page size.
type tpage struct {
nodes tnodes

View File

@ -29,7 +29,7 @@ func TestTpageRead(t *testing.T) {
// Insert 2 leaf nodes at the beginning. sizeof(lnode) == 16
nodes := (*[3]lnode)(unsafe.Pointer(&page.ptr))
nodes[0] = lnode{flags: 0, pos: 32, ksize: 3, vsize: 4} // pos = sizeof(lnode) * 2
nodes[0] = lnode{flags: 0, pos: 32, ksize: 3, vsize: 4} // pos = sizeof(lnode) * 2
nodes[1] = lnode{flags: 0, pos: 23, ksize: 10, vsize: 3} // pos = sizeof(lnode) + 3 + 4
// Write data for the nodes at the end.