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)
// KEY=Oid VALUE=uint64
// KEY=zodb.Oid VALUE=uint64
// ---- 8< ----
// Copyright 2014 The b Authors. All rights reserved.
......@@ -7,6 +7,7 @@
// license that can be found in the LICENSE file.
package b
import "zodb"
import (
"fmt"
......@@ -46,7 +47,7 @@ func (p *btTpool) get(cmp Cmp) *Tree {
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.err, x.hit, x.i, x.k, x.q, x.t, x.ver = err, hit, i, k, q, t, ver
return x
......@@ -59,7 +60,7 @@ type (
// 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
c int
......@@ -69,7 +70,7 @@ type (
}
de struct { // d element
k Oid
k zodb.Oid
v uint64
}
......@@ -85,7 +86,7 @@ type (
err error
hit bool
i int
k Oid
k zodb.Oid
q *d
t *Tree
ver int64
......@@ -103,7 +104,7 @@ type (
xe struct { // x element
ch interface{}
k Oid
k zodb.Oid
}
x struct { // index page
......@@ -116,7 +117,7 @@ var ( // R/O zero values
zd d
zde de
ze Enumerator
zk Oid
zk zodb.Oid
zt Tree
zx x
zxe xe
......@@ -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
if i < c {
q.x[c+1].ch = q.x[c].ch
......@@ -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
// true.
func (t *Tree) Delete(k Oid) (ok bool) {
func (t *Tree) Delete(k zodb.Oid) (ok bool) {
pi := -1
var p *x
q := t.r
......@@ -348,8 +349,8 @@ func (t *Tree) extract(q *d, i int) { // (r uint64) {
return
}
func (t *Tree) find(q interface{}, k Oid) (i int, ok bool) {
var mk Oid
func (t *Tree) find(q interface{}, k zodb.Oid) (i int, ok bool) {
var mk zodb.Oid
l := 0
switch x := q.(type) {
case *x:
......@@ -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
// (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 {
q := &q.d[0]
k, v = q.k, q.v
......@@ -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
// 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
if q == nil {
return
......@@ -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++
c := q.c
if i < c {
......@@ -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
// (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 {
q := &q.d[q.c-1]
k, v = q.k, q.v
......@@ -450,7 +451,7 @@ func (t *Tree) Len() int {
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++
l, r := p.siblings(pi)
......@@ -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.
// ok reports if k == item.key The Enumerator's position is possibly after the
// 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
if q == nil {
e = btEPool.get(nil, false, 0, k, nil, t, t.ver)
......@@ -531,7 +532,7 @@ func (t *Tree) SeekLast() (e *Enumerator, err error) {
}
// 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())
//defer func() {
// dbg("--- POST\n%s\n====\n", t.dump())
......@@ -593,10 +594,10 @@ func (t *Tree) Set(k Oid, v uint64) {
//
// 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.
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
var p *x
q := t.r
......@@ -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++
r := btDPool.Get().(*d)
if q.n != nil {
......@@ -824,7 +825,7 @@ func (e *Enumerator) Close() {
// 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 ==
// 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 {
return
}
......@@ -878,7 +879,7 @@ func (e *Enumerator) next() error {
// 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
// == 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 {
return
}
......
......@@ -5,11 +5,15 @@ Bdir=`go list -f '{{.Dir}}' $b`
Brev=`cd $Bdir && git describe --always`
out=fsbtree.go
KEY=Oid
KEY=zodb.Oid
VALUE=uint64
echo "// DO NOT EDIT - AUTOGENERATED (by gen-fsbtree from $b $Brev)" >$out
echo "// KEY=$KEY VALUE=$VALUE" >>$out
echo "// ---- 8< ----" >>$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