From 73ab1d420dedd965ebe6f814dcf016c8e10879f2 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Fri, 24 Jan 2014 16:32:18 -0700 Subject: TODO --- bnode.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 bnode.go (limited to 'bnode.go') 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) +} -- cgit v1.2.3