Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
1c21d16e
Commit
1c21d16e
authored
May 15, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d4848186
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
87 deletions
+84
-87
wcfs/pptreesubset.go
wcfs/pptreesubset.go
+4
-2
wcfs/δbtail.go
wcfs/δbtail.go
+33
-36
wcfs/δbtail_test.go
wcfs/δbtail_test.go
+47
-49
No files found.
wcfs/pptreesubset.go
View file @
1c21d16e
...
...
@@ -45,6 +45,8 @@ const debugPPSet = false
// returns path to tree node given node oid.
//
// Every node in the set comes with .parent pointer.
//
// XXX we only allow single parent/root case and report "tree corrupt" otherwise.
type
PPTreeSubSet
map
[
zodb
.
Oid
]
*
nodeInTree
// nodeInTree represents tracking information about a node.
...
...
@@ -352,8 +354,8 @@ func (orig PPTreeSubSet) Clone() PPTreeSubSet {
return
klon
}
//
e
qual returns whether a == b.
func
(
A
PPTreeSubSet
)
e
qual
(
B
PPTreeSubSet
)
bool
{
//
E
qual returns whether a == b.
func
(
A
PPTreeSubSet
)
E
qual
(
B
PPTreeSubSet
)
bool
{
if
len
(
A
)
!=
len
(
B
)
{
return
false
}
...
...
wcfs/δbtail.go
View file @
1c21d16e
...
...
@@ -175,12 +175,10 @@ type ΔBtail struct {
// TODO allow client to optionally provide zconnOld/zconnNew on e.g. Update()
db
*
zodb
.
DB
// to open connections to load new/old tree|buckets
// tracked nodes index: node -> parent + accessed holes under this node XXX -> holeIdx
// we only allow single parent/root case and report "tree corrupt" otherwise.
// trackIdx describes @head state
trackIdx
PPTreeSubSet
// XXX -> trackSet
// set of tracked nodes as of @head state.
trackSet
PPTreeSubSet
//
tree(s) subset that was
requested to be tracked, but for which vδB was not yet rebuilt
//
set of node that were
requested to be tracked, but for which vδB was not yet rebuilt
trackNew
PPTreeSubSet
// XXX root -> tracked holes
...
...
@@ -247,7 +245,7 @@ func NewΔBtail(at0 zodb.Tid, db *zodb.DB) *ΔBtail {
return
&
ΔBtail
{
δZtail
:
zodb
.
NewΔTail
(
at0
),
byRoot
:
map
[
zodb
.
Oid
]
*
ΔTtail
{},
track
Idx
:
PPTreeSubSet
{},
track
Set
:
PPTreeSubSet
{},
trackNew
:
PPTreeSubSet
{},
holeIdxByRoot
:
map
[
zodb
.
Oid
]
treeSetKey
{},
db
:
db
,
...
...
@@ -264,8 +262,8 @@ func (orig *ΔBtail) clone() *ΔBtail {
klon
.
δZtail
.
Append
(
δZ
.
Rev
,
δZ
.
Changev
)
}
// track
Idx
, trackNew
klon
.
track
Idx
=
orig
.
trackIdx
.
Clone
()
// track
Set
, trackNew
klon
.
track
Set
=
orig
.
trackSet
.
Clone
()
klon
.
trackNew
=
orig
.
trackNew
.
Clone
()
// byRoot
...
...
@@ -334,7 +332,6 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node) error { //
for
_
,
node
:=
range
path
{
pathv
=
append
(
pathv
,
vnode
(
node
))
}
tracef
(
"Track [%v] %s
\n
"
,
key
,
strings
.
Join
(
pathv
,
" -> "
))
// δBtail.trackIdx.AddNodePath(path)
δBtail
.
trackNew
.
AddNodePath
(
path
)
// track is track of path[-1] (i.e. leaf)
...
...
@@ -409,7 +406,7 @@ func (δBtail *ΔBtail) rebuild() (err error) {
tracef
(
"
\n
rebuild @%s <- @%s
\n
"
,
atPrev
,
δZ
.
Rev
)
tracef
(
"δZ:
\t
%v
\n
"
,
δZ
.
Changev
)
tracef
(
"trackNew: %v
\n
"
,
trackNew
)
tracef
(
"track
Idx: %v
\n
"
,
δBtail
.
trackIdx
)
// XXX needed?
tracef
(
"track
Set: %v
\n
"
,
δBtail
.
trackSet
)
// XXX needed?
defer
tracef
(
"
\n\n
"
)
// XXX len(δtopsByRoot) == 0 -> skip
...
...
@@ -482,12 +479,12 @@ func (δBtail *ΔBtail) rebuild() (err error) {
}
// trackNew was adjusted to correspond to @tail potentially growing its key coverage.
// Remap it back to @head and merge to .track
Idx
// Remap it back to @head and merge to .track
Set
for
_
,
δtrack
:=
range
vδtrack
{
δtrack
.
Reverse
()
// we saved it as lo<-hi; now we go lo->hi
trackNew
.
ApplyΔ
(
δtrack
)
}
δBtail
.
track
Idx
.
UnionInplace
(
trackNew
)
δBtail
.
track
Set
.
UnionInplace
(
trackNew
)
return
nil
}
...
...
@@ -505,19 +502,19 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
headOld
:=
δBtail
.
Head
()
defer
xerr
.
Contextf
(
&
err
,
"ΔBtail update %s -> %s"
,
headOld
,
δZ
.
Tid
)
// update .track
Idx
and vδB from .trackNew
// update .track
Set
and vδB from .trackNew
δBtail
.
rebuild
()
tracef
(
"Update @%s -> @%s
\n
"
,
δBtail
.
Head
(),
δZ
.
Tid
)
tracef
(
"δZ:
\t
%v
\n
"
,
δZ
.
Changev
)
tracef
(
"track
Idx: %v
\n
"
,
δBtail
.
trackIdx
)
tracef
(
"track
Set: %v
\n
"
,
δBtail
.
trackSet
)
tracef
(
"holeIdxByRoot: %v
\n
"
,
δBtail
.
holeIdxByRoot
)
// XXX dup wrt rebuild?
δBtail
.
δZtail
.
Append
(
δZ
.
Tid
,
δZ
.
Changev
)
δZTC
,
δtopsByRoot
:=
δZConnectTracked
(
δZ
.
Changev
,
δBtail
.
track
Idx
)
δZTC
,
δtopsByRoot
:=
δZConnectTracked
(
δZ
.
Changev
,
δBtail
.
track
Set
)
δB
:=
ΔB
{
Rev
:
δZ
.
Tid
,
ByRoot
:
make
(
map
[
zodb
.
Oid
]
map
[
Key
]
ΔValue
)}
...
...
@@ -541,7 +538,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
for
root
,
δtops
:=
range
δtopsByRoot
{
holeIdx
:=
δBtail
.
holeIdxByRoot
[
root
]
δT
,
δtrack
,
err
:=
treediff
(
ctx
,
root
,
δtops
,
δZTC
,
δBtail
.
track
Idx
,
holeIdx
,
zconnOld
,
zconnNew
)
δT
,
δtrack
,
err
:=
treediff
(
ctx
,
root
,
δtops
,
δZTC
,
δBtail
.
track
Set
,
holeIdx
,
zconnOld
,
zconnNew
)
if
err
!=
nil
{
return
ΔB
{},
err
}
...
...
@@ -573,7 +570,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
// XXX rebuild lastRevOf
}
δBtail
.
track
Idx
.
ApplyΔ
(
δtrack
)
δBtail
.
track
Set
.
ApplyΔ
(
δtrack
)
}
return
δB
,
nil
...
...
@@ -808,15 +805,15 @@ func (rs rangeSplit) String() string {
// treediff computes δT/δtrack for tree/track
Idx
specified by root in between old..new.
// treediff computes δT/δtrack for tree/track
Set
specified by root in between old..new.
//
// δtops is set of top nodes for changed subtrees.
// δZTC is connected(δZ/T) - connected closure for subset of δZ(old..new) that
// touches tracked nodes of T.
//
// XXX holeIdx is updated XXX -> return similarly to δtrack
// XXX ^^^ -> but better kill holeIdx and do everything only via track
Idx
func
treediff
(
ctx
context
.
Context
,
root
zodb
.
Oid
,
δtops
SetOid
,
δZTC
SetOid
,
track
Idx
PPTreeSubSet
,
holeIdx
treeSetKey
,
zconnOld
,
zconnNew
*
zodb
.
Connection
)
(
δT
map
[
Key
]
ΔValue
,
δtrack
*
ΔPPTreeSubSet
,
err
error
)
{
// XXX ^^^ -> but better kill holeIdx and do everything only via track
Set
func
treediff
(
ctx
context
.
Context
,
root
zodb
.
Oid
,
δtops
SetOid
,
δZTC
SetOid
,
track
Set
PPTreeSubSet
,
holeIdx
treeSetKey
,
zconnOld
,
zconnNew
*
zodb
.
Connection
)
(
δT
map
[
Key
]
ΔValue
,
δtrack
*
ΔPPTreeSubSet
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"treediff %s..%s %s"
,
zconnOld
.
At
(),
zconnNew
.
At
(),
root
)
tracef
(
"
\n
treediff %s δtops: %v δZTC: %v
\n
"
,
root
,
δtops
,
δZTC
)
...
...
@@ -833,7 +830,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
return
nil
,
nil
,
err
}
δtop
,
δtrackTop
,
err
:=
diffX
(
ctx
,
a
,
b
,
δZTC
,
track
Idx
,
holeIdx
)
δtop
,
δtrackTop
,
err
:=
diffX
(
ctx
,
a
,
b
,
δZTC
,
track
Set
,
holeIdx
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
...
...
@@ -862,7 +859,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
}
}
// adjust track
Idx
by merge(δtrackTops)
// adjust track
Set
by merge(δtrackTops)
δtrack
=
&
ΔPPTreeSubSet
{
Del
:
PPTreeSubSet
{},
Add
:
PPTreeSubSet
{},
δnchildNonLeafs
:
map
[
zodb
.
Oid
]
int
{}}
for
_
,
δ
:=
range
δtrackv
{
δtrack
.
Update
(
δ
)
...
...
@@ -880,9 +877,9 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
//
// a/b can be nil; a=nil means addition, b=nil means deletion.
//
// δtrack
Idx is trackIdx δ that needs to be applied to trackIdx
to keep it
// δtrack
is trackSet δ that needs to be applied to trackSet
to keep it
// consistent with b (= a + δ).
func
diffX
(
ctx
context
.
Context
,
a
,
b
Node
,
δZTC
SetOid
,
track
Idx
PPTreeSubSet
,
holeIdx
treeSetKey
)
(
δ
map
[
Key
]
ΔValue
,
δtrackIdx
*
ΔPPTreeSubSet
,
err
error
)
{
func
diffX
(
ctx
context
.
Context
,
a
,
b
Node
,
δZTC
SetOid
,
track
Set
PPTreeSubSet
,
holeIdx
treeSetKey
)
(
δ
map
[
Key
]
ΔValue
,
δtrack
*
ΔPPTreeSubSet
,
err
error
)
{
if
a
==
nil
&&
b
==
nil
{
panic
(
"BUG: both a & b == nil"
)
}
...
...
@@ -917,7 +914,7 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid, trackIdx PPTreeSubSet,
}
if
isT
{
return
diffT
(
ctx
,
aT
,
bT
,
δZTC
,
track
Idx
,
holeIdx
)
return
diffT
(
ctx
,
aT
,
bT
,
δZTC
,
track
Set
,
holeIdx
)
}
else
{
var
δtrack
*
ΔPPTreeSubSet
δ
,
err
:=
diffB
(
ctx
,
aB
,
bB
)
...
...
@@ -932,7 +929,7 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid, trackIdx PPTreeSubSet,
//
// a, b point to top of subtrees @old and @new revisions.
// δZTC is connected set of objects covering δZT (objects changed in this tree in old..new).
func
diffT
(
ctx
context
.
Context
,
A
,
B
*
Tree
,
δZTC
SetOid
,
track
Idx
PPTreeSubSet
,
holeIdx
treeSetKey
)
(
δ
map
[
Key
]
ΔValue
,
δtrack
*
ΔPPTreeSubSet
,
err
error
)
{
func
diffT
(
ctx
context
.
Context
,
A
,
B
*
Tree
,
δZTC
SetOid
,
track
Set
PPTreeSubSet
,
holeIdx
treeSetKey
)
(
δ
map
[
Key
]
ΔValue
,
δtrack
*
ΔPPTreeSubSet
,
err
error
)
{
tracef
(
" diffT %s %s
\n
"
,
xidOf
(
A
),
xidOf
(
B
))
defer
xerr
.
Contextf
(
&
err
,
"diffT %s %s"
,
xidOf
(
A
),
xidOf
(
B
))
...
...
@@ -945,10 +942,10 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx PPTreeSubSet,
// path prefix to A and B
prefix
:=
[]
zodb
.
Oid
{}
t
:=
track
Idx
[
A
.
POid
()]
t
:=
track
Set
[
A
.
POid
()]
for
t
.
parent
!=
zodb
.
InvalidOid
{
prefix
=
append
([]
zodb
.
Oid
{
t
.
parent
},
prefix
...
)
t
=
track
Idx
[
t
.
parent
]
t
=
track
Set
[
t
.
parent
]
}
// initial split ranges for A and B
...
...
@@ -978,8 +975,8 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx PPTreeSubSet,
// {} oid -> parent for all nodes in Bv: current and previously expanded - up till top B
// XXX requires A.oid == B.oid
Btrack
Idx
:=
PPTreeSubSet
{}
Btrack
Idx
.
AddPath
(
trackIdx
.
Path
(
B
.
POid
()))
Btrack
Set
:=
PPTreeSubSet
{}
Btrack
Set
.
AddPath
(
trackSet
.
Path
(
B
.
POid
()))
// phase 1: expand A top->down driven by δZTC.
// by default a node contributes to δ-
...
...
@@ -1029,7 +1026,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx PPTreeSubSet,
achildren
:=
Av
.
Expand
(
ra
)
for
_
,
ac
:=
range
achildren
{
acOid
:=
ac
.
node
.
POid
()
at
,
tracked
:=
track
Idx
[
acOid
]
at
,
tracked
:=
track
Set
[
acOid
]
if
!
tracked
&&
/*cannot skip embedded bucket:*/
acOid
!=
zodb
.
InvalidOid
{
continue
}
...
...
@@ -1040,7 +1037,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx PPTreeSubSet,
// ( this does not give exact answer but should be a reasonable heuristic;
// the diff is the same if heuristic does not work and we
// look into and load more nodes to compute δ )
_
,
found
:=
Btrack
Idx
[
acOid
]
_
,
found
:=
Btrack
Set
[
acOid
]
if
!
found
{
for
{
blo
:=
Bv
.
Get
(
ac
.
lo
)
...
...
@@ -1059,7 +1056,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx PPTreeSubSet,
bchildren
:=
Bv
.
Expand
(
blo
)
for
_
,
bc
:=
range
bchildren
{
bcOid
:=
bc
.
node
.
POid
()
Btrack
Idx
.
AddPath
(
bc
.
Path
())
Btrack
Set
.
AddPath
(
bc
.
Path
())
if
acOid
==
bcOid
{
found
=
true
}
...
...
@@ -1073,9 +1070,9 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx PPTreeSubSet,
// ac can be skipped
// XXX Bkqueue <- holes(ac.range \ bc.range) XXX test for this
// adjust track
Idx
since path to the node could have changed
apath
:=
track
Idx
.
Path
(
acOid
)
bpath
:=
Btrack
Idx
.
Path
(
acOid
)
// adjust track
Set
since path to the node could have changed
apath
:=
track
Set
.
Path
(
acOid
)
bpath
:=
Btrack
Set
.
Path
(
acOid
)
if
!
pathEqual
(
apath
,
bpath
)
{
δtrack
.
Del
.
AddPath
(
apath
)
δtrack
.
Add
.
AddPath
(
bpath
)
...
...
wcfs/δbtail_test.go
View file @
1c21d16e
...
...
@@ -312,20 +312,19 @@ func (rbs RBucketSet) holeIdx(tracked SetKey) SetKey {
return
holes
}
// trackIdx returns what should be ΔBtree.trackIdx for specified tracked key set.
// XXX -> trackSet
func
(
rbs
RBucketSet
)
trackIdx
(
tracked
SetKey
)
PPTreeSubSet
{
trackIdx
:=
PPTreeSubSet
{}
// trackSet returns what should be ΔBtree.trackSet for specified tracked key set.
func
(
rbs
RBucketSet
)
trackSet
(
tracked
SetKey
)
PPTreeSubSet
{
trackSet
:=
PPTreeSubSet
{}
for
k
:=
range
tracked
{
kb
:=
rbs
.
Get
(
k
)
// track
Idx
explicitly records only regular buckets.
// track
Set
explicitly records only regular buckets.
// embedded buckets all have oid=zodb.InvalidOid and would lead to z
newNode
:=
false
if
kb
.
oid
!=
zodb
.
InvalidOid
{
track
,
already
:=
track
Idx
[
kb
.
oid
]
track
,
already
:=
track
Set
[
kb
.
oid
]
if
!
already
{
track
=
&
nodeInTree
{
parent
:
kb
.
parent
.
oid
,
nchild
:
0
}
track
Idx
[
kb
.
oid
]
=
track
track
Set
[
kb
.
oid
]
=
track
newNode
=
true
}
if
track
.
parent
!=
kb
.
parent
.
oid
{
...
...
@@ -340,11 +339,11 @@ func (rbs RBucketSet) trackIdx(tracked SetKey) PPTreeSubSet {
ppoid
=
p
.
parent
.
oid
}
pt
,
already
:=
track
Idx
[
p
.
oid
]
pt
,
already
:=
track
Set
[
p
.
oid
]
newParent
:=
false
if
!
already
{
pt
=
&
nodeInTree
{
parent
:
ppoid
,
nchild
:
0
}
track
Idx
[
p
.
oid
]
=
pt
track
Set
[
p
.
oid
]
=
pt
newParent
=
true
}
if
pt
.
parent
!=
ppoid
{
...
...
@@ -358,7 +357,7 @@ func (rbs RBucketSet) trackIdx(tracked SetKey) PPTreeSubSet {
newNode
=
newParent
}
}
return
track
Idx
return
track
Set
}
...
...
@@ -749,13 +748,13 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
badf
(
"δbtail.holeIdx1 wrong ; holeIdx=%v holeIdxOK=%v"
,
holeIdx
,
holes1
)
}
// verify δbtail.track
Idx
against @at1
// track
Idx
1 = xkv1[tracked1]
track
Idx1
:=
xkv1
.
trackIdx
(
initialTrackedKeys
)
// if !reflect.DeepEqual(track
Idx1, δbtail.trackIdx
) {
// badf("δbtail.track
Idx1 wrong:\n\thave: %v\n\twant: %v", δbtail.trackIdx, trackIdx
1)
// verify δbtail.track
Set
against @at1
// track
Set
1 = xkv1[tracked1]
track
Set1
:=
xkv1
.
trackSet
(
initialTrackedKeys
)
// if !reflect.DeepEqual(track
Set1, δbtail.trackSet
) {
// badf("δbtail.track
Set1 wrong:\n\thave: %v\n\twant: %v", δbtail.trackSet, trackSet
1)
// }
δbtail
.
assertTrack
(
t
,
"1"
,
/*ø*/
PPTreeSubSet
{},
track
Idx
1
)
δbtail
.
assertTrack
(
t
,
"1"
,
/*ø*/
PPTreeSubSet
{},
track
Set
1
)
// δB <- δZ
...
...
@@ -772,13 +771,13 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
badf
(
"δbtail.holeIdx2 wrong ; holeIdx=%v holeIdxOK=%v"
,
holeIdx
,
holes2
)
}
// verify δbtail.track
Idx
against @at2
// track
Idx
2 = xkv2[tracked2] ( = xkv2[kadj[tracked1]]
track
Idx2
:=
xkv2
.
trackIdx
(
kadjTracked
)
// if !reflect.DeepEqual(track
Idx2, δbtail.trackIdx
) {
// badf("δbtail.track
Idx2 wrong:\n\thave: %v\n\twant: %v", δbtail.trackIdx, trackIdx
2)
// verify δbtail.track
Set
against @at2
// track
Set
2 = xkv2[tracked2] ( = xkv2[kadj[tracked1]]
track
Set2
:=
xkv2
.
trackSet
(
kadjTracked
)
// if !reflect.DeepEqual(track
Set2, δbtail.trackSet
) {
// badf("δbtail.track
Set2 wrong:\n\thave: %v\n\twant: %v", δbtail.trackSet, trackSet
2)
// }
δbtail
.
assertTrack
(
t
,
"2"
,
track
Idx
2
,
/*ø*/
PPTreeSubSet
{})
δbtail
.
assertTrack
(
t
,
"2"
,
track
Set
2
,
/*ø*/
PPTreeSubSet
{})
// assert δB.ByRoot == {treeRoot -> ...} if δTok != ø
...
...
@@ -838,22 +837,21 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
}
}
// assertTrack verifies that track
Idx == trackIdx
OK.
// assertTrack verifies that track
Set == trackSet
OK.
// XXX place
func
assertTrack
(
t
*
testing
.
T
,
subj
string
,
track
Idx
,
trackIdx
OK
PPTreeSubSet
)
{
func
assertTrack
(
t
*
testing
.
T
,
subj
string
,
track
Set
,
trackSet
OK
PPTreeSubSet
)
{
t
.
Helper
()
// eq := reflect.DeepEqual(trackIdx, trackIdxOK) // slower
eq
:=
trackIdx
.
equal
(
trackIdxOK
)
eq
:=
trackSet
.
Equal
(
trackSetOK
)
if
!
eq
{
t
.
Errorf
(
"%s:
\n\t
have: %v
\n\t
want: %v"
,
subj
,
track
Idx
,
trackIdx
OK
)
t
.
Errorf
(
"%s:
\n\t
have: %v
\n\t
want: %v"
,
subj
,
track
Set
,
trackSet
OK
)
}
}
// assertTrack verifies state of .track
Idx
and .trackNew.
// assertTrack verifies state of .track
Set
and .trackNew.
// XXX place
func
(
δbtail
*
ΔBtail
)
assertTrack
(
t
*
testing
.
T
,
subj
string
,
track
Idx
OK
,
trackNewOK
PPTreeSubSet
)
{
func
(
δbtail
*
ΔBtail
)
assertTrack
(
t
*
testing
.
T
,
subj
string
,
track
Set
OK
,
trackNewOK
PPTreeSubSet
)
{
t
.
Helper
()
assertTrack
(
t
,
subj
+
": track
Idx"
,
δbtail
.
trackIdx
,
trackIdx
OK
)
assertTrack
(
t
,
subj
+
": track
Set"
,
δbtail
.
trackSet
,
trackSet
OK
)
assertTrack
(
t
,
subj
+
": trackNew"
,
δbtail
.
trackNew
,
trackNewOK
)
// XXX also verify .holeIdx XXX or better get rid of .holeIdx
...
...
@@ -908,24 +906,24 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
t
.
Run
(
fmt
.
Sprintf
(
" T%s;R"
,
keys1
),
func
(
t
*
testing
.
T
)
{
δbtail
:=
NewΔBtail
(
t0
.
at
,
db
)
// assert track
Idx
=ø, trackNew=ø, vδB=[]
// assert track
Set
=ø, trackNew=ø, vδB=[]
δbtail
.
assertTrack
(
t
,
"@at0"
,
ø
,
ø
)
// XXX + vδB
xverifyΔBTail_rebuild_U
(
t
,
δbtail
,
t0
,
t1
,
xat
,
/*track
Idx
=*/
ø
)
xverifyΔBTail_rebuild_U
(
t
,
δbtail
,
t0
,
t1
,
xat
,
/*track
Set
=*/
ø
)
xverifyΔBTail_rebuild_TR
(
t
,
db
,
δbtail
,
t1
,
treeRoot
,
xat
,
// after Track(keys1)
keys1
,
/*track
Idx
=*/
ø
,
/*trackNew=*/
t1
.
xkv
.
track
Idx
(
keys1
),
/*track
Set
=*/
ø
,
/*trackNew=*/
t1
.
xkv
.
track
Set
(
keys1
),
// after rebuild
/*track
Idx=*/
t1
.
xkv
.
trackIdx
(
keys1_0
),
/*track
Set=*/
t1
.
xkv
.
trackSet
(
keys1_0
),
/*vδT=*/
δkv1_1
)
t
.
Run
((
" →"
+
t2
.
tree
),
func
(
t
*
testing
.
T
)
{
// tracked keys1 becomes tracked keys1_2 after Update(t1->t2)
keys1_2
:=
kadj12
.
Map
(
keys1
)
xverifyΔBTail_rebuild_U
(
t
,
δbtail
,
t1
,
t2
,
xat
,
/*track
Idx=*/
t2
.
xkv
.
trackIdx
(
keys1_2
))
xverifyΔBTail_rebuild_U
(
t
,
δbtail
,
t1
,
t2
,
xat
,
/*track
Set=*/
t2
.
xkv
.
trackSet
(
keys1_2
))
// tRestKeys2 = tAllKeys - keys1
tRestKeys2
:=
tAllKeys
.
Difference
(
keys1
)
...
...
@@ -959,12 +957,12 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
xverifyΔBTail_rebuild_TR
(
t
,
db
,
δbtail_
,
t2
,
treeRoot
,
xat
,
// after Track(keys2)
keys2
,
// FIXME vvv trackNew should not cover ranges that are already in track
Idx
/*track
Idx*/
t2
.
xkv
.
trackIdx
(
keys1_0
.
Union
(
keys1_2
)),
/*trackNew*/
t2
.
xkv
.
track
Idx
(
keys2
),
// FIXME vvv trackNew should not cover ranges that are already in track
Set
/*track
Set*/
t2
.
xkv
.
trackSet
(
keys1_0
.
Union
(
keys1_2
)),
/*trackNew*/
t2
.
xkv
.
track
Set
(
keys2
),
// after rebuild
/* track
Idx=*/
t2
.
xkv
.
trackIdx
(
keys12_0
),
/* track
Set=*/
t2
.
xkv
.
trackSet
(
keys12_0
),
/*vδT=*/
δkv1_2
,
δkv2_2
)
// })
}
...
...
@@ -975,7 +973,7 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
}
// xverifyΔBTail_rebuild_U verifies ΔBTree state after Update(ti->tj).
func
xverifyΔBTail_rebuild_U
(
t
*
testing
.
T
,
δbtail
*
ΔBtail
,
ti
,
tj
*
tTreeCommit
,
xat
map
[
zodb
.
Tid
]
string
,
track
Idx
PPTreeSubSet
)
{
func
xverifyΔBTail_rebuild_U
(
t
*
testing
.
T
,
δbtail
*
ΔBtail
,
ti
,
tj
*
tTreeCommit
,
xat
map
[
zodb
.
Tid
]
string
,
track
Set
PPTreeSubSet
)
{
t
.
Helper
()
X
:=
exc
.
Raiseif
ø
:=
PPTreeSubSet
{}
...
...
@@ -983,12 +981,12 @@ func xverifyΔBTail_rebuild_U(t *testing.T, δbtail *ΔBtail, ti, tj *tTreeCommi
// Update ati -> atj
δB
,
err
:=
δbtail
.
Update
(
tj
.
δZ
);
X
(
err
)
// XXX assert δB.Rev = tj.at; δB = δ(ti,tj)/initially tracked
δbtail
.
assertTrack
(
t
,
fmt
.
Sprintf
(
"after Update(@%s→@%s)"
,
xat
[
ti
.
at
],
xat
[
tj
.
at
]),
track
Idx
,
ø
)
δbtail
.
assertTrack
(
t
,
fmt
.
Sprintf
(
"after Update(@%s→@%s)"
,
xat
[
ti
.
at
],
xat
[
tj
.
at
]),
track
Set
,
ø
)
_
=
δB
}
// xverifyΔBTail_rebuild_TR verifies ΔBTree state after Track(keys) + rebuild.
func
xverifyΔBTail_rebuild_TR
(
t
*
testing
.
T
,
db
*
zodb
.
DB
,
δbtail
*
ΔBtail
,
tj
*
tTreeCommit
,
treeRoot
zodb
.
Oid
,
xat
map
[
zodb
.
Tid
]
string
,
keys
SetKey
,
track
Idx
PPTreeSubSet
,
trackNew
,
trackIdx
AfterRebuild
PPTreeSubSet
,
vδTok
...
map
[
Key
]
Δstring
)
{
func
xverifyΔBTail_rebuild_TR
(
t
*
testing
.
T
,
db
*
zodb
.
DB
,
δbtail
*
ΔBtail
,
tj
*
tTreeCommit
,
treeRoot
zodb
.
Oid
,
xat
map
[
zodb
.
Tid
]
string
,
keys
SetKey
,
track
Set
PPTreeSubSet
,
trackNew
,
trackSet
AfterRebuild
PPTreeSubSet
,
vδTok
...
map
[
Key
]
Δstring
)
{
t
.
Helper
()
X
:=
exc
.
Raiseif
ø
:=
PPTreeSubSet
{}
...
...
@@ -1004,12 +1002,12 @@ func xverifyΔBTail_rebuild_TR(t *testing.T, db *zodb.DB, δbtail *ΔBtail, tj *
err
=
δbtail
.
Track
(
k
,
ok
,
path
);
X
(
err
)
}
δbtail
.
assertTrack
(
t
,
fmt
.
Sprintf
(
"@%s: after Track%v"
,
xat
[
tj
.
at
],
keys
),
track
Idx
,
trackNew
)
δbtail
.
assertTrack
(
t
,
fmt
.
Sprintf
(
"@%s: after Track%v"
,
xat
[
tj
.
at
],
keys
),
track
Set
,
trackNew
)
// XXX vδB=[ø]
δbtail
.
rebuild
()
δbtail
.
assertTrack
(
t
,
fmt
.
Sprintf
(
"@%s: after Track%v + rebuild"
,
xat
[
tj
.
at
],
keys
),
track
Idx
AfterRebuild
,
ø
)
δbtail
.
assertTrack
(
t
,
fmt
.
Sprintf
(
"@%s: after Track%v + rebuild"
,
xat
[
tj
.
at
],
keys
),
track
Set
AfterRebuild
,
ø
)
// XXX assert vδB=[δ1/T(keys)]
// XXX verify Get
...
...
@@ -1434,12 +1432,12 @@ func TestΔBTail(t *testing.T) {
"T/T1/T-T/B0:g-B1:e,2:d,3:h"
,
"T1/T-T3/B0:g-T-T/B1:e,2:d-B3:h"
,
// was leading to wrongly computed track
Idx
2 due to top not
// was leading to wrongly computed track
Set
2 due to top not
// being tracked to tree root.
"T/T1/B0:a-B1:b"
,
"T/T1/T-T/B0:c-B1:d"
,
// was leading to wrongly computed track
Idx
2: leaf bucket not
// was leading to wrongly computed track
Set
2: leaf bucket not
// reparented to root.
"T/T/B0:a"
,
"T/B0:a"
,
...
...
@@ -1450,7 +1448,7 @@ func TestΔBTail(t *testing.T) {
// ---- found by AllStructs ----
// track
Idx
2 wrongly computed due to top not being tracked to tree root
// track
Set
2 wrongly computed due to top not being tracked to tree root
"T2/T1-T/B0:g-B1:b-T/B2:b,3:a"
,
"T2/T1-T/T-T-B2:a/B0:c-B1:g"
,
...
...
@@ -1462,7 +1460,7 @@ func TestΔBTail(t *testing.T) {
"T1/T-T2/T-B1:c-B2:c/B0:g"
,
"T1/T-T/B0:g-T/B1:e"
,
// track
Idx
corruption: oid is pointed by some .parent but is not present
// track
Set
corruption: oid is pointed by some .parent but is not present
"T1/T-T/B0:g-T2/B1:h-B2:g"
,
"T/T1/T-T2/B0:e-B1:f-B2:g"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment