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
01b98455
Commit
01b98455
authored
Jul 01, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7ed177e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
15 deletions
+25
-15
wcfs/internal/xbtree/blib/pptreesubset.go
wcfs/internal/xbtree/blib/pptreesubset.go
+21
-11
wcfs/internal/xbtree/treediff.go
wcfs/internal/xbtree/treediff.go
+4
-4
No files found.
wcfs/internal/xbtree/blib/pptreesubset.go
View file @
01b98455
...
...
@@ -61,6 +61,16 @@ type nodeInTree struct {
nchild
int
// number of direct children in PPTreeSubSet referring to this node
}
// Parent returns parent of this node.
func
(
n
*
nodeInTree
)
Parent
()
zodb
.
Oid
{
return
n
.
parent
}
// NChild returns number of children of this node in the tree subset.
func
(
n
*
nodeInTree
)
NChild
()
int
{
return
n
.
nchild
}
// Has returns whether node is in the set.
func
(
S
PPTreeSubSet
)
Has
(
oid
zodb
.
Oid
)
bool
{
_
,
ok
:=
S
[
oid
]
...
...
@@ -464,20 +474,20 @@ func (t nodeInTree) String() string {
// The second component with "-22" builds from leaf, but the first
// component with "-43" builds from non-leaf node.
//
//
δ
nchildNonLeafs = {43: +1}
//
Δ
nchildNonLeafs = {43: +1}
//
// Only complete result of applying all
//
// - xfixup(-1,
δ
nchildNonLeafs)
// - xfixup(-1,
Δ
nchildNonLeafs)
// - δ.Del,
// - δ.Add, and
// - xfixup(+1,
δ
nchildNonLeafs)
// - xfixup(+1,
Δ
nchildNonLeafs)
//
// produces correctly PP-connected set.
type
ΔPPTreeSubSet
struct
{
Del
PPTreeSubSet
Add
PPTreeSubSet
δ
nchildNonLeafs
map
[
zodb
.
Oid
]
int
Δ
nchildNonLeafs
map
[
zodb
.
Oid
]
int
}
// NewΔPPTreeSubSet creates new empty ΔPPTreeSubSet.
...
...
@@ -485,7 +495,7 @@ func NewΔPPTreeSubSet() *ΔPPTreeSubSet {
return
&
ΔPPTreeSubSet
{
Del
:
PPTreeSubSet
{},
Add
:
PPTreeSubSet
{},
δ
nchildNonLeafs
:
map
[
zodb
.
Oid
]
int
{},
Δ
nchildNonLeafs
:
map
[
zodb
.
Oid
]
int
{},
}
}
...
...
@@ -493,15 +503,15 @@ func NewΔPPTreeSubSet() *ΔPPTreeSubSet {
func
(
δ
*
ΔPPTreeSubSet
)
Update
(
δ2
*
ΔPPTreeSubSet
)
{
δ
.
Del
.
UnionInplace
(
δ2
.
Del
)
δ
.
Add
.
UnionInplace
(
δ2
.
Add
)
for
oid
,
δnc
:=
range
δ2
.
δ
nchildNonLeafs
{
δ
.
δ
nchildNonLeafs
[
oid
]
+=
δnc
for
oid
,
δnc
:=
range
δ2
.
Δ
nchildNonLeafs
{
δ
.
Δ
nchildNonLeafs
[
oid
]
+=
δnc
}
}
// Reverse changes δ=diff(A->B) to δ'=diff(A<-B).
func
(
δ
*
ΔPPTreeSubSet
)
Reverse
()
{
δ
.
Del
,
δ
.
Add
=
δ
.
Add
,
δ
.
Del
//
δ
nchildNonLeafs stays the same
//
Δ
nchildNonLeafs stays the same
}
...
...
@@ -514,7 +524,7 @@ func (S PPTreeSubSet) ApplyΔ(δ *ΔPPTreeSubSet) {
fmt
.
Printf
(
" A: %s
\n
"
,
S
)
fmt
.
Printf
(
" -: %s
\n
"
,
δ
.
Del
)
fmt
.
Printf
(
" +: %s
\n
"
,
δ
.
Add
)
fmt
.
Printf
(
" x: %v
\n
"
,
δ
.
δ
nchildNonLeafs
)
fmt
.
Printf
(
" x: %v
\n
"
,
δ
.
Δ
nchildNonLeafs
)
defer
fmt
.
Printf
(
"
\n
->B: %s
\n
"
,
S
)
}
...
...
@@ -523,8 +533,8 @@ func (S PPTreeSubSet) ApplyΔ(δ *ΔPPTreeSubSet) {
δ
.
Add
.
verify
()
defer
S
.
verify
()
S
.
xfixup
(
-
1
,
δ
.
δ
nchildNonLeafs
)
S
.
xfixup
(
-
1
,
δ
.
Δ
nchildNonLeafs
)
S
.
xDifferenceInplace
(
δ
.
Del
)
S
.
xUnionInplace
(
δ
.
Add
)
S
.
xfixup
(
+
1
,
δ
.
δ
nchildNonLeafs
)
S
.
xfixup
(
+
1
,
δ
.
Δ
nchildNonLeafs
)
}
wcfs/internal/xbtree/treediff.go
View file @
01b98455
...
...
@@ -132,7 +132,7 @@ func δZConnectTracked(δZv []zodb.Oid, T blib.PPTreeSubSet) (δZTC setOid, δto
// if !root -> δZTC += path through which we reached another node (forming connection)
path
:=
[]
zodb
.
Oid
{}
node
:=
δ
parent
:=
track
.
parent
parent
:=
track
.
Parent
()
for
{
// reached root
if
parent
==
zodb
.
InvalidOid
{
...
...
@@ -160,7 +160,7 @@ func δZConnectTracked(δZv []zodb.Oid, T blib.PPTreeSubSet) (δZTC setOid, δto
panicf
(
"BUG: .p%s -> %s, but %s is not tracked"
,
node
,
parent
,
parent
)
}
node
=
parent
parent
=
trackUp
.
parent
parent
=
trackUp
.
Parent
()
}
}
...
...
@@ -701,8 +701,8 @@ ABcov:
if
!
pathEqual
(
apath
,
bpath
)
{
δtrack
.
Del
.
AddPath
(
apath
)
δtrack
.
Add
.
AddPath
(
bpath
)
if
nc
:=
at
.
nchild
;
nc
!=
0
{
δtrack
.
δ
nchildNonLeafs
[
acOid
]
=
nc
if
nc
:=
at
.
NChild
()
;
nc
!=
0
{
δtrack
.
Δ
nchildNonLeafs
[
acOid
]
=
nc
}
}
...
...
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