Commit 7ffbe6ae authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 798f7dc6
...@@ -45,7 +45,7 @@ import ( ...@@ -45,7 +45,7 @@ import (
// //
// XXX ΔPPTreeSubSet // XXX ΔPPTreeSubSet
// //
// Every node in the set also has .parent pointer. // Every node in the set also has .parent pointer. XXX
type PPTreeSubSet map[zodb.Oid]*nodeInTree type PPTreeSubSet map[zodb.Oid]*nodeInTree
// nodeInTree represents tracking information about a node. // nodeInTree represents tracking information about a node.
...@@ -116,8 +116,8 @@ func (δ *ΔPPTreeSubSet) Reverse() { ...@@ -116,8 +116,8 @@ func (δ *ΔPPTreeSubSet) Reverse() {
} }
// verify verifies internal consistency of tidx. // verify checks internal consistency of S.
func (tidx PPTreeSubSet) verify() { func (S PPTreeSubSet) verify() {
// XXX !debug -> return // XXX !debug -> return
var badv []string var badv []string
...@@ -126,18 +126,18 @@ func (tidx PPTreeSubSet) verify() { ...@@ -126,18 +126,18 @@ func (tidx PPTreeSubSet) verify() {
} }
defer func() { defer func() {
if badv != nil { if badv != nil {
emsg := fmt.Sprintf("tidx.verify: fail:\n\n") emsg := fmt.Sprintf("S.verify: fail:\n\n")
for _, bad := range badv { for _, bad := range badv {
emsg += fmt.Sprintf("- %s\n", bad) emsg += fmt.Sprintf("- %s\n", bad)
} }
emsg += fmt.Sprintf("\ntidx: %s\n", tidx) emsg += fmt.Sprintf("\nS: %s\n", S)
panic(emsg) panic(emsg)
} }
}() }()
// recompute {} oid -> children and verify .nchild against it // recompute {} oid -> children and verify .nchild against it
children := map[zodb.Oid]SetOid{} children := map[zodb.Oid]SetOid{}
for oid, t := range tidx { for oid, t := range S {
if t.parent != zodb.InvalidOid { if t.parent != zodb.InvalidOid {
cc, ok := children[t.parent] cc, ok := children[t.parent]
if !ok { if !ok {
...@@ -148,16 +148,16 @@ func (tidx PPTreeSubSet) verify() { ...@@ -148,16 +148,16 @@ func (tidx PPTreeSubSet) verify() {
} }
} }
for oid, t := range tidx { for oid, t := range S {
cc := children[oid] cc := children[oid]
if t.nchild != len(cc) { if t.nchild != len(cc) {
badf("[%s].nchild=%d children: %s", oid, t.nchild, cc) badf("[%s].nchild=%d children: %s", oid, t.nchild, cc)
} }
} }
// verify that all pointed-to parents are present in tidx // verify that all pointed-to parents are present in the set (= PP-connected)
for oid := range children { for oid := range children {
_, ok := tidx[oid] _, ok := S[oid]
if !ok { if !ok {
badf("oid %s is pointed to via some .parent, but is not present in the set", oid) badf("oid %s is pointed to via some .parent, but is not present in the set", oid)
} }
......
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