diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-01-27 10:11:54 -0500 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-01-27 10:11:54 -0500 |
commit | 192649f453af1f1fa79f41f1cfeed296ec51b545 (patch) | |
tree | 1195cb6ca23a6c8a576a8c24d10295ddc1515df6 /lnode.go | |
parent | Initialize transaction/rwtransaction. (diff) | |
download | dedo-192649f453af1f1fa79f41f1cfeed296ec51b545.tar.gz dedo-192649f453af1f1fa79f41f1cfeed296ec51b545.tar.xz |
Intermediate.
Diffstat (limited to 'lnode.go')
-rw-r--r-- | lnode.go | 25 |
1 files changed, 10 insertions, 15 deletions
@@ -4,27 +4,22 @@ import ( "unsafe" ) -type nodeid uint16 +const lnodeSize = int(unsafe.Sizeof(lnode{})) // 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. + flags uint32 + pos uint32 + ksize uint32 + vsize uint32 } -// key returns a byte slice that of the node key. +// key returns a byte slice of the node key. func (n *lnode) key() []byte { - return (*[MaxKeySize]byte)(unsafe.Pointer(&n.data))[:n.keySize] + return (*[MaxKeySize]byte)(unsafe.Pointer(&n))[n.pos : n.pos+n.ksize] } -// 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) +// value returns a byte slice of the node value. +func (n *lnode) value() []byte { + return (*[MaxKeySize]byte)(unsafe.Pointer(&n))[n.pos+n.ksize : n.pos+n.ksize+n.vsize] } |