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
ca596ec5
Commit
ca596ec5
authored
Sep 09, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6e63c63d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
12 deletions
+21
-12
wcfs/δbtail.go
wcfs/δbtail.go
+18
-12
wcfs/δbtail_test.go
wcfs/δbtail_test.go
+3
-0
No files found.
wcfs/δbtail.go
View file @
ca596ec5
...
@@ -189,7 +189,6 @@ type trackIndex map[zodb.Oid]*nodeTrack
...
@@ -189,7 +189,6 @@ type trackIndex map[zodb.Oid]*nodeTrack
// XXX place
// XXX place
// nodeTrack represents tracking information about a node.
// nodeTrack represents tracking information about a node.
//// XXX kill (parentIdx is just {} oid -> oid)
type
nodeTrack
struct
{
type
nodeTrack
struct
{
parent
zodb
.
Oid
// parent node | InvalidOid for root
parent
zodb
.
Oid
// parent node | InvalidOid for root
nchild
int
// number of direct children in trackIdx referring to this node
nchild
int
// number of direct children in trackIdx referring to this node
...
@@ -199,19 +198,24 @@ type nodeTrack struct {
...
@@ -199,19 +198,24 @@ type nodeTrack struct {
*/
*/
}
}
// δtrackIndex represents change
s
to trackIndex.
// δtrackIndex represents change to trackIndex.
// XXX place
// XXX place
type
δtrackIndex
struct
{
type
δtrackIndex
struct
{
// set of leaf nodes to remove. After leafs are removed, their parents are automatically cleaned up.
// set of leaf nodes to remove. After leafs are removed, their parents
// removals are processed before adds (see below).
// are automatically cleaned down-up. Removals are processed before
// adds (see below).
DelLeaf
SetOid
DelLeaf
SetOid
// nodes to add
// nodes to add
XXX -> add/modify ?
Add
trackIndex
Add
trackIndex
}
}
// ApplyΔ applies δ to trackIdx. XXX
// ApplyΔ applies δ to trackIdx. XXX
func
(
tidx
trackIndex
)
ApplyΔ
(
δ
*
δtrackIndex
)
{
func
(
tidx
trackIndex
)
ApplyΔ
(
δ
*
δtrackIndex
)
{
//fmt.Printf("\n\nApplyΔ\n")
//fmt.Printf("\tDelLeaf: %v\n", δ.DelLeaf)
//fmt.Printf("\tAdd: %v\n", δ.Add)
// remove leafs and thier parents
// remove leafs and thier parents
for
leaf
:=
range
δ
.
DelLeaf
{
for
leaf
:=
range
δ
.
DelLeaf
{
t
,
present
:=
tidx
[
leaf
]
t
,
present
:=
tidx
[
leaf
]
...
@@ -237,20 +241,22 @@ func (tidx trackIndex) ApplyΔ(δ *δtrackIndex) {
...
@@ -237,20 +241,22 @@ func (tidx trackIndex) ApplyΔ(δ *δtrackIndex) {
for
oid
,
δt
:=
range
δ
.
Add
{
for
oid
,
δt
:=
range
δ
.
Add
{
t
,
already
:=
tidx
[
oid
]
t
,
already
:=
tidx
[
oid
]
if
already
{
if
already
{
// XXX but check if with the same parent
if
t
.
parent
!=
zodb
.
InvalidOid
{
if
t
.
parent
!=
δt
.
parent
{
δnchild
[
t
.
parent
]
-=
1
panic
(
"TODO"
)
t
.
parent
=
δt
.
parent
}
}
continue
// object already tracked
}
else
{
t
=
&
nodeTrack
{
parent
:
δt
.
parent
,
nchild
:
0
}
tidx
[
oid
]
=
t
}
}
tidx
[
oid
]
=
&
nodeTrack
{
parent
:
δt
.
parent
,
nchild
:
0
}
if
t
.
parent
!=
zodb
.
InvalidOid
{
if
δt
.
parent
!=
zodb
.
InvalidOid
{
δnchild
[
t
.
parent
]
+=
1
// remeber to nchild++ in parent
δnchild
[
δt
.
parent
]
+=
1
// remeber to nchild++ in parent
}
}
}
}
for
parent
,
δnc
:=
range
δnchild
{
for
parent
,
δnc
:=
range
δnchild
{
tidx
[
parent
]
.
nchild
+=
δnc
tidx
[
parent
]
.
nchild
+=
δnc
// XXX .nchild == 0 - remove ?
}
}
}
}
...
...
wcfs/δbtail_test.go
View file @
ca596ec5
...
@@ -1040,6 +1040,9 @@ func TestΔBTail(t *testing.T) {
...
@@ -1040,6 +1040,9 @@ func TestΔBTail(t *testing.T) {
"T/T1/B0:a-B1:b"
,
"T/T1/B0:a-B1:b"
,
"T/T1/T-T/B0:c-B1:d"
,
"T/T1/T-T/B0:c-B1:d"
,
// "T/T/T/B1:a,2:b",
// "T/T/B1:a",
// found by AllStructs (trackIdx2 wrongly computed due to top
// found by AllStructs (trackIdx2 wrongly computed due to top
// not being tracked to tree root)
// not being tracked to tree root)
"T2/T1-T/B0:g-B1:b-T/B2:b,3:a"
,
"T2/T1-T/B0:g-B1:b-T/B2:b,3:a"
,
...
...
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