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
Hide 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) {
...
@@ -256,14 +256,13 @@ func (A PPTreeSubSet) xUnionInplace(B PPTreeSubSet) {
}
}
// fixup performs scheduled δnchild adjustment.
// fixup performs scheduled δnchild adjustment.
// XXX place
func
(
A
PPTreeSubSet
)
fixup
(
δnchild
map
[
zodb
.
Oid
]
int
)
{
func
(
A
PPTreeSubSet
)
fixup
(
δnchild
map
[
zodb
.
Oid
]
int
)
{
A
.
xfixup
(
+
1
,
δnchild
)
A
.
xfixup
(
+
1
,
δnchild
)
}
}
func
(
A
PPTreeSubSet
)
xfixup
(
sign
int
,
δnchild
map
[
zodb
.
Oid
]
int
)
{
func
(
A
PPTreeSubSet
)
xfixup
(
sign
int
,
δnchild
map
[
zodb
.
Oid
]
int
)
{
gcq
:=
[]
zodb
.
Oid
{}
gcq
:=
[]
zodb
.
Oid
{}
for
oid
,
δnc
:=
range
δnchild
{
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
t
.
nchild
+=
sign
*
δnc
if
t
.
nchild
==
0
&&
/* not root node */
t
.
parent
!=
zodb
.
InvalidOid
{
if
t
.
nchild
==
0
&&
/* not root node */
t
.
parent
!=
zodb
.
InvalidOid
{
gcq
=
append
(
gcq
,
oid
)
gcq
=
append
(
gcq
,
oid
)
...
@@ -277,8 +276,8 @@ func (A PPTreeSubSet) xfixup(sign int, δnchild map[zodb.Oid]int) {
...
@@ -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.
// gc1 garbage-collects oid and cleans up its parent down-up.
func
(
tidx
PPTreeSubSet
)
gc1
(
oid
zodb
.
Oid
)
{
func
(
S
PPTreeSubSet
)
gc1
(
oid
zodb
.
Oid
)
{
t
,
present
:=
tidx
[
oid
]
t
,
present
:=
S
[
oid
]
if
!
present
{
if
!
present
{
return
// already not there
return
// already not there
}
}
...
@@ -286,15 +285,15 @@ func (tidx PPTreeSubSet) gc1(oid zodb.Oid) {
...
@@ -286,15 +285,15 @@ func (tidx PPTreeSubSet) gc1(oid zodb.Oid) {
panicf
(
"gc %s %v (nchild != 0)"
,
oid
,
t
)
panicf
(
"gc %s %v (nchild != 0)"
,
oid
,
t
)
}
}
delete
(
tidx
,
oid
)
delete
(
S
,
oid
)
oid
=
t
.
parent
oid
=
t
.
parent
for
oid
!=
zodb
.
InvalidOid
{
for
oid
!=
zodb
.
InvalidOid
{
t
:=
tidx
[
oid
]
t
:=
S
[
oid
]
t
.
nchild
--
t
.
nchild
--
if
t
.
nchild
>
0
||
/* root node */
t
.
parent
==
zodb
.
InvalidOid
{
if
t
.
nchild
>
0
||
/* root node */
t
.
parent
==
zodb
.
InvalidOid
{
break
break
}
}
delete
(
tidx
,
oid
)
delete
(
S
,
oid
)
oid
=
t
.
parent
oid
=
t
.
parent
}
}
}
}
...
@@ -317,35 +316,36 @@ func (A PPTreeSubSet) UnionInplace(B PPTreeSubSet) {
...
@@ -317,35 +316,36 @@ func (A PPTreeSubSet) UnionInplace(B PPTreeSubSet) {
A
.
xUnionInplace
(
B
)
A
.
xUnionInplace
(
B
)
}
}
// ApplyΔ applies δ to trackIdx. XXX
// ApplyΔ applies δ to S.
func
(
tidx
PPTreeSubSet
)
ApplyΔ
(
δ
*
ΔPPTreeSubSet
)
{
//
// See ΔPPTreeSubSet documentation for details.
func
(
S
PPTreeSubSet
)
ApplyΔ
(
δ
*
ΔPPTreeSubSet
)
{
if
debugPPSet
{
if
debugPPSet
{
fmt
.
Printf
(
"
\n\n
ApplyΔ
\n
"
)
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
"
,
δ
.
Del
)
fmt
.
Printf
(
" +: %s
\n
"
,
δ
.
Add
)
fmt
.
Printf
(
" +: %s
\n
"
,
δ
.
Add
)
fmt
.
Printf
(
" x: %v
\n
"
,
δ
.
δnchildNonLeafs
)
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
()
δ
.
Del
.
verify
()
δ
.
Add
.
verify
()
δ
.
Add
.
verify
()
defer
tidx
.
verify
()
defer
S
.
verify
()
tidx
.
xfixup
(
-
1
,
δ
.
δnchildNonLeafs
)
S
.
xfixup
(
-
1
,
δ
.
δnchildNonLeafs
)
tidx
.
xDifferenceInplace
(
δ
.
Del
)
S
.
xDifferenceInplace
(
δ
.
Del
)
tidx
.
xUnionInplace
(
δ
.
Add
)
S
.
xUnionInplace
(
δ
.
Add
)
tidx
.
xfixup
(
+
1
,
δ
.
δnchildNonLeafs
)
S
.
xfixup
(
+
1
,
δ
.
δnchildNonLeafs
)
}
}
// Path returns path leading to node specified by oid.
// Path returns path leading to node specified by oid.
//
//
// The node must be in the set.
// The node must be in the set.
// XXX place
func
(
S
PPTreeSubSet
)
Path
(
oid
zodb
.
Oid
)
(
path
[]
zodb
.
Oid
)
{
func
(
tidx
PPTreeSubSet
)
Path
(
oid
zodb
.
Oid
)
(
path
[]
zodb
.
Oid
)
{
for
{
for
{
t
,
ok
:=
tidx
[
oid
]
t
,
ok
:=
S
[
oid
]
if
!
ok
{
if
!
ok
{
panicf
(
"node %s is not in the set <- %v"
,
oid
,
path
)
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) {
...
@@ -361,9 +361,8 @@ func (tidx PPTreeSubSet) Path(oid zodb.Oid) (path []zodb.Oid) {
return
path
return
path
}
}
// XXX place
// XXX doc
// 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
// XXX assert Tree Tree ... Tree Bucket
// root := path[0].(*Tree).POid()
// root := path[0].(*Tree).POid()
...
@@ -371,12 +370,13 @@ func (tidx PPTreeSubSet) AddNodePath(path []Node) { // XXX Tree|Bucket; path[0]
...
@@ -371,12 +370,13 @@ func (tidx PPTreeSubSet) AddNodePath(path []Node) { // XXX Tree|Bucket; path[0]
for
_
,
node
:=
range
path
{
for
_
,
node
:=
range
path
{
oidv
=
append
(
oidv
,
node
.
POid
())
oidv
=
append
(
oidv
,
node
.
POid
())
}
}
tidx
.
AddPath
(
oidv
)
S
.
AddPath
(
oidv
)
}
}
func
(
tidx
PPTreeSubSet
)
AddPath
(
path
[]
zodb
.
Oid
)
{
// XXX doc
tidx
.
verify
()
func
(
S
PPTreeSubSet
)
AddPath
(
path
[]
zodb
.
Oid
)
{
defer
tidx
.
verify
()
S
.
verify
()
defer
S
.
verify
()
l
:=
len
(
path
)
l
:=
len
(
path
)
if
l
==
0
{
if
l
==
0
{
...
@@ -384,7 +384,7 @@ func (tidx PPTreeSubSet) AddPath(path []zodb.Oid) {
...
@@ -384,7 +384,7 @@ func (tidx PPTreeSubSet) AddPath(path []zodb.Oid) {
}
}
// don't explicitly keep track of embedded buckets - they all have
// 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.
// T/B2:b would lead to InvalidOid having multiple parents.
if
l
>=
2
&&
path
[
l
-
1
]
==
zodb
.
InvalidOid
{
if
l
>=
2
&&
path
[
l
-
1
]
==
zodb
.
InvalidOid
{
path
=
path
[
:
l
-
1
]
path
=
path
[
:
l
-
1
]
...
@@ -399,7 +399,7 @@ func (tidx PPTreeSubSet) AddPath(path []zodb.Oid) {
...
@@ -399,7 +399,7 @@ func (tidx PPTreeSubSet) AddPath(path []zodb.Oid) {
panicf
(
"path has node with invalid oid: %v"
,
path
)
panicf
(
"path has node with invalid oid: %v"
,
path
)
}
}
track
,
oldTrack
=
tidx
[
oid
]
track
,
oldTrack
=
S
[
oid
]
if
!
oldTrack
{
if
!
oldTrack
{
track
=
&
nodeInTree
{
parent
:
parent
,
nchild
:
0
}
// XXX
track
=
&
nodeInTree
{
parent
:
parent
,
nchild
:
0
}
// XXX
/*
/*
...
@@ -407,7 +407,7 @@ func (tidx PPTreeSubSet) AddPath(path []zodb.Oid) {
...
@@ -407,7 +407,7 @@ func (tidx PPTreeSubSet) AddPath(path []zodb.Oid) {
track.holes = SetKey{}
track.holes = SetKey{}
}
}
*/
*/
tidx
[
oid
]
=
track
S
[
oid
]
=
track
// XXX .trackNew += oid
// XXX .trackNew += oid
}
}
if
track
.
parent
!=
parent
{
if
track
.
parent
!=
parent
{
...
@@ -438,13 +438,13 @@ func (orig PPTreeSubSet) Clone() PPTreeSubSet {
...
@@ -438,13 +438,13 @@ func (orig PPTreeSubSet) Clone() PPTreeSubSet {
// equal returns whether a == b.
// equal returns whether a == b.
// XXX place
// XXX place
func
(
a
PPTreeSubSet
)
equal
(
b
PPTreeSubSet
)
bool
{
func
(
A
PPTreeSubSet
)
equal
(
B
PPTreeSubSet
)
bool
{
if
len
(
a
)
!=
len
(
b
)
{
if
len
(
A
)
!=
len
(
B
)
{
return
false
return
false
}
}
for
oid
,
ta
:=
range
a
{
for
oid
,
ta
:=
range
A
{
tb
,
ok
:=
b
[
oid
]
tb
,
ok
:=
B
[
oid
]
if
!
ok
{
if
!
ok
{
return
false
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