Commit de0b06ea authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 847e447a
......@@ -43,8 +43,8 @@ const KeyMin Key = math.MinInt64
type setOid = set.Oid
// kstr formats key as string.
func kstr(k Key) string {
// KStr formats key as string.
func KStr(k Key) string {
if k == KeyMin {
return "-∞"
}
......
......@@ -380,11 +380,11 @@ func (S RangedKeySet) String() string {
func (r KeyRange) String() string {
var shi string
if r.Hi_ == KeyMax {
shi = kstr(r.Hi_) // ∞
shi = KStr(r.Hi_) // ∞
} else {
shi = fmt.Sprintf("%d", r.Hi_+1)
}
return fmt.Sprintf("[%s,%s)", kstr(r.Lo), shi)
return fmt.Sprintf("[%s,%s)", KStr(r.Lo), shi)
}
......
......@@ -995,29 +995,6 @@ func pop(nodeStk *[]*nodeInRange) *nodeInRange {
return top
}
// pathEqual returns whether two paths are the same.
func pathEqual(patha, pathb []zodb.Oid) bool {
if len(patha) != len(pathb) {
return false
}
for i, a := range patha {
if pathb[i] != a {
return false
}
}
return true
}
// vnode returns brief human-readable representation of node.
func vnode(node Node) string {
kind := "?"
switch node.(type) {
case *Tree: kind = "T"
case *Bucket: kind = "B"
}
return kind + node.POid().String()
}
func tracefDiff(format string, argv ...interface{}) {
if traceDiff {
fmt.Printf(format, argv...)
......
......@@ -35,6 +35,9 @@ import (
)
// this file contains only tree types and utilities.
// main code lives in δbtail.go and treediff.go .
// XXX instead of generics
type Tree = blib.Tree
type Bucket = blib.Bucket
......@@ -59,7 +62,6 @@ type setTid = set.Tid
// nodePathToPath converts path from []Node to []Oid.
// XXX place = ? -> δbtail.go/treediff.go (close to pathEqual), or move them both to misc.go
func nodePathToPath(nodePath []Node) (path []zodb.Oid) {
// assert nodePath = Tree Tree ... Tree Bucket
l := len(nodePath)
......@@ -84,16 +86,32 @@ func nodePathToPath(nodePath []Node) (path []zodb.Oid) {
return path
}
// kstr formats key as string.
func kstr(k Key) string {
if k == KeyMin {
return "-∞"
// pathEqual returns whether two paths are the same.
func pathEqual(patha, pathb []zodb.Oid) bool {
if len(patha) != len(pathb) {
return false
}
if k == KeyMax {
return "∞"
for i, a := range patha {
if pathb[i] != a {
return false
}
}
return fmt.Sprintf("%d", k)
return true
}
// vnode returns brief human-readable representation of node.
func vnode(node Node) string {
kind := "?"
switch node.(type) {
case *Tree: kind = "T"
case *Bucket: kind = "B"
}
return kind + node.POid().String()
}
func kstr(key Key) string {
return blib.KStr(key)
}
func panicf(format string, argv ...interface{}) {
......
......@@ -270,7 +270,7 @@ func (δBtail *ΔBtail) track(key Key, path []zodb.Oid) {
tracefΔBtail("->T: nop\n")
path_ := δBtail.trackSet.Path(leaf)
if !pathEqual(path, path_) {
panicf("BUG: key %s is already tracked via path=%v\ntrack requests path=%v", kstr(key), path_, path)
panicf("BUG: key %s is already tracked via path=%v\ntrack requests path=%v", kstr(key), path_, path)
}
return
}
......@@ -798,7 +798,7 @@ func (δBtail *ΔBtail) GetAt(root zodb.Oid, key Key, at zodb.Tid) (value Value,
panicf("δBtail: root<%s> not tracked", root)
}
// TODO -> index lastRevOf(key) | linear scan ↓ looking for change <= at
// TODO -> index lastRevOf(key) | linear scan ↓ looking for change at
for i := len(δTtail.vδT)-1; i >= 0; i-- {
δT := δTtail.vδT[i]
δvalue, ok_ := δT.KV[key]
......
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