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
ab28adcd
Commit
ab28adcd
authored
Jun 24, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
86e5f70f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
22 deletions
+11
-22
wcfs/δbtail.go
wcfs/δbtail.go
+11
-22
No files found.
wcfs/δbtail.go
View file @
ab28adcd
...
@@ -168,17 +168,13 @@ type ΔBtail struct {
...
@@ -168,17 +168,13 @@ type ΔBtail struct {
// XXX or ask client to provide db on every call?
// XXX or ask client to provide db on every call?
db
*
zodb
.
DB
// to open connections to load new/old tree|buckets
db
*
zodb
.
DB
// to open connections to load new/old tree|buckets
// tracked
index: BTree|Bucket -> top tree element.
// tracked
nodes index: node -> parent + accessed holes under this node
//
XXX allow only single root (else it is "tree corrupt") ?
//
we only allow single parent/root case and report "tree corrupt" otherwise.
//
XXX as of
@head state
//
trackIdx describes
@head state
// trackIdx map[zodb.Oid]SetOid // oid -> {} roots
trackIdx
map
[
zodb
.
Oid
]
nodeTrack
// tracked objects that are not yet taken into account in current δBtail
// tracked objects that are not yet taken into account in current δBtail
trackNew
SetOid
trackNew
SetOid
// tracked nodes index: node -> parent + accessed holes under this node
trackIdx
map
[
zodb
.
Oid
]
nodeTrack
}
}
// XXX place
// XXX place
...
@@ -206,7 +202,7 @@ type ΔRoots struct {
...
@@ -206,7 +202,7 @@ type ΔRoots struct {
//
//
// See ΔBtail documentation for details.
// See ΔBtail documentation for details.
type
ΔTtail
struct
{
type
ΔTtail
struct
{
vδT
[]
ΔTree
// changes to tree keys; rev↑. covers keys ∈ tracke
t
subset
vδT
[]
ΔTree
// changes to tree keys; rev↑. covers keys ∈ tracke
d
subset
// {}k/v @tail for keys that are changed in (tail, head].
// {}k/v @tail for keys that are changed in (tail, head].
KVAtTail
map
[
Key
]
Value
KVAtTail
map
[
Key
]
Value
...
@@ -233,7 +229,6 @@ func NewΔBtail(at0 zodb.Tid, db *zodb.DB) *ΔBtail {
...
@@ -233,7 +229,6 @@ func NewΔBtail(at0 zodb.Tid, db *zodb.DB) *ΔBtail {
return
&
ΔBtail
{
return
&
ΔBtail
{
δZtail
:
zodb
.
NewΔTail
(
at0
),
δZtail
:
zodb
.
NewΔTail
(
at0
),
byRoot
:
make
(
map
[
zodb
.
Oid
]
*
ΔTtail
),
byRoot
:
make
(
map
[
zodb
.
Oid
]
*
ΔTtail
),
// trackIdx: make(map[zodb.Oid]SetOid),
trackIdx
:
map
[
zodb
.
Oid
]
nodeTrack
{},
trackIdx
:
map
[
zodb
.
Oid
]
nodeTrack
{},
db
:
db
,
db
:
db
,
}
}
...
@@ -274,10 +269,6 @@ const (
...
@@ -274,10 +269,6 @@ const (
// XXX TrackMinKey (we don't need it in WCFS)
// XXX TrackMinKey (we don't need it in WCFS)
)
)
// XXX keep in trackedKeys only keys that are not present in btree - i.e. only negative entries
// -> this requires to merge δc returned by diffT and adjust bChildren to tail into
// -> it will use less memory and offload Track from (re)loading leaf bucket
// ... for now we go more simple way
func
(
δBtail
*
ΔBtail
)
Track
(
key
Key
,
keyPresent
bool
,
path
[]
Node
,
flags
TrackFlags
)
error
{
// XXX Tree|Bucket; path[0] = root
func
(
δBtail
*
ΔBtail
)
Track
(
key
Key
,
keyPresent
bool
,
path
[]
Node
,
flags
TrackFlags
)
error
{
// XXX Tree|Bucket; path[0] = root
l
:=
len
(
path
)
l
:=
len
(
path
)
if
l
==
0
{
if
l
==
0
{
...
@@ -363,7 +354,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
...
@@ -363,7 +354,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
return
δB
,
nil
return
δB
,
nil
}
}
// open ZODB connections correponding to "old" and "new" states
// open ZODB connections corre
s
ponding to "old" and "new" states
// TODO caller should provide one of those (probably new)
// TODO caller should provide one of those (probably new)
txn
,
ctx
:=
transaction
.
New
(
context
.
TODO
())
// XXX
txn
,
ctx
:=
transaction
.
New
(
context
.
TODO
())
// XXX
defer
txn
.
Abort
()
defer
txn
.
Abort
()
...
@@ -388,7 +379,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
...
@@ -388,7 +379,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
}
}
// XXX .δBtail <- (δZ.rev, [](root, []key))
// XXX .δBtail <- (δZ.rev, [](root, []key))
// XXX rebuil
f
lastRevOf
// XXX rebuil
d
lastRevOf
return
δB
,
nil
return
δB
,
nil
}
}
...
@@ -499,7 +490,7 @@ func (rs rangeSplit) Get_(k Key) (rnode *nodeInRange, ok bool) {
...
@@ -499,7 +490,7 @@ func (rs rangeSplit) Get_(k Key) (rnode *nodeInRange, ok bool) {
//
//
// rnode must be initially in *prs.
// rnode must be initially in *prs.
// rnode.node must be tree.
// rnode.node must be tree.
// rnode.node must be aleady activated.
// rnode.node must be al
r
eady activated.
//
//
// inserted children is also returned for convenience.
// inserted children is also returned for convenience.
func
(
prs
*
rangeSplit
)
Expand
(
rnode
*
nodeInRange
)
(
children
rangeSplit
)
{
func
(
prs
*
rangeSplit
)
Expand
(
rnode
*
nodeInRange
)
(
children
rangeSplit
)
{
...
@@ -759,8 +750,6 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -759,8 +750,6 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
}
}
children
:=
av
.
Expand
(
arn
)
children
:=
av
.
Expand
(
arn
)
// fmt.Printf("Y children: %s\n", children)
// fmt.Printf("Y av: %s\n", av)
for
_
,
rchild
:=
range
children
{
for
_
,
rchild
:=
range
children
{
coid
:=
rchild
.
node
.
POid
()
coid
:=
rchild
.
node
.
POid
()
if
!
(
δZTC
.
Has
(
coid
)
||
if
!
(
δZTC
.
Has
(
coid
)
||
...
@@ -815,7 +804,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -815,7 +804,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
// Each delve for A or B, potentially adds new keys to process on the
// Each delve for A or B, potentially adds new keys to process on the
// other side.
// other side.
//
//
// XXX in
ne
ficient: we process each key separately, while they can be
// XXX in
ef
ficient: we process each key separately, while they can be
// processed in sorted batches.
// processed in sorted batches.
for
len
(
Aqueue
)
>
0
||
len
(
Bqueue
)
>
0
{
for
len
(
Aqueue
)
>
0
||
len
(
Bqueue
)
>
0
{
fmt
.
Printf
(
"
\n
"
)
fmt
.
Printf
(
"
\n
"
)
...
@@ -1159,7 +1148,7 @@ func __diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oi
...
@@ -1159,7 +1148,7 @@ func __diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oi
for child := range allChildren { // XXX -> sorted?
for child := range allChildren { // XXX -> sorted?
// add/del/modify, but child is not tracked - ignore
// add/del/modify, but child is not tracked - ignore
// XXX correct only in children from a? (b could have changed child
e
ren to new objects)
// XXX correct only in children from a? (b could have changed children to new objects)
if !δZTC.Has(child) {
if !δZTC.Has(child) {
continue
continue
}
}
...
@@ -1456,7 +1445,7 @@ func vtree(v []TreeEntry) string {
...
@@ -1456,7 +1445,7 @@ func vtree(v []TreeEntry) string {
return
s
return
s
}
}
// vnode returns brief huan-readable representation of node.
// vnode returns brief hu
m
an-readable representation of node.
func
vnode
(
node
Node
)
string
{
func
vnode
(
node
Node
)
string
{
kind
:=
"?"
kind
:=
"?"
switch
node
.
(
type
)
{
switch
node
.
(
type
)
{
...
...
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