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
b8be35ec
Commit
b8be35ec
authored
Oct 06, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a8945cbf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
7 deletions
+48
-7
wcfs/internal/xbtree/δbtail.go
wcfs/internal/xbtree/δbtail.go
+48
-7
No files found.
wcfs/internal/xbtree/δbtail.go
View file @
b8be35ec
...
...
@@ -283,6 +283,9 @@ func (orig *_ΔTtail) Clone() *_ΔTtail {
// vδTClone returns deep copy of []ΔTree.
func
vδTClone
(
orig
[]
ΔTree
)
[]
ΔTree
{
if
orig
==
nil
{
return
nil
}
klon
:=
make
([]
ΔTree
,
0
,
len
(
orig
))
for
_
,
origδT
:=
range
orig
{
klonδT
:=
ΔTree
{
...
...
@@ -512,10 +515,16 @@ func (δBtail *ΔBtail) rebuild1KeyIfNeeded(root zodb.Oid, key Key) error {
func
(
δBtail
*
ΔBtail
)
rebuild1
(
root
zodb
.
Oid
)
error
{
// XXX locking
δTtail
:=
δBtail
.
byRoot
[
root
]
// must be there
δtrackSet
,
δrevSet
,
err
:=
δTtail
.
rebuild
(
root
,
δBtail
.
δZtail
,
δBtail
.
db
)
// δtrackSet, δrevSet, err := δTtail.rebuild(root, δBtail.δZtail, δBtail.db)
trackNew
:=
δTtail
.
trackNew
δTtail
.
trackNew
=
blib
.
PPTreeSubSet
{}
vδTnew
,
δtrackSet
,
err
:=
vδTBuild
(
root
,
trackNew
,
δBtail
.
δZtail
,
δBtail
.
db
)
if
err
!=
nil
{
return
err
}
// XXX comment about RCU snapshot
δTtail
.
vδT
=
vδTClone
(
δTtail
.
vδT
)
δrevSet
:=
vδTMergeInplace
(
&
δTtail
.
vδT
,
vδTnew
)
δBtail
.
trackSet
.
UnionInplace
(
δtrackSet
)
δBtail
.
vδBroots_Update
(
root
,
δrevSet
)
return
nil
...
...
@@ -657,19 +666,41 @@ func vδTBuild1(atPrev zodb.Tid, δZ zodb.ΔRevEntry, trackNew blib.PPTreeSubSet
debugfΔBtail
(
" -> root<%s> δkv*: %v δtrack*: %v δtkeycov*: %v
\n
"
,
root
,
δT
,
δtrack
,
δtkeycov
)
for
_
,
δv
:=
range
δT
{
for
k
,
δv
:=
range
δT
{
// the diff was backward; vδT entries are with diff forward
δv
.
New
,
δv
.
Old
=
δv
.
Old
,
δv
.
New
δT
[
k
]
=
δv
}
return
δT
,
δtrack
,
δtkeycov
,
nil
}
// vδTMergeInplace merges vδTnew into vδT.
//
// δrevSet indicates set of new revisions created in vδT.
// vδT is modified inplace.
//
// XXX test
func
vδTMergeInplace
(
pvδT
*
[]
ΔTree
,
vδTnew
[]
ΔTree
)
(
δrevSet
setTid
)
{
// TODO optimize to go through vδT and vδTnew sequentially if needed
δrevSet
=
setTid
{}
for
_
,
δT
:=
range
vδTnew
{
newRevEntry
:=
vδTMerge1Inplace
(
pvδT
,
δT
)
if
newRevEntry
{
δrevSet
.
Add
(
δT
.
Rev
)
}
}
return
δrevSet
}
// vδTMerge1Inplace merges one δT entry into vδT.
//
// newRevEntry indicates whether δT.Rev was not there before in vδT.
// vδT is modified inplace.
// XXX test for vδTMerge
func
vδTMerge1Inplace
(
pvδT
*
[]
ΔTree
,
δT
ΔTree
)
{
//
// XXX test
func
vδTMerge1Inplace
(
pvδT
*
[]
ΔTree
,
δT
ΔTree
)
(
newRevEntry
bool
)
{
vδT
:=
*
pvδT
l
:=
len
(
vδT
)
...
...
@@ -677,7 +708,7 @@ func vδTMerge1Inplace(pvδT *[]ΔTree, δT ΔTree) {
return
δT
.
Rev
<=
vδT
[
k
]
.
Rev
})
if
j
==
l
||
vδT
[
j
]
.
Rev
!=
δT
.
Rev
{
//
newRevEntry = true
newRevEntry
=
true
δTcurr
:=
ΔTree
{
Rev
:
δT
.
Rev
,
KV
:
map
[
Key
]
ΔValue
{}}
// insert(@j, δTcurr)
vδT
=
append
(
vδT
[
:
j
],
...
...
@@ -698,9 +729,11 @@ func vδTMerge1Inplace(pvδT *[]ΔTree, δT ΔTree) {
}
*
pvδT
=
vδT
return
newRevEntry
}
/*
// rebuild rebuilds _ΔTtail taking trackNew requests into account.
//
// It returns:
...
...
@@ -783,7 +816,9 @@ func (δTtail *_ΔTtail) rebuild(root zodb.Oid, δZtail *zodb.ΔTail, db *zodb.D
return trackNew, δrevSet, nil
}
*/
/*
// rebuild1 rebuilds δT for single δZ.
//
// δtrackNew/δtkeycov represents how trackNew changes when going through `atPrev <- δZ.Rev` .
...
...
@@ -877,6 +912,7 @@ func (δTtail *_ΔTtail) rebuild1(atPrev zodb.Tid, δZ zodb.ΔRevEntry, trackNew
return δtrack, δtkeycov, newRevEntry, nil
}
*/
// widenTrackNew widens trackNew to cover δtkeycov.
func
widenTrackNew
(
trackNew
blib
.
PPTreeSubSet
,
δtkeycov
*
blib
.
RangedKeySet
,
root
zodb
.
Oid
,
at
zodb
.
Tid
,
db
*
zodb
.
DB
)
(
err
error
)
{
...
...
@@ -940,17 +976,22 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
if
err
!=
nil
{
return
ΔB
{},
err
}
// XXX vvv kill?
if
!
δTtail
.
trackNew
.
Empty
()
{
panicf
(
"BUG: ΔBtail.Update: ΔTtail<%s>.trackNew != ø after _Update1"
,
root
)
}
δTtail
.
trackNew
=
trackNew
//
δTtail.trackNew = trackNew
// NOTE we cannot skip computing diff for HEAD~..HEAD
// even after _Update1 because _Update1 was working with different trackNew.
δtrackSet
,
δrevSet
,
err
:=
δTtail
.
rebuild
(
root
,
δBtail
.
δZtail
,
δBtail
.
db
)
// δtrackSet, δrevSet, err := δTtail.rebuild(root, δBtail.δZtail, δBtail.db)
vδTnew
,
δtrackSet
,
err
:=
vδTBuild
(
root
,
trackNew
,
δBtail
.
δZtail
,
δBtail
.
db
)
if
err
!=
nil
{
return
ΔB
{},
err
}
// XXX comment about RCU snapshot
δTtail
.
vδT
=
vδTClone
(
δTtail
.
vδT
)
δrevSet
:=
vδTMergeInplace
(
&
δTtail
.
vδT
,
vδTnew
)
δBtail
.
trackSet
.
UnionInplace
(
δtrackSet
)
δBtail
.
vδBroots_Update
(
root
,
δrevSet
)
}
...
...
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