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
e2614eb3
Commit
e2614eb3
authored
Sep 09, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
231a8e52
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
18 deletions
+33
-18
wcfs/δbtail.go
wcfs/δbtail.go
+33
-18
No files found.
wcfs/δbtail.go
View file @
e2614eb3
...
...
@@ -210,6 +210,29 @@ type δtrackIndex struct {
Add
trackIndex
}
// gc1 garbage-collects oid and cleans up its parent down-up.
func
(
tidx
trackIndex
)
gc1
(
oid
zodb
.
Oid
)
{
t
,
present
:=
tidx
[
oid
]
if
!
present
{
return
// already not there
}
if
t
.
nchild
!=
0
{
panicf
(
"gc %v (nchild != 0)"
,
t
)
}
delete
(
tidx
,
oid
)
parent
:=
t
.
parent
for
parent
!=
zodb
.
InvalidOid
{
t
:=
tidx
[
parent
]
t
.
nchild
--
if
t
.
nchild
>
0
{
break
}
delete
(
tidx
,
parent
)
parent
=
t
.
parent
}
}
// ApplyΔ applies δ to trackIdx. XXX
func
(
tidx
trackIndex
)
ApplyΔ
(
δ
*
δtrackIndex
)
{
fmt
.
Printf
(
"
\n\n
ApplyΔ
\n
"
)
...
...
@@ -218,22 +241,7 @@ func (tidx trackIndex) ApplyΔ(δ *δtrackIndex) {
// remove leafs and thier parents
for
leaf
:=
range
δ
.
DelLeaf
{
t
,
present
:=
tidx
[
leaf
]
if
!
present
{
continue
// leaf already not there
}
delete
(
tidx
,
leaf
)
parent
:=
t
.
parent
for
parent
!=
zodb
.
InvalidOid
{
t
:=
tidx
[
parent
]
t
.
nchild
--
if
t
.
nchild
>
0
{
break
}
delete
(
tidx
,
parent
)
parent
=
t
.
parent
}
tidx
.
gc1
(
leaf
)
}
// process adds
...
...
@@ -254,9 +262,16 @@ func (tidx trackIndex) ApplyΔ(δ *δtrackIndex) {
δnchild
[
t
.
parent
]
+=
1
// remeber to nchild++ in parent
}
}
gcq
:=
[]
zodb
.
Oid
{}
for
parent
,
δnc
:=
range
δnchild
{
tidx
[
parent
]
.
nchild
+=
δnc
// XXX .nchild == 0 - remove ?
t
:=
tidx
[
parent
]
t
.
nchild
+=
δnc
if
t
.
nchild
==
0
{
gcq
=
append
(
gcq
,
t
.
parent
)
}
}
for
_
,
oid
:=
range
gcq
{
tidx
.
gc1
(
oid
)
}
}
...
...
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