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
c4a49a11
Commit
c4a49a11
authored
Jul 03, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
45383e25
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
58 deletions
+75
-58
wcfs/δbtail.go
wcfs/δbtail.go
+75
-58
No files found.
wcfs/δbtail.go
View file @
c4a49a11
...
@@ -694,10 +694,10 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -694,10 +694,10 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
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
Aqueue
:=
SetKey
{}
// "to process" keys on A
//
Aqueue := SetKey{} // "to process" keys on A
Bqueue
:=
SetKey
{}
// "to process" keys on B
//
Bqueue := SetKey{} // "to process" keys on B
Adone
:=
SetKey
{}
// "processed" keys on A
//
Adone := SetKey{} // "processed" keys on A
Bdone
:=
SetKey
{}
// "processed" keys on B
//
Bdone := SetKey{} // "processed" keys on B
// XXX precise range as for a ^^^ ?
// XXX precise range as for a ^^^ ?
btop
:=
&
nodeInRange
{
lo
:
KeyMin
,
hi_
:
KeyMax
,
node
:
b
}
// [-∞, ∞)
btop
:=
&
nodeInRange
{
lo
:
KeyMin
,
hi_
:
KeyMax
,
node
:
b
}
// [-∞, ∞)
...
@@ -708,7 +708,10 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -708,7 +708,10 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
// XXX maybe walk till a from root to get more precise initial range?
// XXX maybe walk till a from root to get more precise initial range?
atop
:=
&
nodeInRange
{
lo
:
KeyMin
,
hi_
:
KeyMax
,
node
:
a
}
// [-∞, ∞)
atop
:=
&
nodeInRange
{
lo
:
KeyMin
,
hi_
:
KeyMax
,
node
:
a
}
// [-∞, ∞)
av
=
rangeSplit
{
atop
}
av
=
rangeSplit
{
atop
}
aq
:=
[]
*
nodeInRange
{
atop
}
// stack
Aqueue
:=
[]
*
nodeInRange
{
atop
}
// stack: "to process" nodes on A
Bqueue
:=
[]
*
nodeInRange
{}
// stack: "to process" nodes on B
/*
for len(aq) > 0 {
for len(aq) > 0 {
l := len(aq)
l := len(aq)
arn := aq[l-1]; aq=aq[:l-1] // arn=aq.pop()
arn := aq[l-1]; aq=aq[:l-1] // arn=aq.pop()
...
@@ -749,7 +752,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -749,7 +752,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
for _, rchild := range children {
for _, rchild := range children {
coid := rchild.node.POid()
coid := rchild.node.POid()
if !( δZTC.Has(coid) ||
if !( δZTC.Has(coid) ||
/* embedded bucket */
embedded bucket
(len(children) == 1 && coid == zodb.InvalidOid) ) {
(len(children) == 1 && coid == zodb.InvalidOid) ) {
continue
continue
}
}
...
@@ -789,6 +792,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -789,6 +792,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
}
}
}
}
}
}
*/
tracef
(
" av: %s
\n
"
,
av
)
tracef
(
" av: %s
\n
"
,
av
)
tracef
(
" bv: %s
\n
"
,
bv
)
tracef
(
" bv: %s
\n
"
,
bv
)
...
@@ -797,9 +801,6 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -797,9 +801,6 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
// corresponding nodes, and merge diff generated from them into δ.
// corresponding nodes, and merge diff generated from them into δ.
// 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 inefficient: we process each key separately, while they can be
// processed in sorted batches.
for
{
for
{
tracef
(
"
\n
"
)
tracef
(
"
\n
"
)
tracef
(
" aq: %s
\n
"
,
Aqueue
)
tracef
(
" aq: %s
\n
"
,
Aqueue
)
...
@@ -809,6 +810,61 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -809,6 +810,61 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
break
break
}
}
// A queue
// Bqueue = SetKey{}
for
len
(
Aqueue
)
>
0
{
Xa
:=
pop
(
&
Aqueue
)
tracef
(
" A %v
\n
"
,
Xa
)
/*
anode, ok, err := av.GetToLeaf(ctx, k)
if err != nil {
return nil, err
}
if !ok {
// FIXME -> key must be included into some node.hole
continue // key not covered
}
// XXX check for anode.node.(*Tree) (ø tree case)
// - bucket if that bucket is reached for the first time
if !anode.done {
δA, err := diffB(ctx, anode.node.(*Bucket), nil)
if err != nil {
return nil, err
}
// XXX also extract holes
// δ <- δA
err = δMerge(δ, δA)
if err != nil {
return nil, err
}
// Adone <- δA
// Bqueue <- δA
for k_ := range δA {
Adone.Add(k_)
if !Bdone.Has(k_) {
Bqueue.Add(k_)
}
}
anode.done = true
}
// k is not there -> -[k]ø
if !Adone.Has(k) {
// XXX do we need to add(?) [k]ø->ø ?
Adone.Add(k)
}
*/
tracef
(
" av: %s
\n
"
,
av
)
}
/*
// B queue
// B queue
// expand keys from new δA -> in B till buckets;
// expand keys from new δA -> in B till buckets;
// process B buckets that cover new keys into δ+
// process B buckets that cover new keys into δ+
...
@@ -862,6 +918,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -862,6 +918,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
tracef(" bv: %s\n", bv)
tracef(" bv: %s\n", bv)
}
}
*/
// FIXME update trackIdx
// FIXME update trackIdx
/*
/*
...
@@ -891,55 +948,6 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -891,55 +948,6 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
}
}
*/
*/
// A queue
Bqueue
=
SetKey
{}
for
k
:=
range
Aqueue
{
tracef
(
" A [%v]
\n
"
,
k
)
anode
,
ok
,
err
:=
av
.
GetToLeaf
(
ctx
,
k
)
if
err
!=
nil
{
return
nil
,
err
}
if
!
ok
{
// FIXME -> key must be included into some node.hole
continue
// key not covered
}
// XXX check for anode.node.(*Tree) (ø tree case)
// - bucket if that bucket is reached for the first time
if
!
anode
.
done
{
δA
,
err
:=
diffB
(
ctx
,
anode
.
node
.
(
*
Bucket
),
nil
)
if
err
!=
nil
{
return
nil
,
err
}
// XXX also extract holes
// δ <- δA
err
=
δMerge
(
δ
,
δA
)
if
err
!=
nil
{
return
nil
,
err
}
// Adone <- δA
// Bqueue <- δA
for
k_
:=
range
δA
{
Adone
.
Add
(
k_
)
if
!
Bdone
.
Has
(
k_
)
{
Bqueue
.
Add
(
k_
)
}
}
anode
.
done
=
true
}
// k is not there -> -[k]ø
if
!
Adone
.
Has
(
k
)
{
// XXX do we need to add(?) [k]ø->ø ?
Adone
.
Add
(
k
)
}
tracef
(
" av: %s
\n
"
,
av
)
}
}
}
return
δ
,
nil
return
δ
,
nil
...
@@ -1522,6 +1530,15 @@ func (track nodeTrack) String() string {
...
@@ -1522,6 +1530,15 @@ func (track nodeTrack) String() string {
}
}
// pop pops top element from node stack.
func
pop
(
nodeStk
*
[]
*
nodeInRange
)
*
nodeInRange
{
stk
:=
*
nodeStk
l
:=
len
(
stk
)
top
:=
stk
[
l
-
1
]
*
nodeStk
=
stk
[
:
l
-
1
]
return
top
}
const
debug
=
true
const
debug
=
true
func
tracef
(
format
string
,
argv
...
interface
{})
{
func
tracef
(
format
string
,
argv
...
interface
{})
{
...
...
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