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
9eef8bdd
Commit
9eef8bdd
authored
Jul 15, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6b2c1d79
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
19 deletions
+28
-19
wcfs/internal/zdata/δftail_test.go
wcfs/internal/zdata/δftail_test.go
+28
-19
No files found.
wcfs/internal/zdata/δftail_test.go
View file @
9eef8bdd
...
@@ -177,7 +177,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
...
@@ -177,7 +177,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
t
:=
xbtreetest
.
NewT
(
t_
)
t
:=
xbtreetest
.
NewT
(
t_
)
X
:=
exc
.
Raiseif
X
:=
exc
.
Raiseif
δ
f
tail
:=
NewΔFtail
(
t
.
Head
()
.
At
,
t
.
DB
)
δ
F
tail
:=
NewΔFtail
(
t
.
Head
()
.
At
,
t
.
DB
)
// load zfile via root['treegen/file']
// load zfile via root['treegen/file']
txn
,
ctx
:=
transaction
.
New
(
context
.
Background
())
txn
,
ctx
:=
transaction
.
New
(
context
.
Background
())
...
@@ -198,7 +198,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
...
@@ -198,7 +198,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
// track zfile[-∞,∞) from the beginning
// track zfile[-∞,∞) from the beginning
// this should make ΔFtail to see all zfile changes
// this should make ΔFtail to see all zfile changes
size
,
path
,
err
:=
zfile
.
Size
(
ctx
);
X
(
err
)
size
,
path
,
err
:=
zfile
.
Size
(
ctx
);
X
(
err
)
δ
f
tail
.
Track
(
zfile
,
/*blk*/
-
1
,
path
,
/*zblk*/
nil
)
δ
F
tail
.
Track
(
zfile
,
/*blk*/
-
1
,
path
,
/*zblk*/
nil
)
if
size
!=
0
{
if
size
!=
0
{
t
.
Fatalf
(
"BUG: zfile is not initially empty: size=%d"
,
size
)
t
.
Fatalf
(
"BUG: zfile is not initially empty: size=%d"
,
size
)
}
}
...
@@ -216,8 +216,18 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
...
@@ -216,8 +216,18 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
}
}
xat
:=
map
[
zodb
.
Tid
]
string
{}
// tid > "at<i>"
xat
:=
map
[
zodb
.
Tid
]
string
{}
// tid > "at<i>"
xat
[
δftail
.
Head
()]
=
"at0"
xat
[
δFtail
.
Head
()]
=
"at0"
t
.
Logf
(
"# @at0 (%s)"
,
δftail
.
Head
())
t
.
Logf
(
"# @at0 (%s)"
,
δFtail
.
Head
())
// vector of epochs and func to create a new one
epochv
:=
[]
zodb
.
Tid
{
0
}
onNewEpoch
:=
func
(
epoch
zodb
.
Tid
)
{
epochv
=
append
(
epochv
,
epoch
)
for
blk
:=
range
blkTab
{
_
,
path
,
zblk
,
_
,
err
:=
zfile
.
LoadBlk
(
ctx
,
blk
);
X
(
err
)
δFtail
.
Track
(
zfile
,
blk
,
path
,
zblk
)
}
}
// δfstr/vδfstr converts δf/vδf to string taking xat into account
// δfstr/vδfstr converts δf/vδf to string taking xat into account
δfstr
:=
func
(
δf
*
ΔFile
)
string
{
δfstr
:=
func
(
δf
*
ΔFile
)
string
{
...
@@ -241,7 +251,6 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
...
@@ -241,7 +251,6 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
i
:=
0
i
:=
0
delfilePrev
:=
false
delfilePrev
:=
false
epochv
:=
[]
zodb
.
Tid
{
0
}
for
test
:=
range
testq
{
for
test
:=
range
testq
{
i
++
i
++
δblk
:=
setI64
{}
δblk
:=
setI64
{}
...
@@ -316,14 +325,11 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
...
@@ -316,14 +325,11 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
req
=
tTxt
+
" "
+
dTxt
req
=
tTxt
+
" "
+
dTxt
}
}
commit
:=
t
.
CommitTree
(
req
)
commit
:=
t
.
CommitTree
(
req
)
if
newEpoch
{
epochv
=
append
(
epochv
,
commit
.
At
)
}
// update blkRevAt
// update blkRevAt
var
blkRevPrev
map
[
int64
]
zodb
.
Tid
var
blkRevPrev
map
[
int64
]
zodb
.
Tid
if
i
!=
0
{
if
i
!=
0
{
blkRevPrev
=
blkRevAt
[
δ
f
tail
.
Head
()]
blkRevPrev
=
blkRevAt
[
δ
F
tail
.
Head
()]
}
}
blkRev
:=
map
[
int64
]
zodb
.
Tid
{}
blkRev
:=
map
[
int64
]
zodb
.
Tid
{}
for
blk
,
rev
:=
range
blkRevPrev
{
for
blk
,
rev
:=
range
blkRevPrev
{
...
@@ -361,8 +367,11 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
...
@@ -361,8 +367,11 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
//fmt.Printf("Zinblk: %v\n", Zinblk)
//fmt.Printf("Zinblk: %v\n", Zinblk)
// update δftail
// update δFtail
δF
,
err
:=
δftail
.
Update
(
commit
.
ΔZ
);
X
(
err
)
δF
,
err
:=
δFtail
.
Update
(
commit
.
ΔZ
);
X
(
err
)
if
newEpoch
{
onNewEpoch
(
commit
.
At
)
}
// assert δF points to the file if δfok != ø
// assert δF points to the file if δfok != ø
if
δF
.
Rev
!=
commit
.
At
{
if
δF
.
Rev
!=
commit
.
At
{
...
@@ -387,9 +396,9 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
...
@@ -387,9 +396,9 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
t
.
Errorf
(
"δf:
\n
have: %v
\n
want: %v"
,
δf
,
δfok
)
t
.
Errorf
(
"δf:
\n
have: %v
\n
want: %v"
,
δf
,
δfok
)
}
}
// verify δ
f
tail.trackSetZBlk
// verify δ
F
tail.trackSetZBlk
trackZinblk
:=
map
[
string
]
setI64
{}
trackZinblk
:=
map
[
string
]
setI64
{}
for
oid
,
zt
:=
range
δ
f
tail
.
trackSetZBlk
{
for
oid
,
zt
:=
range
δ
F
tail
.
trackSetZBlk
{
zblki
:=
commit
.
ZBlkTab
[
oid
]
zblki
:=
commit
.
ZBlkTab
[
oid
]
for
root
,
blocks
:=
range
zt
.
inroot
{
for
root
,
blocks
:=
range
zt
.
inroot
{
if
root
!=
blktabOid
{
if
root
!=
blktabOid
{
...
@@ -414,10 +423,10 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
...
@@ -414,10 +423,10 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
if
len
(
vδf
)
>=
ncut
{
if
len
(
vδf
)
>=
ncut
{
revcut
:=
vδf
[
0
]
.
Rev
revcut
:=
vδf
[
0
]
.
Rev
t
.
Logf
(
"# forget ≤ @%s"
,
xat
[
revcut
])
t
.
Logf
(
"# forget ≤ @%s"
,
xat
[
revcut
])
δ
f
tail
.
ForgetPast
(
revcut
)
δ
F
tail
.
ForgetPast
(
revcut
)
vδf
=
vδf
[
1
:
]
vδf
=
vδf
[
1
:
]
//t.Logf("# vδf: %s", vδfstr(vδf))
//t.Logf("# vδf: %s", vδfstr(vδf))
//t.Logf("# vδt: %s", vδfstr(δ
ftail.SliceByFileRev(zfile, δftail.Tail(), δf
tail.Head())))
//t.Logf("# vδt: %s", vδfstr(δ
Ftail.SliceByFileRev(zfile, δFtail.Tail(), δF
tail.Head())))
}
}
// SliceByFileRev
// SliceByFileRev
...
@@ -432,7 +441,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
...
@@ -432,7 +441,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
hi
:=
vδf
[
k
]
.
Rev
hi
:=
vδf
[
k
]
.
Rev
vδf_ok
:=
vδf
[
j
:
k
+
1
]
// [j,k]
vδf_ok
:=
vδf
[
j
:
k
+
1
]
// [j,k]
vδf_
:=
δ
f
tail
.
SliceByFileRev
(
zfile
,
lo
,
hi
)
vδf_
:=
δ
F
tail
.
SliceByFileRev
(
zfile
,
lo
,
hi
)
if
!
reflect
.
DeepEqual
(
vδf_
,
vδf_ok
)
{
if
!
reflect
.
DeepEqual
(
vδf_
,
vδf_ok
)
{
t
.
Errorf
(
"slice (@%s,@%s]:
\n
have: %v
\n
want: %v"
,
xat
[
lo
],
xat
[
hi
],
vδfstr
(
vδf_
),
vδfstr
(
vδf_ok
))
t
.
Errorf
(
"slice (@%s,@%s]:
\n
have: %v
\n
want: %v"
,
xat
[
lo
],
xat
[
hi
],
vδfstr
(
vδf_
),
vδfstr
(
vδf_ok
))
}
}
...
@@ -457,7 +466,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
...
@@ -457,7 +466,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
at
:=
vδf
[
j
]
.
Rev
at
:=
vδf
[
j
]
.
Rev
blkRev
:=
blkRevAt
[
at
]
blkRev
:=
blkRevAt
[
at
]
for
_
,
blk
:=
range
blkv
{
for
_
,
blk
:=
range
blkv
{
rev
,
exact
:=
δ
f
tail
.
LastBlkRev
(
ctx
,
zfile
,
blk
,
at
)
rev
,
exact
:=
δ
F
tail
.
LastBlkRev
(
ctx
,
zfile
,
blk
,
at
)
revOK
,
ok
:=
blkRev
[
blk
]
revOK
,
ok
:=
blkRev
[
blk
]
if
!
ok
{
if
!
ok
{
k
:=
len
(
epochv
)
-
1
k
:=
len
(
epochv
)
-
1
...
@@ -469,8 +478,8 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
...
@@ -469,8 +478,8 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
revOK
=
epochv
[
k
]
revOK
=
epochv
[
k
]
}
}
exactOK
:=
true
exactOK
:=
true
if
revOK
<=
δ
f
tail
.
Tail
()
{
if
revOK
<=
δ
F
tail
.
Tail
()
{
revOK
,
exactOK
=
δ
f
tail
.
Tail
(),
false
revOK
,
exactOK
=
δ
F
tail
.
Tail
(),
false
}
}
if
!
(
rev
==
revOK
&&
exact
==
exactOK
)
{
if
!
(
rev
==
revOK
&&
exact
==
exactOK
)
{
t
.
Errorf
(
"blkrev #%d @%s:
\n
have: @%s, %v
\n
want: @%s, %v"
,
blk
,
xat
[
at
],
xat
[
rev
],
exact
,
xat
[
revOK
],
exactOK
)
t
.
Errorf
(
"blkrev #%d @%s:
\n
have: @%s, %v
\n
want: @%s, %v"
,
blk
,
xat
[
at
],
xat
[
rev
],
exact
,
xat
[
revOK
],
exactOK
)
...
...
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