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
45383e25
Commit
45383e25
authored
Jul 03, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f7a26f7d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
69 deletions
+68
-69
wcfs/δbtail.go
wcfs/δbtail.go
+68
-69
No files found.
wcfs/δbtail.go
View file @
45383e25
...
...
@@ -686,6 +686,9 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
tracef
(
" diffT %s %s
\n
"
,
xidOf
(
a
),
xidOf
(
b
))
defer
xerr
.
Contextf
(
&
err
,
"diffT %s %s"
,
xidOf
(
a
),
xidOf
(
b
))
if
a
==
nil
{
panic
(
"a is nil"
)
}
if
b
==
nil
{
panic
(
"b is nil"
)
}
δ
=
map
[
Key
]
ΔValue
{}
defer
tracef
(
" -> δ: %v
\n
"
,
δ
)
...
...
@@ -696,37 +699,79 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
Adone
:=
SetKey
{}
// "processed" keys on A
Bdone
:=
SetKey
{}
// "processed" keys on B
if
b
!=
nil
{
// XXX kill (always !nil) ?
// XXX precise range as for a ^^^ ?
btop
:=
&
nodeInRange
{
lo
:
KeyMin
,
hi_
:
KeyMax
,
node
:
b
}
// [-∞, ∞)
bv
=
rangeSplit
{
btop
}
}
// XXX precise range as for a ^^^ ?
btop
:=
&
nodeInRange
{
lo
:
KeyMin
,
hi_
:
KeyMax
,
node
:
b
}
// [-∞, ∞)
bv
=
rangeSplit
{
btop
}
// initial phase: expand changed nodes in a till buckets;
// XXX changed buckets -> δ-
if
a
!=
nil
{
// XXX kill (always !nil) ?
// XXX maybe walk till a from root to get more precise initial range?
atop
:=
&
nodeInRange
{
lo
:
KeyMin
,
hi_
:
KeyMax
,
node
:
a
}
// [-∞, ∞)
av
=
rangeSplit
{
atop
}
aq
:=
[]
*
nodeInRange
{
atop
}
// stack
for
len
(
aq
)
>
0
{
l
:=
len
(
aq
)
arn
:=
aq
[
l
-
1
];
aq
=
aq
[
:
l
-
1
]
// arn=aq.pop()
atree
:=
arn
.
node
.
(
*
Tree
)
// ok - only trees in aq
err
=
atree
.
PActivate
(
ctx
);
if
err
!=
nil
{
return
nil
,
err
}
defer
atree
.
PDeactivate
()
// XXX maybe walk till a from root to get more precise initial range?
atop
:=
&
nodeInRange
{
lo
:
KeyMin
,
hi_
:
KeyMax
,
node
:
a
}
// [-∞, ∞)
av
=
rangeSplit
{
atop
}
aq
:=
[]
*
nodeInRange
{
atop
}
// stack
for
len
(
aq
)
>
0
{
l
:=
len
(
aq
)
arn
:=
aq
[
l
-
1
];
aq
=
aq
[
:
l
-
1
]
// arn=aq.pop()
atree
:=
arn
.
node
.
(
*
Tree
)
// ok - only trees in aq
err
=
atree
.
PActivate
(
ctx
);
if
err
!=
nil
{
return
nil
,
err
}
defer
atree
.
PDeactivate
()
// empty tree - do not expand into bucket - only process tracked holes
if
len
(
atree
.
Entryv
())
==
0
{
// XXX dup wrt bucket processing?
δA
:=
map
[
Key
]
ΔValue
{}
track
,
ok
:=
trackIdx
[
atree
.
POid
()]
if
!
ok
{
panicf
(
"%s ∈ δZTC, but ∉ trackIdx"
,
vnode
(
atree
))
}
for
k
:=
range
track
.
holes
{
δA
[
k
]
=
ΔValue
{
VDEL
,
VDEL
}
// ø->ø indicates hole
}
// δ <- δA
err
=
δMerge
(
δ
,
δA
)
if
err
!=
nil
{
return
nil
,
err
}
// empty tree - do not expand into bucket - only process tracked holes
if
len
(
atree
.
Entryv
())
==
0
{
// XXX dup wrt bucket processing?
δA
:=
map
[
Key
]
ΔValue
{}
track
,
ok
:=
trackIdx
[
atree
.
POid
()]
// Adone <- δA
// Bqueue <- δA
for
k
:=
range
δA
{
Adone
.
Add
(
k
)
Bqueue
.
Add
(
k
)
}
arn
.
done
=
true
continue
}
// normal tree - expand till buckets
children
:=
av
.
Expand
(
arn
)
for
_
,
rchild
:=
range
children
{
coid
:=
rchild
.
node
.
POid
()
if
!
(
δZTC
.
Has
(
coid
)
||
/* embedded bucket */
(
len
(
children
)
==
1
&&
coid
==
zodb
.
InvalidOid
)
)
{
continue
}
switch
node
:=
rchild
.
node
.
(
type
)
{
case
*
Tree
:
aq
=
append
(
aq
,
rchild
)
case
*
Bucket
:
δA
,
err
:=
diffB
(
ctx
,
node
,
nil
)
if
err
!=
nil
{
return
nil
,
err
}
// also -[k]ø (for tracked holes)
track
,
ok
:=
trackIdx
[
node
.
POid
()]
if
!
ok
{
panicf
(
"%s ∈ δZTC, but ∉ trackIdx"
,
vnode
(
atre
e
))
panicf
(
"%s ∈ δZTC, but ∉ trackIdx"
,
vnode
(
nod
e
))
}
for
k
:=
range
track
.
holes
{
δA
[
k
]
=
ΔValue
{
VDEL
,
VDEL
}
// ø->ø indicates hole
}
// δ <- δA
err
=
δMerge
(
δ
,
δA
)
if
err
!=
nil
{
...
...
@@ -740,53 +785,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
Bqueue
.
Add
(
k
)
}
arn
.
done
=
true
continue
}
// normal tree - expand till buckets
children
:=
av
.
Expand
(
arn
)
for
_
,
rchild
:=
range
children
{
coid
:=
rchild
.
node
.
POid
()
if
!
(
δZTC
.
Has
(
coid
)
||
/* embedded bucket */
(
len
(
children
)
==
1
&&
coid
==
zodb
.
InvalidOid
)
)
{
continue
}
switch
node
:=
rchild
.
node
.
(
type
)
{
case
*
Tree
:
aq
=
append
(
aq
,
rchild
)
case
*
Bucket
:
δA
,
err
:=
diffB
(
ctx
,
node
,
nil
)
if
err
!=
nil
{
return
nil
,
err
}
// also -[k]ø (for tracked holes)
track
,
ok
:=
trackIdx
[
node
.
POid
()]
if
!
ok
{
panicf
(
"%s ∈ δZTC, but ∉ trackIdx"
,
vnode
(
node
))
}
for
k
:=
range
track
.
holes
{
δA
[
k
]
=
ΔValue
{
VDEL
,
VDEL
}
// ø->ø indicates hole
}
// δ <- δA
err
=
δMerge
(
δ
,
δA
)
if
err
!=
nil
{
return
nil
,
err
}
// Adone <- δA
// Bqueue <- δA
for
k
:=
range
δA
{
Adone
.
Add
(
k
)
Bqueue
.
Add
(
k
)
}
rchild
.
done
=
true
}
rchild
.
done
=
true
}
}
}
...
...
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