aboutsummaryrefslogtreecommitdiff
path: root/lnode.go
blob: dd6f494ea5315b06c30a955a3a18804815f3f1dd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package bolt

import (
	"unsafe"
)

const lnodeSize = int(unsafe.Sizeof(lnode{}))

// lnode represents a node on a leaf page.
type lnode struct {
	flags uint32
	pos   uint32
	ksize uint32
	vsize uint32
}

// 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]
}

// 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]
}