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
5a1bdf50
Commit
5a1bdf50
authored
Sep 22, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c267c969
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
wcfs/internal/xbtree/treediff.go
wcfs/internal/xbtree/treediff.go
+11
-7
No files found.
wcfs/internal/xbtree/treediff.go
View file @
5a1bdf50
...
@@ -324,9 +324,13 @@ func (rs rangeSplit) String() string {
...
@@ -324,9 +324,13 @@ func (rs rangeSplit) String() string {
// treediff computes δT/δtrack/δtkeycov for tree/trackSet specified by root in between old..new.
// treediff computes δT/δtrack/δtkeycov for tree/trackSet specified by root in between old..new.
//
//
// It is the main entry-point for BTree-diff algorithm. XXX -> overview
//
// δtops is set of top nodes for changed subtrees.
// δtops is set of top nodes for changed subtrees.
// δZTC is connected(δZ/T) - connected closure for subset of δZ(old..new) that
// δZTC is connected(δZ/T) - connected closure for subset of δZ(old..new) that
// touches tracked nodes of T.
// touches tracked nodes of T.
//
// Use δZConnectTracked to prepare δtops and δZTC.
func
treediff
(
ctx
context
.
Context
,
root
zodb
.
Oid
,
δtops
setOid
,
δZTC
setOid
,
trackSet
blib
.
PPTreeSubSet
,
zconnOld
,
zconnNew
*
zodb
.
Connection
)
(
δT
map
[
Key
]
ΔValue
,
δtrack
*
blib
.
ΔPPTreeSubSet
,
δtkeycov
*
blib
.
RangedKeySet
,
err
error
)
{
func
treediff
(
ctx
context
.
Context
,
root
zodb
.
Oid
,
δtops
setOid
,
δZTC
setOid
,
trackSet
blib
.
PPTreeSubSet
,
zconnOld
,
zconnNew
*
zodb
.
Connection
)
(
δT
map
[
Key
]
ΔValue
,
δtrack
*
blib
.
ΔPPTreeSubSet
,
δtkeycov
*
blib
.
RangedKeySet
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"treediff %s..%s %s"
,
zconnOld
.
At
(),
zconnNew
.
At
(),
root
)
defer
xerr
.
Contextf
(
&
err
,
"treediff %s..%s %s"
,
zconnOld
.
At
(),
zconnNew
.
At
(),
root
)
...
@@ -340,7 +344,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops setOid, δZTC setOid, t
...
@@ -340,7 +344,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops setOid, δZTC setOid, t
δtrackv
:=
[]
*
blib
.
ΔPPTreeSubSet
{}
δtrackv
:=
[]
*
blib
.
ΔPPTreeSubSet
{}
for
top
:=
range
δtops
{
// XXX -> sorted?
for
top
:=
range
δtops
{
a
,
err1
:=
zgetNodeOrNil
(
ctx
,
zconnOld
,
top
)
a
,
err1
:=
zgetNodeOrNil
(
ctx
,
zconnOld
,
top
)
b
,
err2
:=
zgetNodeOrNil
(
ctx
,
zconnNew
,
top
)
b
,
err2
:=
zgetNodeOrNil
(
ctx
,
zconnNew
,
top
)
err
:=
xerr
.
Merge
(
err1
,
err2
)
err
:=
xerr
.
Merge
(
err1
,
err2
)
...
@@ -353,15 +357,15 @@ func treediff(ctx context.Context, root zodb.Oid, δtops setOid, δZTC setOid, t
...
@@ -353,15 +357,15 @@ func treediff(ctx context.Context, root zodb.Oid, δtops setOid, δZTC setOid, t
return
nil
,
nil
,
nil
,
err
return
nil
,
nil
,
nil
,
err
}
}
// FIXME -> merge (VDEL vs add)
// XXX no - not needed here - keys cannot migrate in between two disconnected subtrees
// -> assert that keys from different δtop do not overlap
// DEL k -> Tkextra += k
// +k -> Tkextra -= k
debugfDiff
(
"-> δtop: %v
\n
"
,
δtop
)
debugfDiff
(
"-> δtop: %v
\n
"
,
δtop
)
debugfDiff
(
"-> δtrackTop: %v
\n
"
,
δtrackTop
)
debugfDiff
(
"-> δtrackTop: %v
\n
"
,
δtrackTop
)
debugfDiff
(
"-> δtkeycovTop: %v
\n
"
,
δtkeycovTop
)
debugfDiff
(
"-> δtkeycovTop: %v
\n
"
,
δtkeycovTop
)
for
k
,
δv
:=
range
δtop
{
for
k
,
δv
:=
range
δtop
{
// NOTE keys cannot migrate in between two disconnected subtrees
δv_
,
kdup
:=
δT
[
k
]
if
kdup
{
panicf
(
"BUG: key %v present in two disconnected subtrees; δv1: %s δv2: %s"
,
k
,
δv_
,
δv
)
}
δT
[
k
]
=
δv
δT
[
k
]
=
δv
}
}
...
@@ -369,7 +373,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops setOid, δZTC setOid, t
...
@@ -369,7 +373,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops setOid, δZTC setOid, t
δtkeycov
.
UnionInplace
(
δtkeycovTop
)
δtkeycov
.
UnionInplace
(
δtkeycovTop
)
}
}
//
adjust trackSet
by merge(δtrackTops)
//
trackSet should be adjusted
by merge(δtrackTops)
for
_
,
δ
:=
range
δtrackv
{
for
_
,
δ
:=
range
δtrackv
{
δtrack
.
Update
(
δ
)
δtrack
.
Update
(
δ
)
}
}
...
...
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