32 lines
612 B
Go
32 lines
612 B
Go
package models
|
|
|
|
import "encoding/binary"
|
|
|
|
const (
|
|
BNODE_NODE = 1
|
|
BNODE_LEAF = 2
|
|
)
|
|
|
|
func (node BNode) btype() uint16 {
|
|
return binary.LittleEndian.Uint16(node[0:2])
|
|
}
|
|
|
|
|
|
func (node BNode) nkeys() uint16 {
|
|
return binary.LittleEndian.Uint16(node[2:4])
|
|
}
|
|
|
|
|
|
func (node BNode) setHeader(btype uint16, nkeys uint16) {
|
|
binary.LittleEndian.PutUint16(node[0:2], btype)
|
|
binary.LittleEndian.PutUint16(node[2:4], nkeys)
|
|
}
|
|
|
|
func (node BNode) getPrt(ids uint16) uint64{
|
|
assert(ids < node.nkeys())
|
|
pos := HEADER + 8*ids
|
|
return binary.LittleEndian.Uint64(node[pos:])
|
|
}
|
|
|
|
func (node BNode) setPtr(idx uint16, val uint64) {
|
|
} |