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
7a16fc66
Commit
7a16fc66
authored
Jul 16, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6672e880
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
25 deletions
+58
-25
wcfs/internal/zdata/δftail.go
wcfs/internal/zdata/δftail.go
+37
-24
wcfs/internal/zdata/δftail_test.go
wcfs/internal/zdata/δftail_test.go
+21
-1
No files found.
wcfs/internal/zdata/δftail.go
View file @
7a16fc66
...
...
@@ -237,6 +237,43 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
δF
:=
ΔF
{
Rev
:
δB
.
Rev
,
ByFile
:
make
(
map
[
zodb
.
Oid
]
*
ΔFile
)}
// take ZBigFile changes into account
δzfile
:=
map
[
zodb
.
Oid
]
*
_ΔZBigFile
{}
// which tracked ZBigFiles are changed
for
_
,
oid
:=
range
δZ
.
Changev
{
δftail
,
ok
:=
δFtail
.
byFile
[
oid
]
if
!
ok
{
continue
// not ZBigFile or file is not tracked
}
δ
,
err
:=
zfilediff
(
δFtail
.
δBtail
.
DB
(),
oid
,
headOld
,
δZ
.
Tid
)
if
err
!=
nil
{
return
ΔF
{},
err
}
//fmt.Printf("zfile<%s> diff %s..%s -> δ: %v\n", oid, headOld, δZ.Tid, δ)
if
δ
!=
nil
{
// XXX rebuild first
δzfile
[
oid
]
=
δ
δE
:=
_ΔFileEpoch
{
Rev
:
δZ
.
Tid
,
oldRoot
:
δ
.
blktabOld
,
newRoot
:
δ
.
blktabNew
,
newBlkSize
:
δ
.
blksizeNew
,
oldTrackSetZBlk
:
map
[
zodb
.
Oid
]
setI64
{},
}
for
oid
,
zt
:=
range
δFtail
.
trackSetZBlk
{
inblk
,
ok
:=
zt
.
inroot
[
δftail
.
root
]
if
ok
{
δE
.
oldTrackSetZBlk
[
oid
]
=
inblk
delete
(
zt
.
inroot
,
δftail
.
root
)
}
}
δftail
.
root
=
δE
.
newRoot
δftail
.
vδE
=
append
(
δftail
.
vδE
,
δE
)
}
}
// take btree changes into account
// fmt.Printf("δB.ΔByRoot: %v\n", δB.ΔByRoot)
for
root
,
δt
:=
range
δB
.
ΔByRoot
{
...
...
@@ -295,30 +332,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
}
// take zblk changes into account
δzfile
:=
map
[
zodb
.
Oid
]
*
_ΔZBigFile
{}
// which tracked ZBigFiles are changed
for
_
,
oid
:=
range
δZ
.
Changev
{
δftail
,
ok
:=
δFtail
.
byFile
[
oid
]
if
ok
{
δ
,
err
:=
zfilediff
(
δFtail
.
δBtail
.
DB
(),
oid
,
headOld
,
δZ
.
Tid
)
if
err
!=
nil
{
return
ΔF
{},
err
}
//fmt.Printf("zfile<%s> diff %s..%s -> δ: %v\n", oid, headOld, δZ.Tid, δ)
if
δ
!=
nil
{
// XXX rebuild first
δzfile
[
oid
]
=
δ
δftail
.
vδE
=
append
(
δftail
.
vδE
,
_ΔFileEpoch
{
Rev
:
δZ
.
Tid
,
oldRoot
:
δ
.
blktabOld
,
newRoot
:
δ
.
blktabNew
,
newBlkSize
:
δ
.
blksizeNew
,
})
}
continue
}
zt
,
ok
:=
δFtail
.
trackSetZBlk
[
oid
]
if
!
ok
{
continue
// not tracked
...
...
@@ -359,7 +373,6 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
//fmt.Printf("δZBigFile: %v\n", δ)
// XXX update .fileIdx
// XXX update .trackSetZBlk ?
}
// fmt.Printf("-> δF: %v\n", δF)
...
...
wcfs/internal/zdata/δftail_test.go
View file @
7a16fc66
...
...
@@ -272,6 +272,11 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
newEpoch
:=
delfile
||
(
!
delfile
&&
delfile
!=
delfilePrev
)
delfilePrev
=
delfile
ZinblkPrev
:=
map
[
string
]
setI64
{}
for
zblk
,
inblk
:=
range
Zinblk
{
ZinblkPrev
[
zblk
]
=
inblk
.
Clone
()
}
// newEpoch -> reset
if
newEpoch
{
blkTab
=
map
[
int64
]
string
{}
...
...
@@ -403,6 +408,12 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
δE
.
newBlkSize
=
blksize
// XXX oldBlkSize ?
}
oldTrackSetZBlk
:=
map
[
zodb
.
Oid
]
setI64
{}
for
zblk
,
inblk
:=
range
ZinblkPrev
{
oid
,
_
:=
commit
.
XGetBlkByName
(
zblk
)
oldTrackSetZBlk
[
oid
]
=
inblk
}
δE
.
oldTrackSetZBlk
=
oldTrackSetZBlk
vδE
=
append
(
vδE
,
δE
)
}
...
...
@@ -479,8 +490,17 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
vδE
=
vδE
[
icut
:
]
}
// verify
vδE
// verify
δftail.root
δftail
:=
δFtail
.
byFile
[
foid
]
rootOK
:=
blktabOid
if
delfile
{
rootOK
=
zodb
.
InvalidOid
}
if
δftail
.
root
!=
rootOK
{
t
.
Errorf
(
".root: have %s ; want %s"
,
δftail
.
root
,
rootOK
)
}
// verify vδE
if
!
reflect
.
DeepEqual
(
δftail
.
vδE
,
vδE
)
{
t
.
Errorf
(
"vδE:
\n
have: %v
\n
want: %v"
,
δftail
.
vδE
,
vδE
)
}
...
...
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