Commit fb56ebad authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent ce8d70fb
......@@ -280,7 +280,7 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node, flags Track
pathv := []string{}
for _, node := range path { pathv = append(pathv, vnode(node)) }
fmt.Printf("Track [%v] %s\n", key, strings.Join(pathv, " -> "))
tracef("Track [%v] %s\n", key, strings.Join(pathv, " -> "))
parent := zodb.InvalidOid
var track nodeTrack
......@@ -342,8 +342,8 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
δBtail.δZtail.Append(δZ.Tid, δZ.Changev)
fmt.Printf("\nUpdate δZ: %v\n", δZ.Changev)
fmt.Printf("trackIdx: %v\n", δBtail.trackIdx)
tracef("\nUpdate δZ: %v\n", δZ.Changev)
tracef("trackIdx: %v\n", δBtail.trackIdx)
δZTC, δtopsByRoot := δBtail.δZConnectTracked(δZ)
......@@ -595,8 +595,8 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
defer xerr.Contextf(&err, "treediff %s..%s %s", zconnOld.At(), zconnNew.At(), root)
// XXX zconnX -> a, b ?
fmt.Printf("treediff %s δtops: %v δZTC: %v\n", root, δtops, δZTC)
defer fmt.Printf("\n")
tracef("treediff %s δtops: %v δZTC: %v\n", root, δtops, δZTC)
defer tracef("\n")
δT = map[Key]ΔValue{}
......@@ -618,7 +618,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
// -> assert that keys from different δtop do not overlap
// DEL k -> Tkextra += k
// +k -> Tkextra -= k
fmt.Printf("-> δtop: %v\n", δtop)
tracef("-> δtop: %v\n", δtop)
for k,δv := range δtop {
δT[k] = δv
}
......@@ -683,11 +683,11 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid, trackIdx map[zodb.Oid]n
//
// XXX trackIdx -> just pass δBtail?
func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]nodeTrack) (δ map[Key]ΔValue, err error) {
fmt.Printf(" T %s %s\n", xidOf(a), xidOf(b))
tracef(" diffT %s %s\n", xidOf(a), xidOf(b))
defer xerr.Contextf(&err, "diffT %s %s", xidOf(a), xidOf(b))
δ = map[Key]ΔValue{}
defer fmt.Printf(" -> δt: %v\n", δ)
defer tracef(" -> δt: %v\n", δ)
var av rangeSplit // nodes expanded from a
var bv rangeSplit // nodes expanded from b
......@@ -790,9 +790,8 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
}
}
fmt.Printf(" av: %s\n", av)
fmt.Printf(" bv: %s\n", bv)
fmt.Printf(" bq: %s\n", Bqueue)
tracef(" av: %s\n", av)
tracef(" bv: %s\n", bv)
// phase 2: iterate through keys queued for A and B, delve into
// corresponding nodes, and merge diff generated from them into δ.
......@@ -801,17 +800,21 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
//
// XXX inefficient: we process each key separately, while they can be
// processed in sorted batches.
for len(Aqueue) > 0 || len(Bqueue) > 0 {
fmt.Printf("\n")
fmt.Printf(" aq: %s\n", Aqueue)
fmt.Printf(" bq: %s\n", Bqueue)
for {
tracef("\n")
tracef(" aq: %s\n", Aqueue)
tracef(" bq: %s\n", Bqueue)
if len(Aqueue) == 0 && len(Bqueue) == 0 {
break
}
// B queue
// expand keys in new δA -> in B till buckets;
// process B buckets that cover new keys into δ+
Aqueue = SetKey{}
for k := range Bqueue {
fmt.Printf(" B [%v]\n", k)
tracef(" B [%v]\n", k)
bnode, ok, err := bv.GetToLeaf(ctx, k)
if err != nil {
return nil, err
......@@ -857,7 +860,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
Bdone.Add(k)
}
fmt.Printf(" bv: %s\n", bv)
tracef(" bv: %s\n", bv)
}
// FIXME update trackIdx
......@@ -891,7 +894,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
// A queue
Bqueue = SetKey{}
for k := range Aqueue {
fmt.Printf(" A [%v]\n", k)
tracef(" A [%v]\n", k)
anode, ok, err := av.GetToLeaf(ctx, k)
if err != nil {
return nil, err
......@@ -935,7 +938,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
Adone.Add(k)
}
fmt.Printf(" av: %s\n", av)
tracef(" av: %s\n", av)
}
}
......@@ -946,8 +949,8 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
// δMerge merges changes from δ2 into δ.
// δ is total-building diff, while δ2 is diff from comparing some subnodes.
func δMerge(δ, δ2 map[Key]ΔValue) error {
fmt.Printf(" δmerge %v <- %v\n", δ, δ2)
defer fmt.Printf(" -> %v\n", δ)
tracef(" δmerge %v <- %v\n", δ, δ2)
defer tracef(" -> %v\n", δ)
// merge δ <- δ2
for k, δv2 := range δ2 {
......@@ -992,7 +995,7 @@ func δMerge(δ, δ2 map[Key]ΔValue) error {
δv.New = δv2.New
}
fmt.Printf(" [%v] merge %s %s -> %s\n", k, δv1, δv2, δv)
tracef(" [%v] merge %s %s -> %s\n", k, δv1, δv2, δv)
if δv.Old != δv.New {
δ[k] = δv
} else {
......@@ -1007,7 +1010,7 @@ func δMerge(δ, δ2 map[Key]ΔValue) error {
// diffB computes difference in between two buckets.
// see diffX for details.
func diffB(ctx context.Context, a, b *Bucket) (δ map[Key]ΔValue, err error) {
fmt.Printf(" B %s %s\n", xidOf(a), xidOf(b))
tracef(" diffB %s %s\n", xidOf(a), xidOf(b))
defer xerr.Contextf(&err, "diffB %s %s", xidOf(a), xidOf(b))
// XXX oid can be InvalidOid for T/B... (i.e. B is part of T and is not yet committed separately)
......@@ -1028,7 +1031,7 @@ func diffB(ctx context.Context, a, b *Bucket) (δ map[Key]ΔValue, err error) {
//defer fmt.Println("< diffB")
δ = map[Key]ΔValue{}
defer fmt.Printf(" -> δb: %v\n", δ)
defer tracef(" -> δb: %v\n", δ)
//fmt.Println("av:", av)
//fmt.Println("bv:", bv)
......@@ -1256,3 +1259,12 @@ func (rn nodeInRange) String() string {
func (track nodeTrack) String() string {
return fmt.Sprintf("{p%s h%s}", track.parent, track.holes)
}
const debug = true
func tracef(format string, argv ...interface{}) {
if debug {
fmt.Printf(format, argv...)
}
}
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