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
f428df95
Commit
f428df95
authored
Jun 21, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c13a7bc0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
21 deletions
+42
-21
wcfs/internal/xbtree/pptreesubset.go
wcfs/internal/xbtree/pptreesubset.go
+19
-1
wcfs/internal/xbtree/treediff.go
wcfs/internal/xbtree/treediff.go
+1
-1
wcfs/internal/xbtree/δbtail.go
wcfs/internal/xbtree/δbtail.go
+18
-14
wcfs/internal/xbtree/δbtail_test.go
wcfs/internal/xbtree/δbtail_test.go
+4
-5
No files found.
wcfs/internal/xbtree/pptreesubset.go
View file @
f428df95
...
@@ -467,7 +467,7 @@ func (t nodeInTree) String() string {
...
@@ -467,7 +467,7 @@ func (t nodeInTree) String() string {
// - δ.Add, and
// - δ.Add, and
// - xfixup(+1, δnchildNonLeafs)
// - xfixup(+1, δnchildNonLeafs)
//
//
// produce correctly PP-connected set.
// produce
s
correctly PP-connected set.
type
ΔPPTreeSubSet
struct
{
type
ΔPPTreeSubSet
struct
{
Del
PPTreeSubSet
Del
PPTreeSubSet
Add
PPTreeSubSet
Add
PPTreeSubSet
...
@@ -513,3 +513,21 @@ func (S PPTreeSubSet) ApplyΔ(δ *ΔPPTreeSubSet) {
...
@@ -513,3 +513,21 @@ func (S PPTreeSubSet) ApplyΔ(δ *ΔPPTreeSubSet) {
S
.
xUnionInplace
(
δ
.
Add
)
S
.
xUnionInplace
(
δ
.
Add
)
S
.
xfixup
(
+
1
,
δ
.
δnchildNonLeafs
)
S
.
xfixup
(
+
1
,
δ
.
δnchildNonLeafs
)
}
}
// XXX returns PPTreeSubSet that corresponds to nodes that correspond to δtkeycov.
// XXX correct?
func
(
δ
*
ΔPPTreeSubSet
)
XXXδtkeycovSet
()
(
S
PPTreeSubSet
)
{
S
=
PPTreeSubSet
{}
δ
.
Del
.
verify
()
δ
.
Add
.
verify
()
defer
S
.
verify
()
//S.xfixup(-1, δ.δnchildNonLeafs)
S
.
xUnionInplace
(
δ
.
Add
)
S
.
xDifferenceInplace
(
δ
.
Del
)
//S.xfixup(+1, δ.δnchildNonLeafs)
return
S
}
wcfs/internal/xbtree/treediff.go
View file @
f428df95
...
@@ -606,7 +606,7 @@ ABcov:
...
@@ -606,7 +606,7 @@ ABcov:
ra
.
done
=
true
ra
.
done
=
true
case
*
Tree
:
case
*
Tree
:
// empty tree -
only
queue holes covered by it
// empty tree - queue holes covered by it
if
len
(
a
.
Entryv
())
==
0
{
if
len
(
a
.
Entryv
())
==
0
{
ar
:=
KeyRange
{
ra
.
lo
,
ra
.
hi_
}
ar
:=
KeyRange
{
ra
.
lo
,
ra
.
hi_
}
δtrack
.
Del
.
AddPath
(
ra
.
Path
())
δtrack
.
Del
.
AddPath
(
ra
.
Path
())
...
...
wcfs/internal/xbtree/δbtail.go
View file @
f428df95
...
@@ -504,14 +504,14 @@ func (δTtail *ΔTtail) rebuild1(atPrev zodb.Tid, δZ zodb.ΔRevEntry, trackNew
...
@@ -504,14 +504,14 @@ func (δTtail *ΔTtail) rebuild1(atPrev zodb.Tid, δZ zodb.ΔRevEntry, trackNew
//
//
// TODO optionally accept zconnOld/zconnNew from client
// TODO optionally accept zconnOld/zconnNew from client
func
(
δBtail
*
ΔBtail
)
Update
(
δZ
*
zodb
.
EventCommit
)
(
_
ΔB
,
err
error
)
{
func
(
δBtail
*
ΔBtail
)
Update
(
δZ
*
zodb
.
EventCommit
)
(
_
ΔB
,
err
error
)
{
δ
TKeyCov
1
,
err
:=
δBtail
.
_Update1
(
δZ
)
δ
B
1
,
err
:=
δBtail
.
_Update1
(
δZ
)
δB
:=
ΔB
{
Rev
:
δZ
.
Tid
,
ΔByRoot
:
make
(
map
[
zodb
.
Oid
]
map
[
Key
]
ΔValue
)}
δB
:=
ΔB
{
Rev
:
δZ
.
Tid
,
ΔByRoot
:
make
(
map
[
zodb
.
Oid
]
map
[
Key
]
ΔValue
)}
for
root
,
δ
tkeycov1
:=
range
δTKeyCov
1
.
ByRoot
{
for
root
,
δ
T1
:=
range
δB
1
.
ByRoot
{
δTtail
:=
δBtail
.
vδTbyRoot
[
root
]
// must succeed
δTtail
:=
δBtail
.
vδTbyRoot
[
root
]
// must succeed
// δtkeycov1 != ø -> rebuild δTtail
// δtkeycov1 != ø -> rebuild δTtail
if
!
δtkeycov1
.
Empty
()
&&
δBtail
.
δZtail
.
Len
()
>
1
{
if
!
δ
T1
.
δ
tkeycov1
.
Empty
()
&&
δBtail
.
δZtail
.
Len
()
>
1
{
//δTtail.trackNew = ... // ~δtkeycov1
//δTtail.trackNew = ... // ~δtkeycov1
δTtail
.
trackNew
=
nil
// XXX stub
δTtail
.
trackNew
=
nil
// XXX stub
...
@@ -546,10 +546,14 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
...
@@ -546,10 +546,14 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
// On key coverage growth rebuilding tail of the history is done by Update itself.
// On key coverage growth rebuilding tail of the history is done by Update itself.
//
//
// _Update1 is also used in tests to verify δtkeycov return from treediff.
// _Update1 is also used in tests to verify δtkeycov return from treediff.
type
_Δ
TrackKeyCov
1
struct
{
type
_Δ
BUpdate
1
struct
{
ByRoot
map
[
zodb
.
Oid
]
*
RangedKeySet
// {} root -> δtrackedKeys after first treediff (always grow)
ByRoot
map
[
zodb
.
Oid
]
*
_ΔTUpdate1
}
}
func
(
δBtail
*
ΔBtail
)
_Update1
(
δZ
*
zodb
.
EventCommit
)
(
δTKeyCov1
_ΔTrackKeyCov1
,
err
error
)
{
type
_ΔTUpdate1
struct
{
δtkeycov1
*
RangedKeySet
// {} root -> δtrackedKeys after first treediff (always grow)
δtrack
*
ΔPPTreeSubSet
}
func
(
δBtail
*
ΔBtail
)
_Update1
(
δZ
*
zodb
.
EventCommit
)
(
δB1
_ΔBUpdate1
,
err
error
)
{
headOld
:=
δBtail
.
Head
()
headOld
:=
δBtail
.
Head
()
defer
xerr
.
Contextf
(
&
err
,
"ΔBtail update %s -> %s"
,
headOld
,
δZ
.
Tid
)
defer
xerr
.
Contextf
(
&
err
,
"ΔBtail update %s -> %s"
,
headOld
,
δZ
.
Tid
)
...
@@ -560,7 +564,7 @@ func (δBtail *ΔBtail) _Update1(δZ *zodb.EventCommit) (δTKeyCov1 _ΔTrackKeyC
...
@@ -560,7 +564,7 @@ func (δBtail *ΔBtail) _Update1(δZ *zodb.EventCommit) (δTKeyCov1 _ΔTrackKeyC
tracefΔBtail
(
"[%s].trackNew: %v
\n
"
,
root
,
δTtail
.
trackNew
)
tracefΔBtail
(
"[%s].trackNew: %v
\n
"
,
root
,
δTtail
.
trackNew
)
}
}
δ
TKeyCov1
=
_ΔTrackKeyCov1
{
ByRoot
:
make
(
map
[
zodb
.
Oid
]
*
RangedKeySet
)}
δ
B1
=
_ΔBUpdate1
{
ByRoot
:
make
(
map
[
zodb
.
Oid
]
*
_ΔTUpdate1
)}
if
XXX_killWhenRebuildWorks
{
if
XXX_killWhenRebuildWorks
{
// XXX hack - until vvv is reenabled
// XXX hack - until vvv is reenabled
...
@@ -575,7 +579,7 @@ if XXX_killWhenRebuildWorks {
...
@@ -575,7 +579,7 @@ if XXX_killWhenRebuildWorks {
// update .trackSet and vδB from .trackNew
// update .trackSet and vδB from .trackNew
err
=
δBtail
.
rebuildAll
()
err
=
δBtail
.
rebuildAll
()
if
err
!=
nil
{
if
err
!=
nil
{
return
δ
TKeyCov
1
,
err
return
δ
B
1
,
err
}
}
}
}
...
@@ -587,7 +591,7 @@ if XXX_killWhenRebuildWorks {
...
@@ -587,7 +591,7 @@ if XXX_killWhenRebuildWorks {
// skip opening DB connections if there is no change to any tree node
// skip opening DB connections if there is no change to any tree node
if
len
(
δtopsByRoot
)
==
0
{
if
len
(
δtopsByRoot
)
==
0
{
return
δ
TKeyCov
1
,
nil
return
δ
B
1
,
nil
}
}
// open ZODB connections corresponding to "old" and "new" states
// open ZODB connections corresponding to "old" and "new" states
...
@@ -596,17 +600,17 @@ if XXX_killWhenRebuildWorks {
...
@@ -596,17 +600,17 @@ if XXX_killWhenRebuildWorks {
defer
txn
.
Abort
()
defer
txn
.
Abort
()
zconnOld
,
err
:=
δBtail
.
db
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
headOld
})
zconnOld
,
err
:=
δBtail
.
db
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
headOld
})
if
err
!=
nil
{
if
err
!=
nil
{
return
δ
TKeyCov
1
,
err
return
δ
B
1
,
err
}
}
zconnNew
,
err
:=
δBtail
.
db
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
δZ
.
Tid
})
zconnNew
,
err
:=
δBtail
.
db
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
δZ
.
Tid
})
if
err
!=
nil
{
if
err
!=
nil
{
return
δ
TKeyCov
1
,
err
return
δ
B
1
,
err
}
}
for
root
,
δtops
:=
range
δtopsByRoot
{
for
root
,
δtops
:=
range
δtopsByRoot
{
δT
,
δtrack
,
δtkeycov
,
err
:=
treediff
(
ctx
,
root
,
δtops
,
δZTC
,
δBtail
.
trackSet
,
zconnOld
,
zconnNew
)
δT
,
δtrack
,
δtkeycov
,
err
:=
treediff
(
ctx
,
root
,
δtops
,
δZTC
,
δBtail
.
trackSet
,
zconnOld
,
zconnNew
)
if
err
!=
nil
{
if
err
!=
nil
{
return
δ
TKeyCov
1
,
err
return
δ
B
1
,
err
}
}
tracefΔBtail
(
"
\n
-> root<%s> δkv: %v δtrack: %v δtkeycov: %v
\n
"
,
root
,
δT
,
δtrack
,
δtkeycov
)
tracefΔBtail
(
"
\n
-> root<%s> δkv: %v δtrack: %v δtkeycov: %v
\n
"
,
root
,
δT
,
δtrack
,
δtkeycov
)
...
@@ -617,10 +621,10 @@ if XXX_killWhenRebuildWorks {
...
@@ -617,10 +621,10 @@ if XXX_killWhenRebuildWorks {
}
}
δBtail
.
trackSet
.
ApplyΔ
(
δtrack
)
δBtail
.
trackSet
.
ApplyΔ
(
δtrack
)
δ
TKeyCov1
.
ByRoot
[
root
]
=
δtkeycov
δ
B1
.
ByRoot
[
root
]
=
&
_ΔTUpdate1
{
δtkeycov1
:
δtkeycov
,
δtrack
:
δtrack
}
}
}
return
δ
TKeyCov
1
,
nil
return
δ
B
1
,
nil
}
}
...
...
wcfs/internal/xbtree/δbtail_test.go
View file @
f428df95
...
@@ -810,11 +810,10 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
...
@@ -810,11 +810,10 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
// also call _Update1 directly to verify δtkeycov return from treediff
// also call _Update1 directly to verify δtkeycov return from treediff
// the result of Update and _Update1 should be the same since δbtail is initially empty.
// the result of Update and _Update1 should be the same since δbtail is initially empty.
δbtail_
:=
δbtail
.
Clone
()
δbtail_
:=
δbtail
.
Clone
()
δB
,
err
:=
δbtail
.
Update
(
δZ
);
X
(
err
)
δB
,
err
:=
δbtail
.
Update
(
δZ
);
X
(
err
)
δ
TKeyCov
,
err
:=
δbtail_
.
_Update1
(
δZ
);
X
(
err
)
δ
B1
,
err
:=
δbtail_
.
_Update1
(
δZ
);
X
(
err
)
// XXX assert δB.roots == δTKeyCov roots
// XXX assert δB.roots == δTKeyCov roots
// XXX assert δBtail[root].vδT[-1] = δBtail_[root].vδT[-1]
// XXX assert δBtail[root].vδT = δBtail_[root].vδT
// XXX -> just assert δBtail == δBtail_ ?
if
δB
.
Rev
!=
δZ
.
Tid
{
if
δB
.
Rev
!=
δZ
.
Tid
{
badf
(
"δB: rev != δZ.Tid ; rev=%s δZ.Tid=%s"
,
δB
.
Rev
,
δZ
.
Tid
)
badf
(
"δB: rev != δZ.Tid ; rev=%s δZ.Tid=%s"
,
δB
.
Rev
,
δZ
.
Tid
)
...
@@ -855,7 +854,7 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
...
@@ -855,7 +854,7 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
// assert δtkeycov == δ(tkeyCov1, tkeyCov2)
// assert δtkeycov == δ(tkeyCov1, tkeyCov2)
δtkeycovOK
:=
tkeyCov2
.
Difference
(
tkeyCov1
)
δtkeycovOK
:=
tkeyCov2
.
Difference
(
tkeyCov1
)
δtkeycov
:=
δ
TKeyCov
.
ByRoot
[
treeRoot
]
δtkeycov
:=
δ
B1
.
ByRoot
[
treeRoot
]
.
δtkeycov1
if
!
δtkeycov
.
Equal
(
δtkeycovOK
)
{
if
!
δtkeycov
.
Equal
(
δtkeycovOK
)
{
badf
(
"δtkeycov wrong:
\n
have: %s
\n
want: %s"
,
δtkeycov
,
δtkeycovOK
)
badf
(
"δtkeycov wrong:
\n
have: %s
\n
want: %s"
,
δtkeycov
,
δtkeycovOK
)
}
}
...
...
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