Commit de0b06ea authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 847e447a
...@@ -43,8 +43,8 @@ const KeyMin Key = math.MinInt64 ...@@ -43,8 +43,8 @@ const KeyMin Key = math.MinInt64
type setOid = set.Oid type setOid = set.Oid
// kstr formats key as string. // KStr formats key as string.
func kstr(k Key) string { func KStr(k Key) string {
if k == KeyMin { if k == KeyMin {
return "-∞" return "-∞"
} }
......
...@@ -380,11 +380,11 @@ func (S RangedKeySet) String() string { ...@@ -380,11 +380,11 @@ func (S RangedKeySet) String() string {
func (r KeyRange) String() string { func (r KeyRange) String() string {
var shi string var shi string
if r.Hi_ == KeyMax { if r.Hi_ == KeyMax {
shi = kstr(r.Hi_) // ∞ shi = KStr(r.Hi_) // ∞
} else { } else {
shi = fmt.Sprintf("%d", r.Hi_+1) 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 { ...@@ -995,29 +995,6 @@ func pop(nodeStk *[]*nodeInRange) *nodeInRange {
return top 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{}) { func tracefDiff(format string, argv ...interface{}) {
if traceDiff { if traceDiff {
fmt.Printf(format, argv...) fmt.Printf(format, argv...)
......
...@@ -35,6 +35,9 @@ import ( ...@@ -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 // XXX instead of generics
type Tree = blib.Tree type Tree = blib.Tree
type Bucket = blib.Bucket type Bucket = blib.Bucket
...@@ -59,7 +62,6 @@ type setTid = set.Tid ...@@ -59,7 +62,6 @@ type setTid = set.Tid
// nodePathToPath converts path from []Node to []Oid. // 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) { func nodePathToPath(nodePath []Node) (path []zodb.Oid) {
// assert nodePath = Tree Tree ... Tree Bucket // assert nodePath = Tree Tree ... Tree Bucket
l := len(nodePath) l := len(nodePath)
...@@ -84,16 +86,32 @@ func nodePathToPath(nodePath []Node) (path []zodb.Oid) { ...@@ -84,16 +86,32 @@ func nodePathToPath(nodePath []Node) (path []zodb.Oid) {
return path return path
} }
// pathEqual returns whether two paths are the same.
// kstr formats key as string. func pathEqual(patha, pathb []zodb.Oid) bool {
func kstr(k Key) string { if len(patha) != len(pathb) {
if k == KeyMin { return false
return "-∞" }
for i, a := range patha {
if pathb[i] != a {
return false
} }
if k == KeyMax {
return "∞"
} }
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{}) { func panicf(format string, argv ...interface{}) {
......
...@@ -798,7 +798,7 @@ func (δBtail *ΔBtail) GetAt(root zodb.Oid, key Key, at zodb.Tid) (value Value, ...@@ -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) 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-- { for i := len(δTtail.vδT)-1; i >= 0; i-- {
δT := δTtail.vδT[i] δT := δTtail.vδT[i]
δvalue, ok_ := δT.KV[key] δ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