Commit 820f4ac4 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 666f6df1
// DO NOT EDIT - AUTOGENERATED (by gen-fsbtree from github.com/cznic/b bcff30a) // DO NOT EDIT - AUTOGENERATED (by gen-fsbtree from github.com/cznic/b bcff30a)
// KEY=Oid VALUE=uint64 // KEY=zodb.Oid VALUE=uint64
// ---- 8< ---- // ---- 8< ----
// Copyright 2014 The b Authors. All rights reserved. // Copyright 2014 The b Authors. All rights reserved.
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package b package b
import "zodb"
import ( import (
"fmt" "fmt"
...@@ -46,7 +47,7 @@ func (p *btTpool) get(cmp Cmp) *Tree { ...@@ -46,7 +47,7 @@ func (p *btTpool) get(cmp Cmp) *Tree {
type btEpool struct{ sync.Pool } type btEpool struct{ sync.Pool }
func (p *btEpool) get(err error, hit bool, i int, k Oid, q *d, t *Tree, ver int64) *Enumerator { func (p *btEpool) get(err error, hit bool, i int, k zodb.Oid, q *d, t *Tree, ver int64) *Enumerator {
x := p.Get().(*Enumerator) x := p.Get().(*Enumerator)
x.err, x.hit, x.i, x.k, x.q, x.t, x.ver = err, hit, i, k, q, t, ver x.err, x.hit, x.i, x.k, x.q, x.t, x.ver = err, hit, i, k, q, t, ver
return x return x
...@@ -59,7 +60,7 @@ type ( ...@@ -59,7 +60,7 @@ type (
// 0 if a == b // 0 if a == b
// > 0 if a > b // > 0 if a > b
// //
Cmp func(a, b Oid) int Cmp func(a, b zodb.Oid) int
d struct { // data page d struct { // data page
c int c int
...@@ -69,7 +70,7 @@ type ( ...@@ -69,7 +70,7 @@ type (
} }
de struct { // d element de struct { // d element
k Oid k zodb.Oid
v uint64 v uint64
} }
...@@ -85,7 +86,7 @@ type ( ...@@ -85,7 +86,7 @@ type (
err error err error
hit bool hit bool
i int i int
k Oid k zodb.Oid
q *d q *d
t *Tree t *Tree
ver int64 ver int64
...@@ -103,7 +104,7 @@ type ( ...@@ -103,7 +104,7 @@ type (
xe struct { // x element xe struct { // x element
ch interface{} ch interface{}
k Oid k zodb.Oid
} }
x struct { // index page x struct { // index page
...@@ -116,7 +117,7 @@ var ( // R/O zero values ...@@ -116,7 +117,7 @@ var ( // R/O zero values
zd d zd d
zde de zde de
ze Enumerator ze Enumerator
zk Oid zk zodb.Oid
zt Tree zt Tree
zx x zx x
zxe xe zxe xe
...@@ -154,7 +155,7 @@ func (q *x) extract(i int) { ...@@ -154,7 +155,7 @@ func (q *x) extract(i int) {
} }
} }
func (q *x) insert(i int, k Oid, ch interface{}) *x { func (q *x) insert(i int, k zodb.Oid, ch interface{}) *x {
c := q.c c := q.c
if i < c { if i < c {
q.x[c+1].ch = q.x[c].ch q.x[c+1].ch = q.x[c].ch
...@@ -285,7 +286,7 @@ func (t *Tree) catX(p, q, r *x, pi int) { ...@@ -285,7 +286,7 @@ func (t *Tree) catX(p, q, r *x, pi int) {
// Delete removes the k's KV pair, if it exists, in which case Delete returns // Delete removes the k's KV pair, if it exists, in which case Delete returns
// true. // true.
func (t *Tree) Delete(k Oid) (ok bool) { func (t *Tree) Delete(k zodb.Oid) (ok bool) {
pi := -1 pi := -1
var p *x var p *x
q := t.r q := t.r
...@@ -348,8 +349,8 @@ func (t *Tree) extract(q *d, i int) { // (r uint64) { ...@@ -348,8 +349,8 @@ func (t *Tree) extract(q *d, i int) { // (r uint64) {
return return
} }
func (t *Tree) find(q interface{}, k Oid) (i int, ok bool) { func (t *Tree) find(q interface{}, k zodb.Oid) (i int, ok bool) {
var mk Oid var mk zodb.Oid
l := 0 l := 0
switch x := q.(type) { switch x := q.(type) {
case *x: case *x:
...@@ -386,7 +387,7 @@ func (t *Tree) find(q interface{}, k Oid) (i int, ok bool) { ...@@ -386,7 +387,7 @@ func (t *Tree) find(q interface{}, k Oid) (i int, ok bool) {
// First returns the first item of the tree in the key collating order, or // First returns the first item of the tree in the key collating order, or
// (zero-value, zero-value) if the tree is empty. // (zero-value, zero-value) if the tree is empty.
func (t *Tree) First() (k Oid, v uint64) { func (t *Tree) First() (k zodb.Oid, v uint64) {
if q := t.first; q != nil { if q := t.first; q != nil {
q := &q.d[0] q := &q.d[0]
k, v = q.k, q.v k, v = q.k, q.v
...@@ -396,7 +397,7 @@ func (t *Tree) First() (k Oid, v uint64) { ...@@ -396,7 +397,7 @@ func (t *Tree) First() (k Oid, v uint64) {
// Get returns the value associated with k and true if it exists. Otherwise Get // Get returns the value associated with k and true if it exists. Otherwise Get
// returns (zero-value, false). // returns (zero-value, false).
func (t *Tree) Get(k Oid) (v uint64, ok bool) { func (t *Tree) Get(k zodb.Oid) (v uint64, ok bool) {
q := t.r q := t.r
if q == nil { if q == nil {
return return
...@@ -422,7 +423,7 @@ func (t *Tree) Get(k Oid) (v uint64, ok bool) { ...@@ -422,7 +423,7 @@ func (t *Tree) Get(k Oid) (v uint64, ok bool) {
} }
} }
func (t *Tree) insert(q *d, i int, k Oid, v uint64) *d { func (t *Tree) insert(q *d, i int, k zodb.Oid, v uint64) *d {
t.ver++ t.ver++
c := q.c c := q.c
if i < c { if i < c {
...@@ -437,7 +438,7 @@ func (t *Tree) insert(q *d, i int, k Oid, v uint64) *d { ...@@ -437,7 +438,7 @@ func (t *Tree) insert(q *d, i int, k Oid, v uint64) *d {
// Last returns the last item of the tree in the key collating order, or // Last returns the last item of the tree in the key collating order, or
// (zero-value, zero-value) if the tree is empty. // (zero-value, zero-value) if the tree is empty.
func (t *Tree) Last() (k Oid, v uint64) { func (t *Tree) Last() (k zodb.Oid, v uint64) {
if q := t.last; q != nil { if q := t.last; q != nil {
q := &q.d[q.c-1] q := &q.d[q.c-1]
k, v = q.k, q.v k, v = q.k, q.v
...@@ -450,7 +451,7 @@ func (t *Tree) Len() int { ...@@ -450,7 +451,7 @@ func (t *Tree) Len() int {
return t.c return t.c
} }
func (t *Tree) overflow(p *x, q *d, pi, i int, k Oid, v uint64) { func (t *Tree) overflow(p *x, q *d, pi, i int, k zodb.Oid, v uint64) {
t.ver++ t.ver++
l, r := p.siblings(pi) l, r := p.siblings(pi)
...@@ -480,7 +481,7 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k Oid, v uint64) { ...@@ -480,7 +481,7 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k Oid, v uint64) {
// Seek returns an Enumerator positioned on an item such that k >= item's key. // Seek returns an Enumerator positioned on an item such that k >= item's key.
// ok reports if k == item.key The Enumerator's position is possibly after the // ok reports if k == item.key The Enumerator's position is possibly after the
// last item in the tree. // last item in the tree.
func (t *Tree) Seek(k Oid) (e *Enumerator, ok bool) { func (t *Tree) Seek(k zodb.Oid) (e *Enumerator, ok bool) {
q := t.r q := t.r
if q == nil { if q == nil {
e = btEPool.get(nil, false, 0, k, nil, t, t.ver) e = btEPool.get(nil, false, 0, k, nil, t, t.ver)
...@@ -531,7 +532,7 @@ func (t *Tree) SeekLast() (e *Enumerator, err error) { ...@@ -531,7 +532,7 @@ func (t *Tree) SeekLast() (e *Enumerator, err error) {
} }
// Set sets the value associated with k. // Set sets the value associated with k.
func (t *Tree) Set(k Oid, v uint64) { func (t *Tree) Set(k zodb.Oid, v uint64) {
//dbg("--- PRE Set(%v, %v)\n%s", k, v, t.dump()) //dbg("--- PRE Set(%v, %v)\n%s", k, v, t.dump())
//defer func() { //defer func() {
// dbg("--- POST\n%s\n====\n", t.dump()) // dbg("--- POST\n%s\n====\n", t.dump())
...@@ -593,10 +594,10 @@ func (t *Tree) Set(k Oid, v uint64) { ...@@ -593,10 +594,10 @@ func (t *Tree) Set(k Oid, v uint64) {
// //
// tree.Set(k, v) call conceptually equals calling // tree.Set(k, v) call conceptually equals calling
// //
// tree.Put(k, func(Oid, bool){ return v, true }) // tree.Put(k, func(zodb.Oid, bool){ return v, true })
// //
// modulo the differing return values. // modulo the differing return values.
func (t *Tree) Put(k Oid, upd func(oldV uint64, exists bool) (newV uint64, write bool)) (oldV uint64, written bool) { func (t *Tree) Put(k zodb.Oid, upd func(oldV uint64, exists bool) (newV uint64, write bool)) (oldV uint64, written bool) {
pi := -1 pi := -1
var p *x var p *x
q := t.r q := t.r
...@@ -662,7 +663,7 @@ func (t *Tree) Put(k Oid, upd func(oldV uint64, exists bool) (newV uint64, write ...@@ -662,7 +663,7 @@ func (t *Tree) Put(k Oid, upd func(oldV uint64, exists bool) (newV uint64, write
} }
} }
func (t *Tree) split(p *x, q *d, pi, i int, k Oid, v uint64) { func (t *Tree) split(p *x, q *d, pi, i int, k zodb.Oid, v uint64) {
t.ver++ t.ver++
r := btDPool.Get().(*d) r := btDPool.Get().(*d)
if q.n != nil { if q.n != nil {
...@@ -824,7 +825,7 @@ func (e *Enumerator) Close() { ...@@ -824,7 +825,7 @@ func (e *Enumerator) Close() {
// Next returns the currently enumerated item, if it exists and moves to the // Next returns the currently enumerated item, if it exists and moves to the
// next item in the key collation order. If there is no item to return, err == // next item in the key collation order. If there is no item to return, err ==
// io.EOF is returned. // io.EOF is returned.
func (e *Enumerator) Next() (k Oid, v uint64, err error) { func (e *Enumerator) Next() (k zodb.Oid, v uint64, err error) {
if err = e.err; err != nil { if err = e.err; err != nil {
return return
} }
...@@ -878,7 +879,7 @@ func (e *Enumerator) next() error { ...@@ -878,7 +879,7 @@ func (e *Enumerator) next() error {
// Prev returns the currently enumerated item, if it exists and moves to the // Prev returns the currently enumerated item, if it exists and moves to the
// previous item in the key collation order. If there is no item to return, err // previous item in the key collation order. If there is no item to return, err
// == io.EOF is returned. // == io.EOF is returned.
func (e *Enumerator) Prev() (k Oid, v uint64, err error) { func (e *Enumerator) Prev() (k zodb.Oid, v uint64, err error) {
if err = e.err; err != nil { if err = e.err; err != nil {
return return
} }
......
...@@ -5,11 +5,15 @@ Bdir=`go list -f '{{.Dir}}' $b` ...@@ -5,11 +5,15 @@ Bdir=`go list -f '{{.Dir}}' $b`
Brev=`cd $Bdir && git describe --always` Brev=`cd $Bdir && git describe --always`
out=fsbtree.go out=fsbtree.go
KEY=Oid KEY=zodb.Oid
VALUE=uint64 VALUE=uint64
echo "// DO NOT EDIT - AUTOGENERATED (by gen-fsbtree from $b $Brev)" >$out echo "// DO NOT EDIT - AUTOGENERATED (by gen-fsbtree from $b $Brev)" >$out
echo "// KEY=$KEY VALUE=$VALUE" >>$out echo "// KEY=$KEY VALUE=$VALUE" >>$out
echo "// ---- 8< ----" >>$out echo "// ---- 8< ----" >>$out
echo >>$out echo >>$out
make -s -C $Bdir generic |sed -e 's/KEY/Oid/g' -e 's/VALUE/uint64/g' >>$out make -s -C $Bdir generic |sed \
-e '/package b/a import "zodb"' \
-e "s/KEY/$KEY/g" \
-e "s/VALUE/$VALUE/g" \
>>$out
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment