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
8672b6d8
Commit
8672b6d8
authored
Jul 01, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3c69ff8d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
41 deletions
+35
-41
wcfs/internal/xbtree/treediff.go
wcfs/internal/xbtree/treediff.go
+32
-38
wcfs/internal/xbtree/δbtail.go
wcfs/internal/xbtree/δbtail.go
+3
-3
No files found.
wcfs/internal/xbtree/treediff.go
View file @
8672b6d8
...
@@ -172,7 +172,7 @@ func δZConnectTracked(δZv []zodb.Oid, T blib.PPTreeSubSet) (δZTC setOid, δto
...
@@ -172,7 +172,7 @@ func δZConnectTracked(δZv []zodb.Oid, T blib.PPTreeSubSet) (δZTC setOid, δto
// nodeInRange represents a Node coming under [lo, hi_] key range in its tree.
// nodeInRange represents a Node coming under [lo, hi_] key range in its tree.
type
nodeInRange
struct
{
type
nodeInRange
struct
{
prefix
[]
zodb
.
Oid
// path to this node goes via this objects
prefix
[]
zodb
.
Oid
// path to this node goes via this objects
lo
,
hi_
Key
// [lo, hi_] NOTE _not_ hi) not to overflow at ∞ XXX -> keycov KeyRange?
keycov
blib
.
KeyRange
node
Node
node
Node
done
bool
// whether this node was already taken into account while computing diff
done
bool
// whether this node was already taken into account while computing diff
}
}
...
@@ -210,14 +210,14 @@ func (rs rangeSplit) Get(k Key) *nodeInRange {
...
@@ -210,14 +210,14 @@ func (rs rangeSplit) Get(k Key) *nodeInRange {
// Get_ returns node covering key k.
// Get_ returns node covering key k.
func
(
rs
rangeSplit
)
Get_
(
k
Key
)
(
rnode
*
nodeInRange
,
ok
bool
)
{
func
(
rs
rangeSplit
)
Get_
(
k
Key
)
(
rnode
*
nodeInRange
,
ok
bool
)
{
i
:=
sort
.
Search
(
len
(
rs
),
func
(
i
int
)
bool
{
i
:=
sort
.
Search
(
len
(
rs
),
func
(
i
int
)
bool
{
return
k
<=
rs
[
i
]
.
h
i_
return
k
<=
rs
[
i
]
.
keycov
.
H
i_
})
})
if
i
==
len
(
rs
)
{
if
i
==
len
(
rs
)
{
return
nil
,
false
// key not covered
return
nil
,
false
// key not covered
}
}
rn
:=
rs
[
i
]
rn
:=
rs
[
i
]
if
!
(
rn
.
lo
<=
k
&&
k
<=
rn
.
hi_
)
{
if
!
rn
.
keycov
.
Has
(
k
)
{
panicf
(
"BUG: get(%v) -> %s; coverage: %s"
,
k
,
rn
,
rs
)
panicf
(
"BUG: get(%v) -> %s; coverage: %s"
,
k
,
rn
,
rs
)
}
}
...
@@ -234,7 +234,7 @@ func (rs rangeSplit) Get_(k Key) (rnode *nodeInRange, ok bool) {
...
@@ -234,7 +234,7 @@ func (rs rangeSplit) Get_(k Key) (rnode *nodeInRange, ok bool) {
func
(
prs
*
rangeSplit
)
Expand
(
rnode
*
nodeInRange
)
(
children
rangeSplit
)
{
func
(
prs
*
rangeSplit
)
Expand
(
rnode
*
nodeInRange
)
(
children
rangeSplit
)
{
rs
:=
*
prs
rs
:=
*
prs
i
:=
sort
.
Search
(
len
(
rs
),
func
(
i
int
)
bool
{
i
:=
sort
.
Search
(
len
(
rs
),
func
(
i
int
)
bool
{
return
rnode
.
hi_
<=
rs
[
i
]
.
h
i_
return
rnode
.
keycov
.
Hi_
<=
rs
[
i
]
.
keycov
.
H
i_
})
})
if
i
==
len
(
rs
)
||
rs
[
i
]
!=
rnode
{
if
i
==
len
(
rs
)
||
rs
[
i
]
!=
rnode
{
panicf
(
"%s not in rangeSplit; coverage: %s"
,
rnode
,
rs
)
panicf
(
"%s not in rangeSplit; coverage: %s"
,
rnode
,
rs
)
...
@@ -248,19 +248,18 @@ func (prs *rangeSplit) Expand(rnode *nodeInRange) (children rangeSplit) {
...
@@ -248,19 +248,18 @@ func (prs *rangeSplit) Expand(rnode *nodeInRange) (children rangeSplit) {
treev
:=
tree
.
Entryv
()
treev
:=
tree
.
Entryv
()
children
=
make
(
rangeSplit
,
0
,
len
(
treev
)
+
1
)
children
=
make
(
rangeSplit
,
0
,
len
(
treev
)
+
1
)
for
i
:=
range
treev
{
for
i
:=
range
treev
{
lo
:=
rnode
.
l
o
lo
:=
rnode
.
keycov
.
L
o
if
i
>
0
{
if
i
>
0
{
lo
=
treev
[
i
]
.
Key
()
lo
=
treev
[
i
]
.
Key
()
}
}
hi_
:=
rnode
.
h
i_
hi_
:=
rnode
.
keycov
.
H
i_
if
i
<
len
(
treev
)
-
1
{
if
i
<
len
(
treev
)
-
1
{
hi_
=
treev
[
i
+
1
]
.
Key
()
-
1
// NOTE -1 because it is hi_] not hi)
hi_
=
treev
[
i
+
1
]
.
Key
()
-
1
// NOTE -1 because it is hi_] not hi)
}
}
children
=
append
(
children
,
&
nodeInRange
{
children
=
append
(
children
,
&
nodeInRange
{
prefix
:
rnode
.
Path
(),
prefix
:
rnode
.
Path
(),
lo
:
lo
,
keycov
:
blib
.
KeyRange
{
lo
,
hi_
},
hi_
:
hi_
,
node
:
treev
[
i
]
.
Child
(),
node
:
treev
[
i
]
.
Child
(),
})
})
}
}
...
@@ -558,9 +557,10 @@ ABcov:
...
@@ -558,9 +557,10 @@ ABcov:
}
}
// initial split ranges for A and B
// initial split ranges for A and B
ABcov
:=
blib
.
KeyRange
{
ABlo
,
ABhi_
}
prefix
:=
ABpath
[
:
len
(
ABpath
)
-
1
]
prefix
:=
ABpath
[
:
len
(
ABpath
)
-
1
]
atop
:=
&
nodeInRange
{
prefix
:
prefix
,
lo
:
ABlo
,
hi_
:
ABhi_
,
node
:
A
}
// [-∞, ∞)
atop
:=
&
nodeInRange
{
prefix
:
prefix
,
keycov
:
ABcov
,
node
:
A
}
btop
:=
&
nodeInRange
{
prefix
:
prefix
,
lo
:
ABlo
,
hi_
:
ABhi_
,
node
:
B
}
// [-∞, ∞)
btop
:=
&
nodeInRange
{
prefix
:
prefix
,
keycov
:
ABcov
,
node
:
B
}
Av
:=
rangeSplit
{
atop
}
// nodes expanded from A
Av
:=
rangeSplit
{
atop
}
// nodes expanded from A
Bv
:=
rangeSplit
{
btop
}
// nodes expanded from B
Bv
:=
rangeSplit
{
btop
}
// nodes expanded from B
...
@@ -621,23 +621,21 @@ ABcov:
...
@@ -621,23 +621,21 @@ ABcov:
// a is bucket -> δ-
// a is bucket -> δ-
δA
,
err
:=
diffB
(
ctx
,
a
,
nil
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
}
δA
,
err
:=
diffB
(
ctx
,
a
,
nil
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
}
err
=
δMerge
(
δ
,
δA
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
}
err
=
δMerge
(
δ
,
δA
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
}
ar
:=
blib
.
KeyRange
{
ra
.
lo
,
ra
.
hi_
}
δtrack
.
Del
.
AddPath
(
ra
.
Path
())
δtrack
.
Del
.
AddPath
(
ra
.
Path
())
δtkeycovADel
.
AddRange
(
ar
)
δtkeycovADel
.
AddRange
(
ra
.
keycov
)
debugfDiff
(
" δtrack - %s %v
\n
"
,
ar
,
ra
.
Path
())
debugfDiff
(
" δtrack - %s %v
\n
"
,
ra
.
keycov
,
ra
.
Path
())
// Bkqueue <- ra.range
// Bkqueue <- ra.range
Bktodo
(
ar
)
Bktodo
(
ra
.
keycov
)
ra
.
done
=
true
ra
.
done
=
true
case
*
Tree
:
case
*
Tree
:
// empty tree - queue holes covered by it
// empty tree - queue holes covered by it
if
len
(
a
.
Entryv
())
==
0
{
if
len
(
a
.
Entryv
())
==
0
{
ar
:=
blib
.
KeyRange
{
ra
.
lo
,
ra
.
hi_
}
δtrack
.
Del
.
AddPath
(
ra
.
Path
())
δtrack
.
Del
.
AddPath
(
ra
.
Path
())
δtkeycovADel
.
AddRange
(
ar
)
δtkeycovADel
.
AddRange
(
ra
.
keycov
)
debugfDiff
(
" δtrack - %s %v
\n
"
,
ar
,
ra
.
Path
())
debugfDiff
(
" δtrack - %s %v
\n
"
,
ra
.
keycov
,
ra
.
Path
())
Bktodo
(
ar
)
Bktodo
(
ra
.
keycov
)
continue
continue
}
}
...
@@ -660,8 +658,8 @@ ABcov:
...
@@ -660,8 +658,8 @@ ABcov:
bc
,
found
:=
BnodeIdx
[
acOid
]
bc
,
found
:=
BnodeIdx
[
acOid
]
if
!
found
{
if
!
found
{
for
{
for
{
blo
:=
Bv
.
Get
(
ac
.
l
o
)
blo
:=
Bv
.
Get
(
ac
.
keycov
.
L
o
)
bhi_
:=
Bv
.
Get
(
ac
.
h
i_
)
bhi_
:=
Bv
.
Get
(
ac
.
keycov
.
H
i_
)
if
blo
!=
bhi_
{
if
blo
!=
bhi_
{
break
break
}
}
...
@@ -692,9 +690,7 @@ ABcov:
...
@@ -692,9 +690,7 @@ ABcov:
}
}
if
found
{
if
found
{
// ac can be skipped if key coverage stays the same
// ac can be skipped if key coverage stays the same
ar
:=
blib
.
KeyRange
{
ac
.
lo
,
ac
.
hi_
}
if
ac
.
keycov
==
bc
.
keycov
{
br
:=
blib
.
KeyRange
{
bc
.
lo
,
bc
.
hi_
}
if
ar
==
br
{
// adjust trackSet since path to the node could have changed
// adjust trackSet since path to the node could have changed
apath
:=
ac
.
Path
()
apath
:=
ac
.
Path
()
bpath
:=
bc
.
Path
()
bpath
:=
bc
.
Path
()
...
@@ -759,23 +755,22 @@ ABcov:
...
@@ -759,23 +755,22 @@ ABcov:
// δ <- δB
// δ <- δB
err
=
δMerge
(
δ
,
δB
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
}
err
=
δMerge
(
δ
,
δB
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
}
br
:=
blib
.
KeyRange
{
b
.
lo
,
b
.
hi_
}
δtrack
.
Add
.
AddPath
(
b
.
Path
())
δtrack
.
Add
.
AddPath
(
b
.
Path
())
δtkeycovBAdd
.
AddRange
(
b
r
)
δtkeycovBAdd
.
AddRange
(
b
.
keycov
)
debugfDiff
(
" δtrack + %s %v
\n
"
,
b
r
,
b
.
Path
())
debugfDiff
(
" δtrack + %s %v
\n
"
,
b
.
keycov
,
b
.
Path
())
// Akqueue <- δB
// Akqueue <- δB
Bkdone
.
AddRange
(
b
r
)
Bkdone
.
AddRange
(
b
.
keycov
)
Aktodo
(
b
r
)
Aktodo
(
b
.
keycov
)
b
.
done
=
true
b
.
done
=
true
}
}
// continue with next right bucket until r coverage is complete
// continue with next right bucket until r coverage is complete
if
r
.
Hi_
<=
b
.
h
i_
{
if
r
.
Hi_
<=
b
.
keycov
.
H
i_
{
break
break
}
}
lo
=
b
.
h
i_
+
1
lo
=
b
.
keycov
.
H
i_
+
1
}
}
}
}
Bkqueue
.
Clear
()
Bkqueue
.
Clear
()
...
@@ -799,27 +794,26 @@ ABcov:
...
@@ -799,27 +794,26 @@ ABcov:
err
=
δMerge
(
δ
,
δA
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
}
err
=
δMerge
(
δ
,
δA
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
}
δtrack
.
Del
.
AddPath
(
a
.
Path
())
δtrack
.
Del
.
AddPath
(
a
.
Path
())
// NOTE adjust δtkeycovADel only if a was originally tracked
// NOTE adjust δtkeycovADel only if a was originally tracked
ar
:=
blib
.
KeyRange
{
a
.
lo
,
a
.
hi_
}
_
,
tracked
:=
trackSet
[
a
.
node
.
POid
()]
_
,
tracked
:=
trackSet
[
a
.
node
.
POid
()]
if
tracked
{
if
tracked
{
δtkeycovADel
.
AddRange
(
a
r
)
δtkeycovADel
.
AddRange
(
a
.
keycov
)
debugfDiff
(
" δtrack - %s %v
\n
"
,
a
r
,
a
.
Path
())
debugfDiff
(
" δtrack - %s %v
\n
"
,
a
.
keycov
,
a
.
Path
())
}
else
{
}
else
{
debugfDiff
(
" δtrack - [) %v
\n
"
,
a
.
Path
())
debugfDiff
(
" δtrack - [) %v
\n
"
,
a
.
Path
())
}
}
// Bkqueue <- a.range
// Bkqueue <- a.range
Akdone
.
AddRange
(
a
r
)
Akdone
.
AddRange
(
a
.
keycov
)
Bktodo
(
a
r
)
Bktodo
(
a
.
keycov
)
a
.
done
=
true
a
.
done
=
true
}
}
// continue with next right bucket until r coverage is complete
// continue with next right bucket until r coverage is complete
if
r
.
Hi_
<=
a
.
h
i_
{
if
r
.
Hi_
<=
a
.
keycov
.
H
i_
{
break
break
}
}
lo
=
a
.
h
i_
+
1
lo
=
a
.
keycov
.
H
i_
+
1
}
}
}
}
Akqueue
.
Clear
()
Akqueue
.
Clear
()
...
@@ -1010,7 +1004,7 @@ func xidOf(obj zodb.IPersistent) string {
...
@@ -1010,7 +1004,7 @@ func xidOf(obj zodb.IPersistent) string {
func
(
rn
*
nodeInRange
)
String
()
string
{
func
(
rn
*
nodeInRange
)
String
()
string
{
done
:=
" "
;
if
rn
.
done
{
done
=
"*"
}
done
:=
" "
;
if
rn
.
done
{
done
=
"*"
}
return
fmt
.
Sprintf
(
"%s%s%s"
,
done
,
blib
.
KeyRange
{
rn
.
lo
,
rn
.
hi_
}
,
vnode
(
rn
.
node
))
return
fmt
.
Sprintf
(
"%s%s%s"
,
done
,
rn
.
keycov
,
vnode
(
rn
.
node
))
}
}
// push pushes element to node stack.
// push pushes element to node stack.
...
...
wcfs/internal/xbtree/δbtail.go
View file @
8672b6d8
...
@@ -428,7 +428,7 @@ func widenTrackNew(trackNew blib.PPTreeSubSet, δtkeycov *blib.RangedKeySet, roo
...
@@ -428,7 +428,7 @@ func widenTrackNew(trackNew blib.PPTreeSubSet, δtkeycov *blib.RangedKeySet, roo
}
}
tree
:=
xtree
.
(
*
Tree
)
// must succeed XXX better explicit panic?
tree
:=
xtree
.
(
*
Tree
)
// must succeed XXX better explicit panic?
top
:=
&
nodeInRange
{
prefix
:
nil
,
lo
:
KeyMin
,
hi_
:
KeyMax
,
node
:
tree
}
top
:=
&
nodeInRange
{
prefix
:
nil
,
keycov
:
blib
.
KeyRange
{
KeyMin
,
KeyMax
}
,
node
:
tree
}
V
:=
rangeSplit
{
top
}
V
:=
rangeSplit
{
top
}
for
_
,
r
:=
range
δtkeycov
.
AllRanges
()
{
for
_
,
r
:=
range
δtkeycov
.
AllRanges
()
{
lo
:=
r
.
Lo
lo
:=
r
.
Lo
...
@@ -437,10 +437,10 @@ func widenTrackNew(trackNew blib.PPTreeSubSet, δtkeycov *blib.RangedKeySet, roo
...
@@ -437,10 +437,10 @@ func widenTrackNew(trackNew blib.PPTreeSubSet, δtkeycov *blib.RangedKeySet, roo
trackNew
.
AddPath
(
b
.
Path
())
trackNew
.
AddPath
(
b
.
Path
())
// continue with next right bucket until r coverage is complete
// continue with next right bucket until r coverage is complete
if
r
.
Hi_
<=
b
.
h
i_
{
if
r
.
Hi_
<=
b
.
keycov
.
H
i_
{
break
break
}
}
lo
=
b
.
h
i_
+
1
lo
=
b
.
keycov
.
H
i_
+
1
}
}
}
}
return
nil
return
nil
...
...
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