aboutsummaryrefslogtreecommitdiff
path: root/page.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-01-27 10:11:54 -0500
committerBen Johnson <benbjohnson@yahoo.com>2014-01-27 10:11:54 -0500
commit192649f453af1f1fa79f41f1cfeed296ec51b545 (patch)
tree1195cb6ca23a6c8a576a8c24d10295ddc1515df6 /page.go
parentInitialize transaction/rwtransaction. (diff)
downloaddedo-192649f453af1f1fa79f41f1cfeed296ec51b545.tar.gz
dedo-192649f453af1f1fa79f41f1cfeed296ec51b545.tar.xz
Intermediate.
Diffstat (limited to 'page.go')
-rw-r--r--page.go27
1 files changed, 15 insertions, 12 deletions
diff --git a/page.go b/page.go
index c26b957..2910d54 100644
--- a/page.go
+++ b/page.go
@@ -4,12 +4,11 @@ import (
"unsafe"
)
-const maxPageSize = 0x8000
-const minKeyCount = 2
-
-const pageHeaderSize = int(unsafe.Offsetof(((*page)(nil)).data))
+const pageHeaderSize = int(unsafe.Offsetof(((*page)(nil)).ptr))
-const minPageKeys = 2
+const maxPageSize = 0x8000
+const minKeysPerPage = 2
+const maxNodesPerPage = 65535
const fillThreshold = 250 // 25%
const (
@@ -21,12 +20,11 @@ const (
type pgid uint64
type page struct {
- id pgid
- flags uint32
- lower uint16
- upper uint16
- count uint32
- data uintptr
+ id pgid
+ flags uint16
+ count uint16
+ overflow uint32
+ ptr uintptr
}
// meta returns a pointer to the metadata section of the page.
@@ -52,5 +50,10 @@ func (p *page) init(pageSize int) {
m.version = version
m.pageSize = uint32(pageSize)
m.pgid = 1
- m.buckets.root = 0
+ m.sys.root = 0
+}
+
+// lnode retrieves the leaf node by index
+func (p *page) lnode(index int) *lnode {
+ return &((*[maxNodesPerPage]lnode)(unsafe.Pointer(&p.ptr)))[index]
}