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
41eab70a
Commit
41eab70a
authored
Sep 07, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0480d21d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
19 deletions
+46
-19
wcfs/δbtail.go
wcfs/δbtail.go
+46
-19
No files found.
wcfs/δbtail.go
View file @
41eab70a
...
@@ -199,7 +199,22 @@ type nodeTrack struct {
...
@@ -199,7 +199,22 @@ type nodeTrack struct {
*/
*/
}
}
func
(
tidx
trackIndex
)
DelLeaf
(
oid
zodb
.
Oid
)
{
// δtrackIndex represents changes to trackIndex.
// XXX place
type
δtrackIndex
struct
{
// set of leaf nodes to remove. After leafs are removed, their parents are automatically cleaned up.
// removals are processed before adds (see below).
DelLeaf
SetOid
// nodes to add
Add
trackIndex
}
//func (tidx trackIndex) DelLeaf(oid zodb.Oid) {
// panic("TODO")
//}
func
(
tidx
trackIndex
)
ApplyΔ
(
δtidx
*
δtrackIndex
)
{
panic
(
"TODO"
)
panic
(
"TODO"
)
}
}
...
@@ -319,7 +334,7 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node) error { //
...
@@ -319,7 +334,7 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node) error { //
var
ptrack
*
nodeTrack
=
nil
var
ptrack
*
nodeTrack
=
nil
var
track
*
nodeTrack
// XXX kill here
var
track
*
nodeTrack
// XXX kill here
var
oldTrack
bool
var
oldTrack
bool
for
_
,
node
:=
range
path
{
for
_
,
node
:=
range
path
{
// XXX -> trackIndex.AddPath(path) ?
oid
:=
node
.
POid
()
oid
:=
node
.
POid
()
// XXX skip InvalidOid ?
// XXX skip InvalidOid ?
// InvalidOid means embedded bucket - e.g. T/B1:a with bucket not having its own oid.
// InvalidOid means embedded bucket - e.g. T/B1:a with bucket not having its own oid.
...
@@ -660,7 +675,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
...
@@ -660,7 +675,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
defer
tracef
(
"
\n
"
)
defer
tracef
(
"
\n
"
)
δT
=
map
[
Key
]
ΔValue
{}
δT
=
map
[
Key
]
ΔValue
{}
trackDel
:=
SetOid
{}
δtrackv
:=
[]
*
δtrackIndex
{}
for
top
:=
range
δtops
{
// XXX -> sorted?
for
top
:=
range
δtops
{
// XXX -> sorted?
a
,
err1
:=
zgetNode
(
ctx
,
zconnOld
,
top
)
a
,
err1
:=
zgetNode
(
ctx
,
zconnOld
,
top
)
...
@@ -670,7 +685,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
...
@@ -670,7 +685,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
return
nil
,
err
return
nil
,
err
}
}
δtop
,
err
:=
diffX
(
ctx
,
a
,
b
,
δZTC
,
trackIdx
,
holeIdx
)
δtop
,
δtrackTop
,
err
:=
diffX
(
ctx
,
a
,
b
,
δZTC
,
trackIdx
,
holeIdx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -684,6 +699,8 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
...
@@ -684,6 +699,8 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
for
k
,
δv
:=
range
δtop
{
for
k
,
δv
:=
range
δtop
{
δT
[
k
]
=
δv
δT
[
k
]
=
δv
}
}
δtrackv
=
append
(
δtrackv
,
δtrackTop
)
}
}
// adjust holeIdx
// adjust holeIdx
...
@@ -697,6 +714,11 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
...
@@ -697,6 +714,11 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
}
}
// adjust trackIdx
// adjust trackIdx
for
_
,
δtrack
:=
range
δtrackv
{
trackIdx
.
ApplyΔ
(
δtrack
)
}
/*
for oid := range trackDel {
for oid := range trackDel {
_, present := trackIdx[oid]
_, present := trackIdx[oid]
if !present {
if !present {
...
@@ -704,6 +726,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
...
@@ -704,6 +726,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
}
}
trackIdx.DelLeaf(oid)
trackIdx.DelLeaf(oid)
}
}
*/
/*
/*
for leaf := range trackAdd {
for leaf := range trackAdd {
node := leaf
node := leaf
...
@@ -740,7 +763,10 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
...
@@ -740,7 +763,10 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
// δZTC is connected set of objects covering δZT (objects changed in this tree in old..new).
// δZTC is connected set of objects covering δZT (objects changed in this tree in old..new).
//
//
// a/b can be nil; a=nil means addition, b=nil means deletion.
// a/b can be nil; a=nil means addition, b=nil means deletion.
func
diffX
(
ctx
context
.
Context
,
a
,
b
Node
,
δZTC
SetOid
,
trackIdx
trackIndex
,
holeIdx
treeSetKey
)
(
δ
map
[
Key
]
ΔValue
,
err
error
)
{
//
// δtrackIndex is trackIdx δ that needs to be applied to trackIdx to keep it
// consistent with b (= a + δ).
func
diffX
(
ctx
context
.
Context
,
a
,
b
Node
,
δZTC
SetOid
,
trackIdx
trackIndex
,
holeIdx
treeSetKey
)
(
δ
map
[
Key
]
ΔValue
,
δtrackIdx
*
δtrackIndex
,
err
error
)
{
if
a
==
nil
&&
b
==
nil
{
if
a
==
nil
&&
b
==
nil
{
panic
(
"BUG: both a & b == nil"
)
panic
(
"BUG: both a & b == nil"
)
}
}
...
@@ -769,7 +795,7 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid, trackIdx trackIndex, ho
...
@@ -769,7 +795,7 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid, trackIdx trackIndex, ho
panicf
(
"BUG: a.oid != b.oid ; a: %s b: %s"
,
a
.
POid
(),
b
.
POid
())
panicf
(
"BUG: a.oid != b.oid ; a: %s b: %s"
,
a
.
POid
(),
b
.
POid
())
}
}
if
!
((
aT
!=
nil
&&
bT
!=
nil
)
||
(
aB
!=
nil
&&
bB
!=
nil
))
{
if
!
((
aT
!=
nil
&&
bT
!=
nil
)
||
(
aB
!=
nil
&&
bB
!=
nil
))
{
return
nil
,
fmt
.
Errorf
(
"object %s: type mutated %s -> %s"
,
a
.
POid
(),
return
nil
,
nil
,
fmt
.
Errorf
(
"object %s: type mutated %s -> %s"
,
a
.
POid
(),
zodb
.
ClassOf
(
a
),
zodb
.
ClassOf
(
b
))
zodb
.
ClassOf
(
a
),
zodb
.
ClassOf
(
b
))
}
}
}
}
...
@@ -777,7 +803,8 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid, trackIdx trackIndex, ho
...
@@ -777,7 +803,8 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid, trackIdx trackIndex, ho
if
isT
{
if
isT
{
return
diffT
(
ctx
,
aT
,
bT
,
δZTC
,
trackIdx
,
holeIdx
)
return
diffT
(
ctx
,
aT
,
bT
,
δZTC
,
trackIdx
,
holeIdx
)
}
else
{
}
else
{
return
diffB
(
ctx
,
aB
,
bB
)
δ
,
err
:=
diffB
(
ctx
,
aB
,
bB
)
return
δ
,
/*δtrack*/
nil
,
err
// XXX ok?
}
}
}
}
...
@@ -788,7 +815,7 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid, trackIdx trackIndex, ho
...
@@ -788,7 +815,7 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid, trackIdx trackIndex, ho
//
//
// XXX trackIdx -> just pass δBtail?
// XXX trackIdx -> just pass δBtail?
// XXX ----//---- holeIdx
// XXX ----//---- holeIdx
func
diffT
(
ctx
context
.
Context
,
A
,
B
*
Tree
,
δZTC
SetOid
,
trackIdx
trackIndex
,
holeIdx
treeSetKey
)
(
δ
map
[
Key
]
ΔValue
,
err
error
)
{
func
diffT
(
ctx
context
.
Context
,
A
,
B
*
Tree
,
δZTC
SetOid
,
trackIdx
trackIndex
,
holeIdx
treeSetKey
)
(
δ
map
[
Key
]
ΔValue
,
δtrack
*
δtrackIndex
,
err
error
)
{
tracef
(
" diffT %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
))
defer
xerr
.
Contextf
(
&
err
,
"diffT %s %s"
,
xidOf
(
A
),
xidOf
(
B
))
...
@@ -844,15 +871,15 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h
...
@@ -844,15 +871,15 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h
tracef
(
" av: %s
\n
"
,
Av
)
tracef
(
" av: %s
\n
"
,
Av
)
tracef
(
" bv: %s
\n
"
,
Bv
)
tracef
(
" bv: %s
\n
"
,
Bv
)
ra
:=
pop
(
&
Aq
)
ra
:=
pop
(
&
Aq
)
err
=
ra
.
node
.
PActivate
(
ctx
);
/*X*/
if
err
!=
nil
{
return
nil
,
err
}
err
=
ra
.
node
.
PActivate
(
ctx
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
defer
ra
.
node
.
PDeactivate
()
defer
ra
.
node
.
PDeactivate
()
tracef
(
" a: %s
\n
"
,
ra
)
tracef
(
" a: %s
\n
"
,
ra
)
switch
a
:=
ra
.
node
.
(
type
)
{
switch
a
:=
ra
.
node
.
(
type
)
{
case
*
Bucket
:
case
*
Bucket
:
// a is bucket -> δ-
// a is bucket -> δ-
δA
,
err
:=
diffB
(
ctx
,
a
,
nil
);
/*X*/
if
err
!=
nil
{
return
nil
,
err
}
δA
,
err
:=
diffB
(
ctx
,
a
,
nil
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
err
=
δMerge
(
δ
,
δA
);
/*X*/
if
err
!=
nil
{
return
nil
,
err
}
err
=
δMerge
(
δ
,
δA
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
trackDel
.
Add
(
a
.
POid
())
trackDel
.
Add
(
a
.
POid
())
// Bkqueue <- δA
// Bkqueue <- δA
...
@@ -903,7 +930,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h
...
@@ -903,7 +930,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h
if
!
ok
{
if
!
ok
{
break
// bucket
break
// bucket
}
}
err
=
blo
.
node
.
PActivate
(
ctx
);
/*X*/
if
err
!=
nil
{
return
nil
,
err
}
err
=
blo
.
node
.
PActivate
(
ctx
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
defer
blo
.
node
.
PDeactivate
()
defer
blo
.
node
.
PDeactivate
()
// XXX check for empty tree?
// XXX check for empty tree?
...
@@ -964,18 +991,18 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h
...
@@ -964,18 +991,18 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h
}
}
for
k
:=
range
Bkqueue
{
for
k
:=
range
Bkqueue
{
b
,
err
:=
Bv
.
GetToLeaf
(
ctx
,
k
);
/*X*/
if
err
!=
nil
{
return
nil
,
err
}
b
,
err
:=
Bv
.
GetToLeaf
(
ctx
,
k
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
tracef
(
" B k%d -> %s
\n
"
,
k
,
b
)
tracef
(
" B k%d -> %s
\n
"
,
k
,
b
)
// +bucket if that bucket is reached for the first time
// +bucket if that bucket is reached for the first time
if
!
b
.
done
{
if
!
b
.
done
{
var
δB
map
[
Key
]
ΔValue
var
δB
map
[
Key
]
ΔValue
bbucket
,
ok
:=
b
.
node
.
(
*
Bucket
)
bbucket
,
ok
:=
b
.
node
.
(
*
Bucket
)
if
ok
{
// !ok means ø tree
if
ok
{
// !ok means ø tree
δB
,
err
=
diffB
(
ctx
,
nil
,
bbucket
);
/*X*/
if
err
!=
nil
{
return
nil
,
err
}
δB
,
err
=
diffB
(
ctx
,
nil
,
bbucket
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
}
}
// δ <- δB
// δ <- δB
err
=
δMerge
(
δ
,
δB
);
/*X*/
if
err
!=
nil
{
return
nil
,
err
}
err
=
δMerge
(
δ
,
δB
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
// trackAdd.Add(b)
// trackAdd.Add(b)
// Akqueue <- δB
// Akqueue <- δB
...
@@ -994,18 +1021,18 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h
...
@@ -994,18 +1021,18 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h
tracef
(
"
\n
"
)
tracef
(
"
\n
"
)
tracef
(
" Akq: %s
\n
"
,
Akqueue
)
tracef
(
" Akq: %s
\n
"
,
Akqueue
)
for
k
:=
range
Akqueue
{
for
k
:=
range
Akqueue
{
a
,
err
:=
Av
.
GetToLeaf
(
ctx
,
k
);
/*X*/
if
err
!=
nil
{
return
nil
,
err
}
a
,
err
:=
Av
.
GetToLeaf
(
ctx
,
k
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
tracef
(
" A k%d -> %s
\n
"
,
k
,
a
)
tracef
(
" A k%d -> %s
\n
"
,
k
,
a
)
// -bucket if that bucket is reached for the first time
// -bucket if that bucket is reached for the first time
if
!
a
.
done
{
if
!
a
.
done
{
var
δA
map
[
Key
]
ΔValue
var
δA
map
[
Key
]
ΔValue
abucket
,
ok
:=
a
.
node
.
(
*
Bucket
)
abucket
,
ok
:=
a
.
node
.
(
*
Bucket
)
if
ok
{
// !ok means ø tree
if
ok
{
// !ok means ø tree
δA
,
err
=
diffB
(
ctx
,
abucket
,
nil
);
/*X*/
if
err
!=
nil
{
return
nil
,
err
}
δA
,
err
=
diffB
(
ctx
,
abucket
,
nil
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
}
}
// δ <- δA
// δ <- δA
err
=
δMerge
(
δ
,
δA
);
/*X*/
if
err
!=
nil
{
return
nil
,
err
}
err
=
δMerge
(
δ
,
δA
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
trackDel
.
Add
(
a
.
node
.
POid
())
trackDel
.
Add
(
a
.
node
.
POid
())
// Bkqueue <- δA
// Bkqueue <- δA
...
@@ -1024,7 +1051,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h
...
@@ -1024,7 +1051,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h
Akqueue
=
SetKey
{}
Akqueue
=
SetKey
{}
}
}
return
δ
,
nil
return
δ
,
δtrack
,
nil
}
}
...
...
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