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
4fec22ea
Commit
4fec22ea
authored
Sep 21, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
54276eb7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
22 deletions
+21
-22
wcfs/internal/xbtree/δbtail.go
wcfs/internal/xbtree/δbtail.go
+10
-10
wcfs/internal/xbtree/δbtail_test.go
wcfs/internal/xbtree/δbtail_test.go
+7
-7
wcfs/internal/zdata/δftail.go
wcfs/internal/zdata/δftail.go
+4
-5
No files found.
wcfs/internal/xbtree/δbtail.go
View file @
4fec22ea
...
@@ -118,19 +118,19 @@ type _ΔTtail struct {
...
@@ -118,19 +118,19 @@ type _ΔTtail struct {
// It describes which trees were changed, but does not provide δkv details for changed trees.
// It describes which trees were changed, but does not provide δkv details for changed trees.
type
_ΔBroots
struct
{
type
_ΔBroots
struct
{
Rev
zodb
.
Tid
Rev
zodb
.
Tid
Δ
Roots
setOid
// which roots changed in this revision
Roots
setOid
// which roots changed in this revision
}
}
// ΔB represents a change in BTrees space.
// ΔB represents a change in BTrees space.
type
ΔB
struct
{
type
ΔB
struct
{
Rev
zodb
.
Tid
Rev
zodb
.
Tid
Δ
ByRoot
map
[
zodb
.
Oid
]
map
[
Key
]
ΔValue
// {} root -> {}(key, δvalue)
ByRoot
map
[
zodb
.
Oid
]
map
[
Key
]
ΔValue
// {} root -> {}(key, δvalue)
}
}
// ΔTree describes changes to one BTree in one revision.
// ΔTree describes changes to one BTree in one revision.
type
ΔTree
struct
{
type
ΔTree
struct
{
Rev
zodb
.
Tid
Rev
zodb
.
Tid
ΔKV
map
[
Key
]
ΔValue
ΔKV
map
[
Key
]
ΔValue
// XXX -> KV ?
}
}
...
@@ -175,7 +175,7 @@ func (orig *ΔBtail) Clone() *ΔBtail {
...
@@ -175,7 +175,7 @@ func (orig *ΔBtail) Clone() *ΔBtail {
for
_
,
origδBroots
:=
range
orig
.
vδBroots
{
for
_
,
origδBroots
:=
range
orig
.
vδBroots
{
klonδBroots
:=
_ΔBroots
{
klonδBroots
:=
_ΔBroots
{
Rev
:
origδBroots
.
Rev
,
Rev
:
origδBroots
.
Rev
,
ΔRoots
:
origδBroots
.
Δ
Roots
.
Clone
(),
Roots
:
origδBroots
.
Roots
.
Clone
(),
}
}
klon
.
vδBroots
=
append
(
klon
.
vδBroots
,
klonδBroots
)
klon
.
vδBroots
=
append
(
klon
.
vδBroots
,
klonδBroots
)
}
}
...
@@ -566,7 +566,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
...
@@ -566,7 +566,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
δB1
,
err
:=
δBtail
.
_Update1
(
δZ
)
δB1
,
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
,
δT1
:=
range
δB1
.
ByRoot
{
for
root
,
δT1
:=
range
δB1
.
ByRoot
{
δTtail
:=
δBtail
.
vδTbyRoot
[
root
]
// must succeed
δTtail
:=
δBtail
.
vδTbyRoot
[
root
]
// must succeed
...
@@ -597,7 +597,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
...
@@ -597,7 +597,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
if
l
>
0
{
if
l
>
0
{
δT
:=
δTtail
.
vδT
[
l
-
1
]
// δT head
δT
:=
δTtail
.
vδT
[
l
-
1
]
// δT head
if
δT
.
Rev
==
δZ
.
Tid
{
if
δT
.
Rev
==
δZ
.
Tid
{
δB
.
Δ
ByRoot
[
root
]
=
δT
.
ΔKV
δB
.
ByRoot
[
root
]
=
δT
.
ΔKV
}
}
}
}
...
@@ -605,7 +605,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
...
@@ -605,7 +605,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
}
}
// vδBroots += δB (δB.Rev could be already there added by ^^^ rebuild)
// vδBroots += δB (δB.Rev could be already there added by ^^^ rebuild)
for
root
:=
range
δB
.
Δ
ByRoot
{
for
root
:=
range
δB
.
ByRoot
{
δBtail
.
vδBroots_Update1
(
root
,
δB
.
Rev
)
δBtail
.
vδBroots_Update1
(
root
,
δB
.
Rev
)
}
}
...
@@ -704,14 +704,14 @@ func (δBtail *ΔBtail) vδBroots_Update1(root zodb.Oid, rev zodb.Tid) {
...
@@ -704,14 +704,14 @@ func (δBtail *ΔBtail) vδBroots_Update1(root zodb.Oid, rev zodb.Tid) {
return
rev
<=
δBtail
.
vδBroots
[
k
]
.
Rev
return
rev
<=
δBtail
.
vδBroots
[
k
]
.
Rev
})
})
if
j
==
l
||
rev
!=
δBtail
.
vδBroots
[
j
]
.
Rev
{
if
j
==
l
||
rev
!=
δBtail
.
vδBroots
[
j
]
.
Rev
{
δBroots
:=
_ΔBroots
{
Rev
:
rev
,
Δ
Roots
:
setOid
{}}
δBroots
:=
_ΔBroots
{
Rev
:
rev
,
Roots
:
setOid
{}}
// insert(@j, δBroots)
// insert(@j, δBroots)
δBtail
.
vδBroots
=
append
(
δBtail
.
vδBroots
[
:
j
],
δBtail
.
vδBroots
=
append
(
δBtail
.
vδBroots
[
:
j
],
append
([]
_ΔBroots
{
δBroots
},
append
([]
_ΔBroots
{
δBroots
},
δBtail
.
vδBroots
[
j
:
]
...
)
...
)
δBtail
.
vδBroots
[
j
:
]
...
)
...
)
}
}
δBroots
:=
δBtail
.
vδBroots
[
j
]
δBroots
:=
δBtail
.
vδBroots
[
j
]
δBroots
.
Δ
Roots
.
Add
(
root
)
δBroots
.
Roots
.
Add
(
root
)
}
}
// ForgetPast forgets history entries with revision ≤ revCut.
// ForgetPast forgets history entries with revision ≤ revCut.
...
@@ -729,7 +729,7 @@ func (δBtail *ΔBtail) ForgetPast(revCut zodb.Tid) {
...
@@ -729,7 +729,7 @@ func (δBtail *ΔBtail) ForgetPast(revCut zodb.Tid) {
if
δBroots
.
Rev
>
revCut
{
if
δBroots
.
Rev
>
revCut
{
break
break
}
}
totrim
.
Update
(
δBroots
.
Δ
Roots
)
totrim
.
Update
(
δBroots
.
Roots
)
}
}
// vδBroots[:icut] should be forgotten
// vδBroots[:icut] should be forgotten
...
...
wcfs/internal/xbtree/δbtail_test.go
View file @
4fec22ea
...
@@ -757,20 +757,20 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
...
@@ -757,20 +757,20 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
rootsOK
.
Add
(
treeRoot
)
rootsOK
.
Add
(
treeRoot
)
}
}
roots
:=
setOid
{}
roots
:=
setOid
{}
for
root
:=
range
δB
.
Δ
ByRoot
{
for
root
:=
range
δB
.
ByRoot
{
roots
.
Add
(
root
)
roots
.
Add
(
root
)
}
}
if
!
reflect
.
DeepEqual
(
roots
,
rootsOK
)
{
if
!
reflect
.
DeepEqual
(
roots
,
rootsOK
)
{
badf
(
"δB: roots != rootsOK ; roots=%v rootsOK=%v"
,
roots
,
rootsOK
)
badf
(
"δB: roots != rootsOK ; roots=%v rootsOK=%v"
,
roots
,
rootsOK
)
}
}
_
,
inδB
:=
δB
.
Δ
ByRoot
[
treeRoot
]
_
,
inδB
:=
δB
.
ByRoot
[
treeRoot
]
if
!
inδB
{
if
!
inδB
{
return
return
}
}
// δT <- δB
// δT <- δB
δToid
:=
δB
.
ΔByRoot
[
treeRoot
]
// {} k -> δoid
δToid
:=
δB
.
ByRoot
[
treeRoot
]
// {} k -> δoid
δT
=
xgetδKV
(
t1
,
t2
,
δToid
)
// {} k -> δ(ZBlk(oid).data)
δT
=
xgetδKV
(
t1
,
t2
,
δToid
)
// {} k -> δ(ZBlk(oid).data)
// δT must be subset of d12.
// δT must be subset of d12.
...
@@ -1020,15 +1020,15 @@ func xverifyΔBTail_rebuild_U(t *testing.T, δbtail *ΔBtail, treeRoot zodb.Oid,
...
@@ -1020,15 +1020,15 @@ func xverifyΔBTail_rebuild_U(t *testing.T, δbtail *ΔBtail, treeRoot zodb.Oid,
for
root
:=
range
δbtail
.
vδTbyRoot
{
for
root
:=
range
δbtail
.
vδTbyRoot
{
δroots
.
Add
(
root
)
δroots
.
Add
(
root
)
}
}
δToid
,
ok
:=
δB
.
Δ
ByRoot
[
treeRoot
]
δToid
,
ok
:=
δB
.
ByRoot
[
treeRoot
]
if
ok
{
if
ok
{
δT
=
xgetδKV
(
ti
,
tj
,
δToid
)
δT
=
xgetδKV
(
ti
,
tj
,
δToid
)
}
}
if
δB
.
Rev
!=
tj
.
At
{
if
δB
.
Rev
!=
tj
.
At
{
t
.
Errorf
(
"%s: δB.Rev: have %s ; want %s"
,
subj
,
δB
.
Rev
,
tj
.
At
)
t
.
Errorf
(
"%s: δB.Rev: have %s ; want %s"
,
subj
,
δB
.
Rev
,
tj
.
At
)
}
}
if
len
(
δB
.
Δ
ByRoot
)
!=
δrootsOK
{
if
len
(
δB
.
ByRoot
)
!=
δrootsOK
{
t
.
Errorf
(
"%s: len(δB.
Δ
ByRoot) != %d ; δroots=%v"
,
subj
,
δrootsOK
,
δroots
)
t
.
Errorf
(
"%s: len(δB.ByRoot) != %d ; δroots=%v"
,
subj
,
δrootsOK
,
δroots
)
}
}
if
!
δTEqual
(
δT
,
δTok
)
{
if
!
δTEqual
(
δT
,
δTok
)
{
t
.
Errorf
(
"%s: δB.ΔBByRoot[%s]:
\n
have: %v
\n
want: %v"
,
subj
,
treeRoot
,
δT
,
δTok
)
t
.
Errorf
(
"%s: δB.ΔBByRoot[%s]:
\n
have: %v
\n
want: %v"
,
subj
,
treeRoot
,
δT
,
δTok
)
...
@@ -1554,7 +1554,7 @@ func assertΔTtail(t *testing.T, subj string, δbtail *ΔBtail, tj *xbtreetest.C
...
@@ -1554,7 +1554,7 @@ func assertΔTtail(t *testing.T, subj string, δbtail *ΔBtail, tj *xbtreetest.C
var
vatδB
[]
zodb
.
Tid
// δbtail.vδBroots/treeRoot
var
vatδB
[]
zodb
.
Tid
// δbtail.vδBroots/treeRoot
for
_
,
δBroots
:=
range
δbtail
.
vδBroots
{
for
_
,
δBroots
:=
range
δbtail
.
vδBroots
{
if
δBroots
.
Δ
Roots
.
Has
(
treeRoot
)
{
if
δBroots
.
Roots
.
Has
(
treeRoot
)
{
vatδB
=
append
(
vatδB
,
δBroots
.
Rev
)
vatδB
=
append
(
vatδB
,
δBroots
.
Rev
)
}
}
}
}
...
...
wcfs/internal/zdata/δftail.go
View file @
4fec22ea
...
@@ -305,13 +305,13 @@ func (δFtail *ΔFtail) rebuildIfNeeded(foid zodb.Oid) (_ *_ΔFileTail, err erro
...
@@ -305,13 +305,13 @@ func (δFtail *ΔFtail) rebuildIfNeeded(foid zodb.Oid) (_ *_ΔFileTail, err erro
return
δftail
,
err
return
δftail
,
err
}
}
// rebuild rebuilds vδE.
// rebuild
1
rebuilds vδE.
func
(
δftail
*
_ΔFileTail
)
rebuild1
(
foid
zodb
.
Oid
,
δZtail
*
zodb
.
ΔTail
,
db
*
zodb
.
DB
)
(
err
error
)
{
func
(
δftail
*
_ΔFileTail
)
rebuild1
(
foid
zodb
.
Oid
,
δZtail
*
zodb
.
ΔTail
,
db
*
zodb
.
DB
)
(
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"file<%s>: rebuild"
,
foid
)
defer
xerr
.
Contextf
(
&
err
,
"file<%s>: rebuild"
,
foid
)
// XXX locking
// XXX locking
if
δftail
.
vδE
!=
nil
{
if
δftail
.
vδE
!=
nil
{
panic
(
"rebuild: vδE != nil"
)
panic
(
"rebuild
1
: vδE != nil"
)
}
}
vδE
:=
[]
_ΔFileEpoch
{}
vδE
:=
[]
_ΔFileEpoch
{}
...
@@ -372,7 +372,6 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
...
@@ -372,7 +372,6 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
}
}
headOld
:=
δFtail
.
Head
()
headOld
:=
δFtail
.
Head
()
δB
,
err
:=
δFtail
.
δBtail
.
Update
(
δZ
)
δB
,
err
:=
δFtail
.
δBtail
.
Update
(
δZ
)
if
err
!=
nil
{
if
err
!=
nil
{
return
ΔF
{},
err
return
ΔF
{},
err
...
@@ -418,8 +417,8 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
...
@@ -418,8 +417,8 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
}
}
// take btree changes into account
// take btree changes into account
//fmt.Printf("δB.
ΔByRoot: %v\n", δB.Δ
ByRoot)
//fmt.Printf("δB.
ByRoot: %v\n", δB.
ByRoot)
for
root
,
δt
:=
range
δB
.
Δ
ByRoot
{
for
root
,
δt
:=
range
δB
.
ByRoot
{
//fmt.Printf("root: %v δt: %v\n", root, δt)
//fmt.Printf("root: %v δt: %v\n", root, δt)
files
:=
δFtail
.
filesByRoot
[
root
]
files
:=
δFtail
.
filesByRoot
[
root
]
// NOTE files might be empty e.g. if a zfile was tracked, then
// NOTE files might be empty e.g. if a zfile was tracked, then
...
...
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