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
e7e8600f
Commit
e7e8600f
authored
Aug 04, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
27b8b378
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
9 deletions
+31
-9
wcfs/δbtail.go
wcfs/δbtail.go
+31
-9
No files found.
wcfs/δbtail.go
View file @
e7e8600f
...
...
@@ -169,11 +169,14 @@ type ΔBtail struct {
// XXX or ask client to provide db on every call?
db
*
zodb
.
DB
// to open connections to load new/old tree|buckets
// tracked nodes index: node -> parent + accessed holes under this node
// tracked nodes index: node -> parent + accessed holes under this node
XXX -> holeIdx
// we only allow single parent/root case and report "tree corrupt" otherwise.
// trackIdx describes @head state
trackIdx
map
[
zodb
.
Oid
]
nodeTrack
// XXX tracked holes
holeIdx
treeSetKey
// tracked objects that are not yet taken into account in current δBtail
trackNew
SetOid
}
...
...
@@ -186,6 +189,25 @@ type nodeTrack struct {
// XXX move holes into separate ΔBtail..holeIdx
}
// treeSetKey represents ordered set of keys.
// it can be point-queried and range-accessed.
// TODO -> btree
type
treeSetKey
struct
{
SetKey
}
// InRange returns
func
(
hi
treeSetKey
)
GetInRange
(
lo
,
hi_
Key
)
SetKey
{
// FIXME dumb O(n) -> TODO use cznic/b
ret
:=
SetKey
{}
for
k
:=
range
hi
.
SetKey
{
if
lo
<=
k
&&
k
<=
hi_
{
ret
.
Add
(
k
)
}
}
return
ret
}
// ΔB represents a change in BTrees space.
type
ΔB
struct
{
Rev
zodb
.
Tid
...
...
@@ -370,7 +392,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
}
for
root
,
δtops
:=
range
δtopsByRoot
{
δT
,
err
:=
treediff
(
ctx
,
root
,
δtops
,
δZTC
,
δBtail
.
trackIdx
,
zconnOld
,
zconnNew
)
δT
,
err
:=
treediff
(
ctx
,
root
,
δtops
,
δZTC
,
δBtail
.
trackIdx
,
δBtail
.
holeIdx
,
zconnOld
,
zconnNew
)
if
err
!=
nil
{
return
ΔB
{},
err
}
...
...
@@ -603,7 +625,7 @@ func (rs rangeSplit) String() string {
// δtops is set of top nodes for changed subtrees.
// δZTC is connected(δZ/T) - connected closure for subset of δZ(old..new) that
// touches tracked nodes of T.
func
treediff
(
ctx
context
.
Context
,
root
zodb
.
Oid
,
δtops
SetOid
,
δZTC
SetOid
,
trackIdx
map
[
zodb
.
Oid
]
nodeTrack
,
zconnOld
,
zconnNew
*
zodb
.
Connection
)
(
δT
map
[
Key
]
ΔValue
,
err
error
)
{
func
treediff
(
ctx
context
.
Context
,
root
zodb
.
Oid
,
δtops
SetOid
,
δZTC
SetOid
,
trackIdx
map
[
zodb
.
Oid
]
nodeTrack
,
holeIdx
treeSetKey
,
zconnOld
,
zconnNew
*
zodb
.
Connection
)
(
δT
map
[
Key
]
ΔValue
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"treediff %s..%s %s"
,
zconnOld
.
At
(),
zconnNew
.
At
(),
root
)
tracef
(
"treediff %s δtops: %v δZTC: %v
\n
"
,
root
,
δtops
,
δZTC
)
...
...
@@ -619,7 +641,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
return
nil
,
err
}
δtop
,
err
:=
diffX
(
ctx
,
a
,
b
,
δZTC
,
trackIdx
)
δtop
,
err
:=
diffX
(
ctx
,
a
,
b
,
δZTC
,
trackIdx
,
holeIdx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -646,7 +668,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
// δZTC is connected set of objects covering δZT (objects changed in this tree in old..new).
//
// a/b can be nil; a=nil means addition, b=nil means deletion.
func
diffX
(
ctx
context
.
Context
,
a
,
b
Node
,
δZTC
SetOid
,
trackIdx
map
[
zodb
.
Oid
]
nodeTrack
)
(
δ
map
[
Key
]
ΔValue
,
err
error
)
{
func
diffX
(
ctx
context
.
Context
,
a
,
b
Node
,
δZTC
SetOid
,
trackIdx
map
[
zodb
.
Oid
]
nodeTrack
,
holeIdx
treeSetKey
)
(
δ
map
[
Key
]
ΔValue
,
err
error
)
{
if
a
==
nil
&&
b
==
nil
{
panic
(
"BUG: both a & b == nil"
)
}
...
...
@@ -681,7 +703,7 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid, trackIdx map[zodb.Oid]n
}
if
isT
{
return
diffT
(
ctx
,
aT
,
bT
,
δZTC
,
trackIdx
)
return
diffT
(
ctx
,
aT
,
bT
,
δZTC
,
trackIdx
,
holeIdx
)
}
else
{
return
diffB
(
ctx
,
aB
,
bB
)
}
...
...
@@ -693,7 +715,7 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid, trackIdx map[zodb.Oid]n
// δZTC is connected set of objects covering δZT (objects changed in this tree in old..new).
//
// XXX trackIdx -> just pass δBtail?
func
diffT
(
ctx
context
.
Context
,
A
,
B
*
Tree
,
δZTC
SetOid
,
trackIdx
map
[
zodb
.
Oid
]
nodeTrack
)
(
δ
map
[
Key
]
ΔValue
,
err
error
)
{
func
diffT
(
ctx
context
.
Context
,
A
,
B
*
Tree
,
δZTC
SetOid
,
trackIdx
map
[
zodb
.
Oid
]
nodeTrack
,
holeIdx
treeSetKey
)
(
δ
map
[
Key
]
ΔValue
,
err
error
)
{
tracef
(
" diffT %s %s
\n
"
,
xidOf
(
A
),
xidOf
(
B
))
defer
xerr
.
Contextf
(
&
err
,
"diffT %s %s"
,
xidOf
(
A
),
xidOf
(
B
))
...
...
@@ -748,7 +770,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
}
}
// Bkqueue <- holes(ra.range)
for
k
:=
range
holeIdx
.
InRange
(
ra
.
lo
,
ra
.
hi_
)
{
for
k
:=
range
holeIdx
.
Get
InRange
(
ra
.
lo
,
ra
.
hi_
)
{
if
!
Bkdone
.
Has
(
k
)
{
Bkqueue
.
Add
(
k
)
}
...
...
@@ -882,7 +904,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
}
}
// Bkqueue <- holes(a.range)
for
k_
:=
range
holeIdx
.
InRange
(
a
.
lo
,
a
.
hi_
)
{
for
k_
:=
range
holeIdx
.
Get
InRange
(
a
.
lo
,
a
.
hi_
)
{
if
!
Bkdone
.
Has
(
k_
)
{
Bkqueue
.
Add
(
k_
)
}
...
...
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