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
c9f93cf0
Commit
c9f93cf0
authored
Jun 14, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
9ac61959
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
107 additions
and
12 deletions
+107
-12
wcfs/internal/xbtree/δbtail.go
wcfs/internal/xbtree/δbtail.go
+107
-12
No files found.
wcfs/internal/xbtree/δbtail.go
View file @
c9f93cf0
...
...
@@ -313,7 +313,7 @@ func (δTtail *ΔTtail) rebuild(δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet P
// go backwards and merge vδT <- treediff(lo..hi/trackNew)
vδZ
:=
δZtail
.
Data
()
vδtrack
:=
[]
*
ΔPPTreeSubSet
{}
//
vδtrack := []*ΔPPTreeSubSet{}
for
i
:=
len
(
vδZ
)
-
1
;
i
>=
0
;
i
--
{
δZ
:=
vδZ
[
i
]
...
...
@@ -326,6 +326,19 @@ func (δTtail *ΔTtail) rebuild(δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet P
atPrev
=
δZtail
.
Tail
()
}
δtrackNew
,
δtkeycov
,
err
:=
δTtail
.
rebuild1
(
atPrev
,
δZ
,
trackNew
,
db
)
if
err
!=
nil
{
return
nil
,
err
}
trackNew
.
ApplyΔ
(
δtrackNew
)
// FIXME use δtkeycov to recompute track coverage
_
=
δtkeycov
// XXX update .KVAtTail, .lastRevOf
/*
δZTC, δtopsByRoot := δZConnectTracked(δZ.Changev, trackNew)
debugfΔBtail("\n rebuild @%s <- @%s\n", atPrev, δZ.Rev)
...
...
@@ -362,21 +375,12 @@ func (δTtail *ΔTtail) rebuild(δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet P
debugfΔBtail(" -> root<%s> δkv*: %v δtrack*: %v\n", root, δT, δtrack)
trackNew.ApplyΔ(δtrack)
vδtrack
=
append
([]
*
ΔPPTreeSubSet
{
δtrack
},
vδtrack
...
)
//
vδtrack = append([]*ΔPPTreeSubSet{δtrack}, vδtrack...)
if len(δT) == 0 { // an object might be resaved without change
continue
}
/* XXX kill
δTtail, ok := δBtail.vδTbyRoot[root]
if !ok {
// this root was not tracked before -> create δTtail for it with empty changes
δTtail = newΔTtail()
δBtail.vδTbyRoot[root] = δTtail
}
*/
// δTtail.vδT <- merge δT*
l := len(δTtail.vδT)
j := sort.Search(l, func(k int) bool {
...
...
@@ -391,7 +395,6 @@ func (δTtail *ΔTtail) rebuild(δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet P
}
δTcurr := δTtail.vδT[j]
for k, δv := range δT {
// the diff was backward; δTtail entries are with diff forward
δv.New, δv.Old = δv.Old, δv.New
...
...
@@ -408,6 +411,7 @@ func (δTtail *ΔTtail) rebuild(δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet P
// XXX update .KVAtTail, .lastRevOf
}
*/
}
/*
...
...
@@ -422,6 +426,96 @@ func (δTtail *ΔTtail) rebuild(δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet P
return
δtrackSet
,
nil
}
// rebuild1 rebuilds δT for single δZ.
//
// δtrackNew/δtkeycov represents how trackNew changes when going from atPrev <- δZ.Rev .
func
(
δTtail
*
ΔTtail
)
rebuild1
(
atPrev
zodb
.
Tid
,
δZ
zodb
.
ΔRevEntry
,
trackNew
PPTreeSubSet
,
db
*
zodb
.
DB
)
(
δtrackNew
*
ΔPPTreeSubSet
,
δtkeycov
*
RangedKeySet
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"rebuild1 %s<-%s"
,
atPrev
,
δZ
.
Rev
)
debugfΔBtail
(
"
\n
rebuild1 @%s <- @%s
\n
"
,
atPrev
,
δZ
.
Rev
)
debugfΔBtail
(
" δZ:
\t
%v
\n
"
,
δZ
.
Changev
)
debugfΔBtail
(
" trackNew: %v
\n
"
,
trackNew
)
defer
func
()
{
debugfΔBtail
(
"-> δtrackNew: %v
\n
"
,
δtrackNew
)
debugfΔBtail
(
"-> δtkeycov: %v
\n
"
,
δtkeycov
)
debugfΔBtail
(
"
\n\n
"
)
}()
δZTC
,
δtopsByRoot
:=
δZConnectTracked
(
δZ
.
Changev
,
trackNew
)
// skip opening DB connections if there is no change to this tree
if
len
(
δtopsByRoot
)
==
0
{
return
nil
,
nil
,
nil
}
if
len
(
δtopsByRoot
)
!=
1
{
panicf
(
"BUG: δtopsByRoot has > 1 entries: %v
\n
trackNew: %v
\n
δZ: %v"
,
δtopsByRoot
,
trackNew
,
δZ
)
}
var
root
zodb
.
Oid
var
δtops
SetOid
for
root_
,
δtops_
:=
range
δtopsByRoot
{
root
=
root_
δtops
=
δtops_
}
// open ZODB connection corresponding to "current" and "prev" states
txn
,
ctx
:=
transaction
.
New
(
context
.
TODO
())
// XXX
defer
txn
.
Abort
()
zconnPrev
,
err
:=
db
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
atPrev
})
if
err
!=
nil
{
return
nil
,
nil
,
err
}
zconnCurr
,
err
:=
db
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
δZ
.
Rev
})
if
err
!=
nil
{
return
nil
,
nil
,
err
}
// diff backwards curr -> prev
δT
,
δtrack
,
δtkeycov
,
err
:=
treediff
(
ctx
,
root
,
δtops
,
δZTC
,
trackNew
,
zconnCurr
,
zconnPrev
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
debugfΔBtail
(
" -> root<%s> δkv*: %v δtrack*: %v δtkeycov*: %v
\n
"
,
root
,
δT
,
δtrack
,
δtkeycov
)
if
len
(
δT
)
==
0
{
// an object might be resaved without change
return
δtrack
,
δtkeycov
,
nil
}
// δTtail.vδT <- merge δT*
l
:=
len
(
δTtail
.
vδT
)
j
:=
sort
.
Search
(
l
,
func
(
k
int
)
bool
{
return
δZ
.
Rev
<=
δTtail
.
vδT
[
k
]
.
Rev
})
if
j
==
l
||
δTtail
.
vδT
[
j
]
.
Rev
!=
δZ
.
Rev
{
δTcurr
:=
ΔTree
{
Rev
:
δZ
.
Rev
,
ΔKV
:
map
[
Key
]
ΔValue
{}}
// insert(@j, δTcurr)
δTtail
.
vδT
=
append
(
δTtail
.
vδT
[
:
j
],
append
([]
ΔTree
{
δTcurr
},
δTtail
.
vδT
[
j
:
]
...
)
...
)
}
δTcurr
:=
δTtail
.
vδT
[
j
]
for
k
,
δv
:=
range
δT
{
// the diff was backward; δTtail entries are with diff forward
δv
.
New
,
δv
.
Old
=
δv
.
Old
,
δv
.
New
δv_
,
already
:=
δTcurr
.
ΔKV
[
k
]
if
already
{
if
δv
!=
δv_
{
panicf
(
"[%v] inconsistent δv:
\n
δTcurr: %v
\n
δT: %v"
,
k
,
δTcurr
,
δT
)
}
}
else
{
δTcurr
.
ΔKV
[
k
]
=
δv
}
}
// XXX update .KVAtTail, .lastRevOf (here?)
return
δtrack
,
δtkeycov
,
nil
}
// Update updates δB with per-object level ZODB changes.
//
// Only those objects from δZ that belong to tracked set are guaranteed to be
...
...
@@ -524,6 +618,7 @@ if XXX_killWhenRebuildWorks {
δTKeyCov
.
ByRoot
[
root
]
=
δtkeycov
// XXX if δtkeycov != ø -> rebuild δTtail
// XXX here? or in the caller?
}
return
δB
,
δTKeyCov
,
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