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
9d1dc98b
Commit
9d1dc98b
authored
Sep 09, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7981f7c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
14 deletions
+34
-14
wcfs/δbtail.go
wcfs/δbtail.go
+34
-14
No files found.
wcfs/δbtail.go
View file @
9d1dc98b
...
...
@@ -221,31 +221,42 @@ func (tidx trackIndex) gc1(oid zodb.Oid) {
}
delete
(
tidx
,
oid
)
parent
:
=
t
.
parent
for
parent
!=
zodb
.
InvalidOid
{
t
:=
tidx
[
parent
]
oid
=
t
.
parent
for
oid
!=
zodb
.
InvalidOid
{
t
:=
tidx
[
oid
]
t
.
nchild
--
if
t
.
nchild
>
0
{
if
t
.
nchild
>
0
||
/* root node */
t
.
parent
==
zodb
.
InvalidOid
{
break
}
delete
(
tidx
,
parent
)
parent
=
t
.
parent
delete
(
tidx
,
oid
)
oid
=
t
.
parent
}
}
// ApplyΔ applies δ to trackIdx. XXX
func
(
tidx
trackIndex
)
ApplyΔ
(
δ
*
δtrackIndex
)
{
//fmt.Printf("\n\nApplyΔ\n")
//fmt.Printf("\ttidx: %v\n", tidx)
//fmt.Printf("\tDelLeaf: %v\n", δ.DelLeaf)
//fmt.Printf("\tAdd: %v\n", δ.Add)
//defer fmt.Printf("\n\t-> tidx: %v\n", tidx)
δnchild
:=
map
[
zodb
.
Oid
]
int
{}
// remove leafs and thier parents
for
leaf
:=
range
δ
.
DelLeaf
{
tidx
.
gc1
(
leaf
)
t
,
present
:=
tidx
[
leaf
]
if
!
present
{
continue
// already not there
}
delete
(
tidx
,
leaf
)
if
t
.
parent
!=
zodb
.
InvalidOid
{
δnchild
[
t
.
parent
]
-=
1
}
}
// process adds
δnchild
:=
map
[
zodb
.
Oid
]
int
{}
for
oid
,
δt
:=
range
δ
.
Add
{
t
,
already
:=
tidx
[
oid
]
if
already
{
...
...
@@ -262,14 +273,18 @@ func (tidx trackIndex) ApplyΔ(δ *δtrackIndex) {
δnchild
[
t
.
parent
]
+=
1
// remeber to nchild++ in parent
}
}
// perform scheduled δnchild adjustment
gcq
:=
[]
zodb
.
Oid
{}
for
oid
,
δnc
:=
range
δnchild
{
t
:=
tidx
[
oid
]
t
:=
tidx
[
oid
]
// XXX t can be nil -> XXX no must be there as tidx is connected
t
.
nchild
+=
δnc
if
t
.
nchild
==
0
{
if
t
.
nchild
==
0
&&
/* not root node */
t
.
parent
!=
zodb
.
InvalidOid
{
gcq
=
append
(
gcq
,
oid
)
}
}
// GC parents that became to have .nchild == 0
for
_
,
oid
:=
range
gcq
{
tidx
.
gc1
(
oid
)
}
...
...
@@ -842,10 +857,15 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
}
}
// adjust trackIdx
for
_
,
δtrack
:=
range
δtrackv
{
trackIdx
.
ApplyΔ
(
δtrack
)
// adjust trackIdx by merge(δtrackTops)
δtrack
:=
&
δtrackIndex
{
DelLeaf
:
SetOid
{},
Add
:
trackIndex
{}}
for
_
,
δ
:=
range
δtrackv
{
δtrack
.
DelLeaf
.
Update
(
δ
.
DelLeaf
)
for
oid
,
t
:=
range
δ
.
Add
{
δtrack
.
Add
[
oid
]
=
t
// XXX verify changes from 2 δtrackTops are consistent
}
}
trackIdx
.
ApplyΔ
(
δtrack
)
return
δT
,
nil
}
...
...
@@ -1504,7 +1524,7 @@ func pop(nodeStk *[]*nodeInRange) *nodeInRange {
}
const
debug
=
tru
e
const
debug
=
fals
e
func
tracef
(
format
string
,
argv
...
interface
{})
{
if
debug
{
fmt
.
Printf
(
format
,
argv
...
)
...
...
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