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
fb56ebad
Commit
fb56ebad
authored
Jun 24, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
ce8d70fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
24 deletions
+36
-24
wcfs/δbtail.go
wcfs/δbtail.go
+36
-24
No files found.
wcfs/δbtail.go
View file @
fb56ebad
...
@@ -280,7 +280,7 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node, flags Track
...
@@ -280,7 +280,7 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node, flags Track
pathv
:=
[]
string
{}
pathv
:=
[]
string
{}
for
_
,
node
:=
range
path
{
pathv
=
append
(
pathv
,
vnode
(
node
))
}
for
_
,
node
:=
range
path
{
pathv
=
append
(
pathv
,
vnode
(
node
))
}
fmt
.
Print
f
(
"Track [%v] %s
\n
"
,
key
,
strings
.
Join
(
pathv
,
" -> "
))
trace
f
(
"Track [%v] %s
\n
"
,
key
,
strings
.
Join
(
pathv
,
" -> "
))
parent
:=
zodb
.
InvalidOid
parent
:=
zodb
.
InvalidOid
var
track
nodeTrack
var
track
nodeTrack
...
@@ -342,8 +342,8 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
...
@@ -342,8 +342,8 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
δBtail
.
δZtail
.
Append
(
δZ
.
Tid
,
δZ
.
Changev
)
δBtail
.
δZtail
.
Append
(
δZ
.
Tid
,
δZ
.
Changev
)
fmt
.
Print
f
(
"
\n
Update δZ: %v
\n
"
,
δZ
.
Changev
)
trace
f
(
"
\n
Update δZ: %v
\n
"
,
δZ
.
Changev
)
fmt
.
Print
f
(
"trackIdx: %v
\n
"
,
δBtail
.
trackIdx
)
trace
f
(
"trackIdx: %v
\n
"
,
δBtail
.
trackIdx
)
δZTC
,
δtopsByRoot
:=
δBtail
.
δZConnectTracked
(
δZ
)
δZTC
,
δtopsByRoot
:=
δBtail
.
δZConnectTracked
(
δZ
)
...
@@ -595,8 +595,8 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
...
@@ -595,8 +595,8 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
defer
xerr
.
Contextf
(
&
err
,
"treediff %s..%s %s"
,
zconnOld
.
At
(),
zconnNew
.
At
(),
root
)
defer
xerr
.
Contextf
(
&
err
,
"treediff %s..%s %s"
,
zconnOld
.
At
(),
zconnNew
.
At
(),
root
)
// XXX zconnX -> a, b ?
// XXX zconnX -> a, b ?
fmt
.
Print
f
(
"treediff %s δtops: %v δZTC: %v
\n
"
,
root
,
δtops
,
δZTC
)
trace
f
(
"treediff %s δtops: %v δZTC: %v
\n
"
,
root
,
δtops
,
δZTC
)
defer
fmt
.
Print
f
(
"
\n
"
)
defer
trace
f
(
"
\n
"
)
δT
=
map
[
Key
]
ΔValue
{}
δT
=
map
[
Key
]
ΔValue
{}
...
@@ -618,7 +618,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
...
@@ -618,7 +618,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
// -> assert that keys from different δtop do not overlap
// -> assert that keys from different δtop do not overlap
// DEL k -> Tkextra += k
// DEL k -> Tkextra += k
// +k -> Tkextra -= k
// +k -> Tkextra -= k
fmt
.
Print
f
(
"-> δtop: %v
\n
"
,
δtop
)
trace
f
(
"-> δtop: %v
\n
"
,
δtop
)
for
k
,
δv
:=
range
δtop
{
for
k
,
δv
:=
range
δtop
{
δT
[
k
]
=
δv
δT
[
k
]
=
δv
}
}
...
@@ -683,11 +683,11 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid, trackIdx map[zodb.Oid]n
...
@@ -683,11 +683,11 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid, trackIdx map[zodb.Oid]n
//
//
// XXX trackIdx -> just pass δBtail?
// 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
)
(
δ
map
[
Key
]
ΔValue
,
err
error
)
{
fmt
.
Printf
(
"
T %s %s
\n
"
,
xidOf
(
a
),
xidOf
(
b
))
tracef
(
" diff
T %s %s
\n
"
,
xidOf
(
a
),
xidOf
(
b
))
defer
xerr
.
Contextf
(
&
err
,
"diffT %s %s"
,
xidOf
(
a
),
xidOf
(
b
))
defer
xerr
.
Contextf
(
&
err
,
"diffT %s %s"
,
xidOf
(
a
),
xidOf
(
b
))
δ
=
map
[
Key
]
ΔValue
{}
δ
=
map
[
Key
]
ΔValue
{}
defer
fmt
.
Print
f
(
" -> δt: %v
\n
"
,
δ
)
defer
trace
f
(
" -> δt: %v
\n
"
,
δ
)
var
av
rangeSplit
// nodes expanded from a
var
av
rangeSplit
// nodes expanded from a
var
bv
rangeSplit
// nodes expanded from b
var
bv
rangeSplit
// nodes expanded from b
...
@@ -790,9 +790,8 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -790,9 +790,8 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
}
}
}
}
fmt
.
Printf
(
" av: %s
\n
"
,
av
)
tracef
(
" av: %s
\n
"
,
av
)
fmt
.
Printf
(
" bv: %s
\n
"
,
bv
)
tracef
(
" bv: %s
\n
"
,
bv
)
fmt
.
Printf
(
" bq: %s
\n
"
,
Bqueue
)
// phase 2: iterate through keys queued for A and B, delve into
// phase 2: iterate through keys queued for A and B, delve into
// corresponding nodes, and merge diff generated from them into δ.
// corresponding nodes, and merge diff generated from them into δ.
...
@@ -801,17 +800,21 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -801,17 +800,21 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
//
//
// XXX inefficient: we process each key separately, while they can be
// XXX inefficient: 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
{
fmt
.
Printf
(
"
\n
"
)
tracef
(
"
\n
"
)
fmt
.
Printf
(
" aq: %s
\n
"
,
Aqueue
)
tracef
(
" aq: %s
\n
"
,
Aqueue
)
fmt
.
Printf
(
" bq: %s
\n
"
,
Bqueue
)
tracef
(
" bq: %s
\n
"
,
Bqueue
)
if
len
(
Aqueue
)
==
0
&&
len
(
Bqueue
)
==
0
{
break
}
// B queue
// B queue
// expand keys in new δA -> in B till buckets;
// expand keys in new δA -> in B till buckets;
// process B buckets that cover new keys into δ+
// process B buckets that cover new keys into δ+
Aqueue
=
SetKey
{}
Aqueue
=
SetKey
{}
for
k
:=
range
Bqueue
{
for
k
:=
range
Bqueue
{
fmt
.
Print
f
(
" B [%v]
\n
"
,
k
)
trace
f
(
" B [%v]
\n
"
,
k
)
bnode
,
ok
,
err
:=
bv
.
GetToLeaf
(
ctx
,
k
)
bnode
,
ok
,
err
:=
bv
.
GetToLeaf
(
ctx
,
k
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -857,7 +860,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -857,7 +860,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
Bdone
.
Add
(
k
)
Bdone
.
Add
(
k
)
}
}
fmt
.
Print
f
(
" bv: %s
\n
"
,
bv
)
trace
f
(
" bv: %s
\n
"
,
bv
)
}
}
// FIXME update trackIdx
// FIXME update trackIdx
...
@@ -891,7 +894,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -891,7 +894,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
// A queue
// A queue
Bqueue
=
SetKey
{}
Bqueue
=
SetKey
{}
for
k
:=
range
Aqueue
{
for
k
:=
range
Aqueue
{
fmt
.
Print
f
(
" A [%v]
\n
"
,
k
)
trace
f
(
" A [%v]
\n
"
,
k
)
anode
,
ok
,
err
:=
av
.
GetToLeaf
(
ctx
,
k
)
anode
,
ok
,
err
:=
av
.
GetToLeaf
(
ctx
,
k
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -935,7 +938,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -935,7 +938,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
Adone
.
Add
(
k
)
Adone
.
Add
(
k
)
}
}
fmt
.
Print
f
(
" av: %s
\n
"
,
av
)
trace
f
(
" av: %s
\n
"
,
av
)
}
}
}
}
...
@@ -946,8 +949,8 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -946,8 +949,8 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
// δMerge merges changes from δ2 into δ.
// δMerge merges changes from δ2 into δ.
// δ is total-building diff, while δ2 is diff from comparing some subnodes.
// δ is total-building diff, while δ2 is diff from comparing some subnodes.
func
δMerge
(
δ
,
δ2
map
[
Key
]
ΔValue
)
error
{
func
δMerge
(
δ
,
δ2
map
[
Key
]
ΔValue
)
error
{
fmt
.
Print
f
(
" δmerge %v <- %v
\n
"
,
δ
,
δ2
)
trace
f
(
" δmerge %v <- %v
\n
"
,
δ
,
δ2
)
defer
fmt
.
Print
f
(
" -> %v
\n
"
,
δ
)
defer
trace
f
(
" -> %v
\n
"
,
δ
)
// merge δ <- δ2
// merge δ <- δ2
for
k
,
δv2
:=
range
δ2
{
for
k
,
δv2
:=
range
δ2
{
...
@@ -992,7 +995,7 @@ func δMerge(δ, δ2 map[Key]ΔValue) error {
...
@@ -992,7 +995,7 @@ func δMerge(δ, δ2 map[Key]ΔValue) error {
δv
.
New
=
δv2
.
New
δv
.
New
=
δv2
.
New
}
}
fmt
.
Print
f
(
" [%v] merge %s %s -> %s
\n
"
,
k
,
δv1
,
δv2
,
δv
)
trace
f
(
" [%v] merge %s %s -> %s
\n
"
,
k
,
δv1
,
δv2
,
δv
)
if
δv
.
Old
!=
δv
.
New
{
if
δv
.
Old
!=
δv
.
New
{
δ
[
k
]
=
δv
δ
[
k
]
=
δv
}
else
{
}
else
{
...
@@ -1007,7 +1010,7 @@ func δMerge(δ, δ2 map[Key]ΔValue) error {
...
@@ -1007,7 +1010,7 @@ func δMerge(δ, δ2 map[Key]ΔValue) error {
// diffB computes difference in between two buckets.
// diffB computes difference in between two buckets.
// see diffX for details.
// see diffX for details.
func
diffB
(
ctx
context
.
Context
,
a
,
b
*
Bucket
)
(
δ
map
[
Key
]
ΔValue
,
err
error
)
{
func
diffB
(
ctx
context
.
Context
,
a
,
b
*
Bucket
)
(
δ
map
[
Key
]
ΔValue
,
err
error
)
{
fmt
.
Printf
(
"
B %s %s
\n
"
,
xidOf
(
a
),
xidOf
(
b
))
tracef
(
" diff
B %s %s
\n
"
,
xidOf
(
a
),
xidOf
(
b
))
defer
xerr
.
Contextf
(
&
err
,
"diffB %s %s"
,
xidOf
(
a
),
xidOf
(
b
))
defer
xerr
.
Contextf
(
&
err
,
"diffB %s %s"
,
xidOf
(
a
),
xidOf
(
b
))
// XXX oid can be InvalidOid for T/B... (i.e. B is part of T and is not yet committed separately)
// XXX oid can be InvalidOid for T/B... (i.e. B is part of T and is not yet committed separately)
...
@@ -1028,7 +1031,7 @@ func diffB(ctx context.Context, a, b *Bucket) (δ map[Key]ΔValue, err error) {
...
@@ -1028,7 +1031,7 @@ func diffB(ctx context.Context, a, b *Bucket) (δ map[Key]ΔValue, err error) {
//defer fmt.Println("< diffB")
//defer fmt.Println("< diffB")
δ
=
map
[
Key
]
ΔValue
{}
δ
=
map
[
Key
]
ΔValue
{}
defer
fmt
.
Print
f
(
" -> δb: %v
\n
"
,
δ
)
defer
trace
f
(
" -> δb: %v
\n
"
,
δ
)
//fmt.Println("av:", av)
//fmt.Println("av:", av)
//fmt.Println("bv:", bv)
//fmt.Println("bv:", bv)
...
@@ -1256,3 +1259,12 @@ func (rn nodeInRange) String() string {
...
@@ -1256,3 +1259,12 @@ func (rn nodeInRange) String() string {
func
(
track
nodeTrack
)
String
()
string
{
func
(
track
nodeTrack
)
String
()
string
{
return
fmt
.
Sprintf
(
"{p%s h%s}"
,
track
.
parent
,
track
.
holes
)
return
fmt
.
Sprintf
(
"{p%s h%s}"
,
track
.
parent
,
track
.
holes
)
}
}
const
debug
=
true
func
tracef
(
format
string
,
argv
...
interface
{})
{
if
debug
{
fmt
.
Printf
(
format
,
argv
...
)
}
}
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