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 /bnode.go | |
parent | TODO (diff) | |
download | dedo-73ab1d420dedd965ebe6f814dcf016c8e10879f2.tar.gz dedo-73ab1d420dedd965ebe6f814dcf016c8e10879f2.tar.xz |
TODO
Diffstat (limited to 'bnode.go')
-rw-r--r-- | bnode.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/bnode.go b/bnode.go new file mode 100644 index 0000000..d272e93 --- /dev/null +++ b/bnode.go @@ -0,0 +1,23 @@ +package bolt + +import ( + "unsafe" +) + +// bnode represents a node on a branch page. +type bnode struct { + flags uint16 + keySize uint16 + pgid pgid + data uintptr // Pointer to the beginning of the data. +} + +// key returns a byte slice that of the key data. +func (n *bnode) key() []byte { + return (*[MaxKeySize]byte)(unsafe.Pointer(&n.data))[:n.keySize] +} + +// bnodeSize returns the number of bytes required to store a key as a branch node. +func bnodeSize(key []byte) int { + return int(unsafe.Offsetof((*bnode)(nil)).data) + len(key) +} |