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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
25 deletions
+24
-25
wcfs/internal/xbtree/δbtail.go
wcfs/internal/xbtree/δbtail.go
+13
-13
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
...
...
@@ -117,20 +117,20 @@ type _ΔTtail struct {
//
// It describes which trees were changed, but does not provide δkv details for changed trees.
type
_ΔBroots
struct
{
Rev
zodb
.
Tid
Δ
Roots
setOid
// which roots changed in this revision
Rev
zodb
.
Tid
Roots
setOid
// which roots changed in this revision
}
// ΔB represents a change in BTrees space.
type
ΔB
struct
{
Rev
zodb
.
Tid
Δ
ByRoot
map
[
zodb
.
Oid
]
map
[
Key
]
ΔValue
// {} root -> {}(key, δvalue)
Rev
zodb
.
Tid
ByRoot
map
[
zodb
.
Oid
]
map
[
Key
]
ΔValue
// {} root -> {}(key, δvalue)
}
// ΔTree describes changes to one BTree in one revision.
type
ΔTree
struct
{
Rev
zodb
.
Tid
ΔKV
map
[
Key
]
ΔValue
ΔKV
map
[
Key
]
ΔValue
// XXX -> KV ?
}
...
...
@@ -174,8 +174,8 @@ func (orig *ΔBtail) Clone() *ΔBtail {
klon
.
vδBroots
=
make
([]
_ΔBroots
,
0
,
len
(
orig
.
vδBroots
))
for
_
,
origδBroots
:=
range
orig
.
vδBroots
{
klonδBroots
:=
_ΔBroots
{
Rev
:
origδBroots
.
Rev
,
ΔRoots
:
origδBroots
.
Δ
Roots
.
Clone
(),
Rev
:
origδBroots
.
Rev
,
Roots
:
origδBroots
.
Roots
.
Clone
(),
}
klon
.
vδBroots
=
append
(
klon
.
vδBroots
,
klonδBroots
)
}
...
...
@@ -566,7 +566,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
δ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
{
δTtail
:=
δBtail
.
vδTbyRoot
[
root
]
// must succeed
...
...
@@ -597,7 +597,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
if
l
>
0
{
δT
:=
δTtail
.
vδT
[
l
-
1
]
// δT head
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) {
}
// 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
)
}
...
...
@@ -704,14 +704,14 @@ func (δBtail *ΔBtail) vδBroots_Update1(root zodb.Oid, rev zodb.Tid) {
return
rev
<=
δBtail
.
vδBroots
[
k
]
.
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)
δBtail
.
vδBroots
=
append
(
δBtail
.
vδBroots
[
:
j
],
append
([]
_ΔBroots
{
δ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.
...
...
@@ -729,7 +729,7 @@ func (δBtail *ΔBtail) ForgetPast(revCut zodb.Tid) {
if
δBroots
.
Rev
>
revCut
{
break
}
totrim
.
Update
(
δBroots
.
Δ
Roots
)
totrim
.
Update
(
δBroots
.
Roots
)
}
// 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
rootsOK
.
Add
(
treeRoot
)
}
roots
:=
setOid
{}
for
root
:=
range
δB
.
Δ
ByRoot
{
for
root
:=
range
δB
.
ByRoot
{
roots
.
Add
(
root
)
}
if
!
reflect
.
DeepEqual
(
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
{
return
}
// δ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 must be subset of d12.
...
...
@@ -1020,15 +1020,15 @@ func xverifyΔBTail_rebuild_U(t *testing.T, δbtail *ΔBtail, treeRoot zodb.Oid,
for
root
:=
range
δbtail
.
vδTbyRoot
{
δroots
.
Add
(
root
)
}
δToid
,
ok
:=
δB
.
Δ
ByRoot
[
treeRoot
]
δToid
,
ok
:=
δB
.
ByRoot
[
treeRoot
]
if
ok
{
δT
=
xgetδKV
(
ti
,
tj
,
δToid
)
}
if
δB
.
Rev
!=
tj
.
At
{
t
.
Errorf
(
"%s: δB.Rev: have %s ; want %s"
,
subj
,
δB
.
Rev
,
tj
.
At
)
}
if
len
(
δB
.
Δ
ByRoot
)
!=
δrootsOK
{
t
.
Errorf
(
"%s: len(δB.
Δ
ByRoot) != %d ; δroots=%v"
,
subj
,
δrootsOK
,
δroots
)
if
len
(
δB
.
ByRoot
)
!=
δrootsOK
{
t
.
Errorf
(
"%s: len(δB.ByRoot) != %d ; δroots=%v"
,
subj
,
δrootsOK
,
δroots
)
}
if
!
δTEqual
(
δ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
var
vatδB
[]
zodb
.
Tid
// δbtail.vδBroots/treeRoot
for
_
,
δBroots
:=
range
δbtail
.
vδBroots
{
if
δBroots
.
Δ
Roots
.
Has
(
treeRoot
)
{
if
δBroots
.
Roots
.
Has
(
treeRoot
)
{
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
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
)
{
defer
xerr
.
Contextf
(
&
err
,
"file<%s>: rebuild"
,
foid
)
// XXX locking
if
δftail
.
vδE
!=
nil
{
panic
(
"rebuild: vδE != nil"
)
panic
(
"rebuild
1
: vδE != nil"
)
}
vδE
:=
[]
_ΔFileEpoch
{}
...
...
@@ -372,7 +372,6 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
}
headOld
:=
δFtail
.
Head
()
δB
,
err
:=
δFtail
.
δBtail
.
Update
(
δZ
)
if
err
!=
nil
{
return
ΔF
{},
err
...
...
@@ -418,8 +417,8 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
}
// take btree changes into account
//fmt.Printf("δB.
ΔByRoot: %v\n", δB.Δ
ByRoot)
for
root
,
δt
:=
range
δB
.
Δ
ByRoot
{
//fmt.Printf("δB.
ByRoot: %v\n", δB.
ByRoot)
for
root
,
δt
:=
range
δB
.
ByRoot
{
//fmt.Printf("root: %v δt: %v\n", root, δt)
files
:=
δFtail
.
filesByRoot
[
root
]
// 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