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
bb76489c
Commit
bb76489c
authored
May 15, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7ffbe6ae
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
33 deletions
+33
-33
wcfs/pptreesubset.go
wcfs/pptreesubset.go
+33
-33
No files found.
wcfs/pptreesubset.go
View file @
bb76489c
...
...
@@ -256,14 +256,13 @@ func (A PPTreeSubSet) xUnionInplace(B PPTreeSubSet) {
}
// fixup performs scheduled δnchild adjustment.
// XXX place
func
(
A
PPTreeSubSet
)
fixup
(
δnchild
map
[
zodb
.
Oid
]
int
)
{
A
.
xfixup
(
+
1
,
δnchild
)
}
func
(
A
PPTreeSubSet
)
xfixup
(
sign
int
,
δnchild
map
[
zodb
.
Oid
]
int
)
{
gcq
:=
[]
zodb
.
Oid
{}
for
oid
,
δnc
:=
range
δnchild
{
t
:=
A
[
oid
]
// XXX t can be nil -> XXX no must be there as A is
connected
t
:=
A
[
oid
]
// t != nil as A is PP-
connected
t
.
nchild
+=
sign
*
δnc
if
t
.
nchild
==
0
&&
/* not root node */
t
.
parent
!=
zodb
.
InvalidOid
{
gcq
=
append
(
gcq
,
oid
)
...
...
@@ -277,8 +276,8 @@ func (A PPTreeSubSet) xfixup(sign int, δnchild map[zodb.Oid]int) {
}
// gc1 garbage-collects oid and cleans up its parent down-up.
func
(
tidx
PPTreeSubSet
)
gc1
(
oid
zodb
.
Oid
)
{
t
,
present
:=
tidx
[
oid
]
func
(
S
PPTreeSubSet
)
gc1
(
oid
zodb
.
Oid
)
{
t
,
present
:=
S
[
oid
]
if
!
present
{
return
// already not there
}
...
...
@@ -286,15 +285,15 @@ func (tidx PPTreeSubSet) gc1(oid zodb.Oid) {
panicf
(
"gc %s %v (nchild != 0)"
,
oid
,
t
)
}
delete
(
tidx
,
oid
)
delete
(
S
,
oid
)
oid
=
t
.
parent
for
oid
!=
zodb
.
InvalidOid
{
t
:=
tidx
[
oid
]
t
:=
S
[
oid
]
t
.
nchild
--
if
t
.
nchild
>
0
||
/* root node */
t
.
parent
==
zodb
.
InvalidOid
{
break
}
delete
(
tidx
,
oid
)
delete
(
S
,
oid
)
oid
=
t
.
parent
}
}
...
...
@@ -317,35 +316,36 @@ func (A PPTreeSubSet) UnionInplace(B PPTreeSubSet) {
A
.
xUnionInplace
(
B
)
}
// ApplyΔ applies δ to trackIdx. XXX
func
(
tidx
PPTreeSubSet
)
ApplyΔ
(
δ
*
ΔPPTreeSubSet
)
{
// ApplyΔ applies δ to S.
//
// See ΔPPTreeSubSet documentation for details.
func
(
S
PPTreeSubSet
)
ApplyΔ
(
δ
*
ΔPPTreeSubSet
)
{
if
debugPPSet
{
fmt
.
Printf
(
"
\n\n
ApplyΔ
\n
"
)
fmt
.
Printf
(
" A: %s
\n
"
,
tidx
)
fmt
.
Printf
(
" A: %s
\n
"
,
S
)
fmt
.
Printf
(
" -: %s
\n
"
,
δ
.
Del
)
fmt
.
Printf
(
" +: %s
\n
"
,
δ
.
Add
)
fmt
.
Printf
(
" x: %v
\n
"
,
δ
.
δnchildNonLeafs
)
defer
fmt
.
Printf
(
"
\n
->B: %s
\n
"
,
tidx
)
defer
fmt
.
Printf
(
"
\n
->B: %s
\n
"
,
S
)
}
tidx
.
verify
()
S
.
verify
()
δ
.
Del
.
verify
()
δ
.
Add
.
verify
()
defer
tidx
.
verify
()
defer
S
.
verify
()
tidx
.
xfixup
(
-
1
,
δ
.
δnchildNonLeafs
)
tidx
.
xDifferenceInplace
(
δ
.
Del
)
tidx
.
xUnionInplace
(
δ
.
Add
)
tidx
.
xfixup
(
+
1
,
δ
.
δnchildNonLeafs
)
S
.
xfixup
(
-
1
,
δ
.
δnchildNonLeafs
)
S
.
xDifferenceInplace
(
δ
.
Del
)
S
.
xUnionInplace
(
δ
.
Add
)
S
.
xfixup
(
+
1
,
δ
.
δnchildNonLeafs
)
}
// Path returns path leading to node specified by oid.
//
// The node must be in the set.
// XXX place
func
(
tidx
PPTreeSubSet
)
Path
(
oid
zodb
.
Oid
)
(
path
[]
zodb
.
Oid
)
{
func
(
S
PPTreeSubSet
)
Path
(
oid
zodb
.
Oid
)
(
path
[]
zodb
.
Oid
)
{
for
{
t
,
ok
:=
tidx
[
oid
]
t
,
ok
:=
S
[
oid
]
if
!
ok
{
panicf
(
"node %s is not in the set <- %v"
,
oid
,
path
)
}
...
...
@@ -361,9 +361,8 @@ func (tidx PPTreeSubSet) Path(oid zodb.Oid) (path []zodb.Oid) {
return
path
}
// XXX place
// XXX doc
func
(
tidx
PPTreeSubSet
)
AddNodePath
(
path
[]
Node
)
{
// XXX Tree|Bucket; path[0] = root
func
(
S
PPTreeSubSet
)
AddNodePath
(
path
[]
Node
)
{
// XXX Tree|Bucket; path[0] = root
// XXX assert Tree Tree ... Tree Bucket
// root := path[0].(*Tree).POid()
...
...
@@ -371,12 +370,13 @@ func (tidx PPTreeSubSet) AddNodePath(path []Node) { // XXX Tree|Bucket; path[0]
for
_
,
node
:=
range
path
{
oidv
=
append
(
oidv
,
node
.
POid
())
}
tidx
.
AddPath
(
oidv
)
S
.
AddPath
(
oidv
)
}
func
(
tidx
PPTreeSubSet
)
AddPath
(
path
[]
zodb
.
Oid
)
{
tidx
.
verify
()
defer
tidx
.
verify
()
// XXX doc
func
(
S
PPTreeSubSet
)
AddPath
(
path
[]
zodb
.
Oid
)
{
S
.
verify
()
defer
S
.
verify
()
l
:=
len
(
path
)
if
l
==
0
{
...
...
@@ -384,7 +384,7 @@ func (tidx PPTreeSubSet) AddPath(path []zodb.Oid) {
}
// don't explicitly keep track of embedded buckets - they all have
// InvalidOid, and thus, if kept in
tidx
, e.g. T/B1:a and another
// InvalidOid, and thus, if kept in
S
, e.g. T/B1:a and another
// T/B2:b would lead to InvalidOid having multiple parents.
if
l
>=
2
&&
path
[
l
-
1
]
==
zodb
.
InvalidOid
{
path
=
path
[
:
l
-
1
]
...
...
@@ -399,7 +399,7 @@ func (tidx PPTreeSubSet) AddPath(path []zodb.Oid) {
panicf
(
"path has node with invalid oid: %v"
,
path
)
}
track
,
oldTrack
=
tidx
[
oid
]
track
,
oldTrack
=
S
[
oid
]
if
!
oldTrack
{
track
=
&
nodeInTree
{
parent
:
parent
,
nchild
:
0
}
// XXX
/*
...
...
@@ -407,7 +407,7 @@ func (tidx PPTreeSubSet) AddPath(path []zodb.Oid) {
track.holes = SetKey{}
}
*/
tidx
[
oid
]
=
track
S
[
oid
]
=
track
// XXX .trackNew += oid
}
if
track
.
parent
!=
parent
{
...
...
@@ -438,13 +438,13 @@ func (orig PPTreeSubSet) Clone() PPTreeSubSet {
// equal returns whether a == b.
// XXX place
func
(
a
PPTreeSubSet
)
equal
(
b
PPTreeSubSet
)
bool
{
if
len
(
a
)
!=
len
(
b
)
{
func
(
A
PPTreeSubSet
)
equal
(
B
PPTreeSubSet
)
bool
{
if
len
(
A
)
!=
len
(
B
)
{
return
false
}
for
oid
,
ta
:=
range
a
{
tb
,
ok
:=
b
[
oid
]
for
oid
,
ta
:=
range
A
{
tb
,
ok
:=
B
[
oid
]
if
!
ok
{
return
false
}
...
...
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