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
bc8389ed
Commit
bc8389ed
authored
Jun 22, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
07981138
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
62 deletions
+8
-62
wcfs/δbtail.go
wcfs/δbtail.go
+5
-61
wcfs/δbtail_test.go
wcfs/δbtail_test.go
+3
-1
No files found.
wcfs/δbtail.go
View file @
bc8389ed
...
...
@@ -348,38 +348,6 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
fmt
.
Printf
(
"
\n
Update δZ: %v
\n
"
,
δZ
.
Changev
)
fmt
.
Printf
(
"trackIdx: %v
\n
"
,
δBtail
.
trackIdx
)
/*
// {} root -> {oid} changed under that root in tracked set
// XXX dumb -> rework to toposort and getting root from tops only
rootOf := func(node zodb.Oid) (root zodb.Oid, ok bool) {
track, ok := δBtail.trackIdx[node]
if !ok {
return zodb.InvalidOid, false
}
for track.parent != zodb.InvalidOid {
node = track.parent
track = δBtail.trackIdx[node] // must be present
}
return node, true
}
δZByRoot := map[zodb.Oid]SetOid{}
for _, oid := range δZ.Changev {
root, ok := rootOf(oid)
if !ok {
continue
}
δZT, ok := δZByRoot[root]
if !ok {
δZT = SetOid{}
δZByRoot[root] = δZT
}
δZT.Add(oid)
}
fmt.Println("δZByRoot:", δZByRoot)
*/
δZTC
,
δtopsByRoot
:=
δBtail
.
δZConnectTracked
(
δZ
)
δB
:=
ΔB
{
Rev
:
δZ
.
Tid
,
ByRoot
:
make
(
map
[
zodb
.
Oid
]
map
[
Key
]
ΔValue
)}
...
...
@@ -402,9 +370,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
return
ΔB
{},
err
}
// for root, δZT := range δZByRoot {
for
root
,
δtops
:=
range
δtopsByRoot
{
// δT, err := treediff(ctx, root, δZT, δBtail.trackIdx, zconnOld, zconnNew)
δT
,
err
:=
treediff
(
ctx
,
root
,
δtops
,
δZTC
,
δBtail
.
trackIdx
,
zconnOld
,
zconnNew
)
if
err
!=
nil
{
return
ΔB
{},
err
...
...
@@ -416,24 +382,8 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
}
return
δB
,
nil
/* TODO btree-diff:
zconnNew = db.Open(δZ.rev)
defer(zconnNew.close)
for root, δZ in δbZ:
toposort(δZ)
for δ in δZ:
T | B = zconnOld.Get(δ) // XXX .zconnOld must be at .head and active
T' | B' = zconnNew.Get(δ)
diff(T, T')
diff(B, B')
...
.δBtail <- (δZ.rev, [](root, []key))
XXX rebuilf lastRevOf
*/
// XXX .δBtail <- (δZ.rev, [](root, []key))
// XXX rebuilf lastRevOf
}
// δZConnectTracked computes connected closure of δZ/T.
...
...
@@ -504,9 +454,9 @@ func (δBtail *ΔBtail) δZConnectTracked(δZv *zodb.EventCommit) (δZTC SetOid,
// treediff computes δT for tree specified by root in between old..new.
//
//
XXX only for tracked
// δZT
is δZ/T - subset of δZ(old..new) that touches tracked nodes of T.
//
func treediff(ctx context.Context, root zodb.Oid, δZT SetOid, trackIdx map[zodb.Oid]nodeTrack, zconnOld, zconnNew *zodb.Connection) (δT map[Key]ΔValue, err error) {
//
δtops is set of top nodes for changed subtrees.
// δZT
C is connected(δZ/T) - connected closure for subset of δZ(old..new) that
//
touches tracked nodes of T.
func
treediff
(
ctx
context
.
Context
,
root
zodb
.
Oid
,
δtops
SetOid
,
δZTC
SetOid
,
trackIdx
map
[
zodb
.
Oid
]
nodeTrack
,
zconnOld
,
zconnNew
*
zodb
.
Connection
)
(
δT
map
[
Key
]
ΔValue
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"treediff %s..%s %s"
,
zconnOld
.
At
(),
zconnNew
.
At
(),
root
)
// XXX zconnX -> a, b ?
...
...
@@ -514,12 +464,6 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
fmt
.
Printf
(
"treediff %s δtops: %v δZTC: %v
\n
"
,
root
,
δtops
,
δZTC
)
defer
fmt
.
Printf
(
"
\n
"
)
/*
// XXX δZT -> δZTC (all changed nodes are connected)
// e.g. t₀->t₁->b₂ δZ={t₀ b₂} -> δZC=δZ+{t₁}
δZTC := δZT // FIXME stub
*/
δT
=
map
[
Key
]
ΔValue
{}
for
top
:=
range
δtops
{
// XXX -> sorted?
...
...
wcfs/δbtail_test.go
View file @
bc8389ed
...
...
@@ -756,7 +756,9 @@ func TestΔBTail(t *testing.T) {
// test known cases going through tree1 -> tree2 -> ...
testv
:=
[]
interface
{}
{
"T2/B1:a-B2:c"
,
"T2,3/B1:a-B2:c-B3:c"
,
//"T2/B1:a-B2:c", "T2,3/B1:a-B2:c-B3:c",
"T2,3/B1:a-B2:b-B3:c"
,
"T/B1:a,2:b"
,
"T2,3/B1:a-B2:c-B3:c"
,
"T/B1:a,2:b"
,
///*
"T/B:"
,
...
...
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