diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-01-24 16:32:18 -0700 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-01-24 16:32:18 -0700 |
commit | 73ab1d420dedd965ebe6f814dcf016c8e10879f2 (patch) | |
tree | 2a025e8e8daeaba34953c6b92b83bd579c83962b /lnode.go | |
parent | TODO (diff) | |
download | dedo-73ab1d420dedd965ebe6f814dcf016c8e10879f2.tar.gz dedo-73ab1d420dedd965ebe6f814dcf016c8e10879f2.tar.xz |
TODO
Diffstat (limited to 'lnode.go')
-rw-r--r-- | lnode.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lnode.go b/lnode.go new file mode 100644 index 0000000..9e457b6 --- /dev/null +++ b/lnode.go @@ -0,0 +1,30 @@ +package bolt + +import ( + "unsafe" +) + +type nodeid uint16 + +// lnode represents a node on a leaf page. +type lnode struct { + flags uint16 + keySize uint16 + dataSize uint32 + data uintptr // Pointer to the beginning of the data. +} + +// key returns a byte slice that of the node key. +func (n *lnode) key() []byte { + return (*[MaxKeySize]byte)(unsafe.Pointer(&n.data))[:n.keySize] +} + +// data returns a byte slice that of the node data. +func (n *lnode) data() []byte { + return (*[MaxKeySize]byte)(unsafe.Pointer(&n.data))[n.keySize : n.keySize+n.dataSize] +} + +// lnodeSize returns the number of bytes required to store a key+data as a leaf node. +func lnodeSize(key []byte, data []byte) int { + return int(unsafe.Offsetof((*lnode)(nil)).data) + len(key) + len(data) +} |