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
f2b44b94
Commit
f2b44b94
authored
Jun 11, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6440a343
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
21 deletions
+56
-21
wcfs/internal/xbtree/rangeset.go
wcfs/internal/xbtree/rangeset.go
+6
-4
wcfs/internal/xbtree/treediff.go
wcfs/internal/xbtree/treediff.go
+49
-11
wcfs/internal/xbtree/δbtail_test.go
wcfs/internal/xbtree/δbtail_test.go
+1
-6
No files found.
wcfs/internal/xbtree/rangeset.go
View file @
f2b44b94
...
...
@@ -398,11 +398,13 @@ func (S RangedKeySet) String() string {
}
func
(
r
KeyRange
)
String
()
string
{
hi
:=
r
.
hi_
if
hi
<
KeyMax
{
hi
+=
1
var
shi
string
if
r
.
hi_
==
KeyMax
{
shi
=
kstr
(
r
.
hi_
)
// ∞
}
else
{
shi
=
fmt
.
Sprintf
(
"%d"
,
r
.
hi_
+
1
)
}
return
fmt
.
Sprintf
(
"[%s,%s)"
,
kstr
(
r
.
lo
),
kstr
(
hi
)
)
return
fmt
.
Sprintf
(
"[%s,%s)"
,
kstr
(
r
.
lo
),
shi
)
}
...
...
wcfs/internal/xbtree/treediff.go
View file @
f2b44b94
...
...
@@ -467,16 +467,55 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackSet PPTreeSubSet)
}
var
ABoid
zodb
.
Oid
var
AB
*
Tree
if
A
!=
nil
{
ABoid
=
A
.
POid
()
AB
=
A
}
if
B
!=
nil
{
ABoid
=
B
.
POid
()
AB
=
B
}
// path prefix to A and B
ABpath
:=
trackSet
.
Path
(
ABoid
)
// key coverage for A and B
ABlo
:=
KeyMin
ABhi_
:=
KeyMax
node
:=
AB
ABcov
:
for
i
:=
len
(
ABpath
)
-
2
;
i
>=
0
;
i
--
{
xparent
,
err
:=
node
.
PJar
()
.
Get
(
ctx
,
ABpath
[
i
]);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
}
parent
:=
xparent
.
(
*
Tree
)
// must succeed
// find node in parent children and constrain ABlo/ABhi accordingly
entryv
:=
parent
.
Entryv
()
for
j
,
entry
:=
range
entryv
{
if
entry
.
Child
()
==
node
{
// parent.entry[j] points to node
// [i].Key ≤ [i].Child.*.Key < [i+1].Key
klo
:=
entryv
[
j
]
.
Key
()
khi_
:=
KeyMax
if
j
+
1
<
len
(
entryv
)
{
khi_
=
entryv
[
j
+
1
]
.
Key
()
-
1
}
if
klo
>
ABlo
{
ABlo
=
klo
}
if
khi_
<
ABhi_
{
ABhi_
=
khi_
}
node
=
parent
continue
ABcov
}
}
panicf
(
"BUG: T%s points to T%s as parent in trackSet, but not found in T%s children"
,
node
.
POid
(),
parent
.
POid
(),
parent
.
POid
())
}
if
A
==
nil
||
B
==
nil
{
// top of the subtree must stay in the tracking set even if the subtree is removed
// this way, if later, the subtree will be recreated, that change won't be missed
...
...
@@ -496,11 +535,9 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackSet PPTreeSubSet)
}
// initial split ranges for A and B
// FIXME walk till a from root to get more precise initial range
// XXX ^^^ get it from ABpath[-1].keyrange
prefix
:=
ABpath
[
:
len
(
ABpath
)
-
1
]
atop
:=
&
nodeInRange
{
prefix
:
prefix
,
lo
:
KeyMin
,
hi_
:
KeyMax
,
node
:
A
}
// [-∞, ∞)
btop
:=
&
nodeInRange
{
prefix
:
prefix
,
lo
:
KeyMin
,
hi_
:
KeyMax
,
node
:
B
}
// [-∞, ∞)
atop
:=
&
nodeInRange
{
prefix
:
prefix
,
lo
:
ABlo
,
hi_
:
ABhi_
,
node
:
A
}
// [-∞, ∞)
btop
:=
&
nodeInRange
{
prefix
:
prefix
,
lo
:
ABlo
,
hi_
:
ABhi_
,
node
:
B
}
// [-∞, ∞)
Av
:=
rangeSplit
{
atop
}
// nodes expanded from A
Bv
:=
rangeSplit
{
btop
}
// nodes expanded from B
...
...
@@ -638,8 +675,13 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackSet PPTreeSubSet)
if
nc
:=
at
.
nchild
;
nc
!=
0
{
δtrack
.
δnchildNonLeafs
[
acOid
]
=
nc
}
// XXX δtkeycov
// debugfDiff(" δtrack - %s %v\n", ar, ra.Path())
ar
:=
KeyRange
{
ac
.
lo
,
ac
.
hi_
}
bc
:=
Bv
.
Get
(
ac
.
lo
)
br
:=
KeyRange
{
bc
.
lo
,
bc
.
hi_
}
δtkeycovADel
.
AddRange
(
ar
)
δtkeycovBAdd
.
AddRange
(
br
)
debugfDiff
(
" δtrack - %s %v KKK
\n
"
,
ar
,
apath
)
debugfDiff
(
" δtrack + %s %v KKK
\n
"
,
br
,
bpath
)
}
continue
...
...
@@ -940,11 +982,7 @@ func xidOf(obj zodb.IPersistent) string {
func
(
rn
*
nodeInRange
)
String
()
string
{
done
:=
" "
;
if
rn
.
done
{
done
=
"*"
}
hi
:=
rn
.
hi_
if
hi
<
KeyMax
{
hi
+=
1
}
return
fmt
.
Sprintf
(
"%s[%s,%s)%s"
,
done
,
kstr
(
rn
.
lo
),
kstr
(
hi
),
vnode
(
rn
.
node
))
return
fmt
.
Sprintf
(
"%s%s%s"
,
done
,
KeyRange
{
rn
.
lo
,
rn
.
hi_
},
vnode
(
rn
.
node
))
}
// push pushes element to node stack.
...
...
wcfs/internal/xbtree/δbtail_test.go
View file @
f2b44b94
...
...
@@ -1947,12 +1947,7 @@ func sortedKeys(kv map[Key]Δstring) []Key {
}
func
(
b
*
RBucket
)
String
()
string
{
// XXX dup wrt nodeInRange.String
hi
:=
b
.
hi_
if
hi
<
KeyMax
{
hi
+=
1
}
return
fmt
.
Sprintf
(
"[%s,%s)B%s{%s}"
,
kstr
(
b
.
lo
),
kstr
(
hi
),
b
.
oid
,
kvtxt
(
b
.
kv
))
return
fmt
.
Sprintf
(
"%sB%s{%s}"
,
KeyRange
{
b
.
lo
,
b
.
hi_
},
b
.
oid
,
kvtxt
(
b
.
kv
))
}
...
...
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