Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
73bc026b
Commit
73bc026b
authored
Jan 24, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d1f63f32
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
21 deletions
+36
-21
go/zodb/δtail.go
go/zodb/δtail.go
+4
-2
go/zodb/δtail_test.go
go/zodb/δtail_test.go
+32
-19
No files found.
go/zodb/δtail.go
View file @
73bc026b
...
...
@@ -82,6 +82,8 @@ func (δtail *ΔTail) Head() Tid {
return
δtail
.
head
}
// XXX + Tail?
// XXX add way to extend coverage without appending changed data? (i.e. if a
// txn did not change file at all) -> but then it is simply .Append(rev, nil)?
...
...
@@ -139,14 +141,14 @@ func (δtail *ΔTail) ForgetBefore(revCut Tid) {
// LastRevOf(id, at) = at
//
// 2) if δtail has an entry corresponding to id change, it gives exactly the
//
last revision that changed id:
// last revision that changed id:
//
// # at ∈ [min(rev ∈ δtail), max(rev ∈ δtail)]
// # ∃ rev ∈ δtail: rev changed id && rev ≤ at
// LastRevOf(id, at) = max(rev: rev changed id && rev ≤ at)
//
// 3) if δtail does not contain appropriate record with id - it returns δtail's
//
lower bound as the estimate for the upper bound of the last id revision:
// lower bound as the estimate for the upper bound of the last id revision:
//
// # at ∈ [min(rev ∈ δtail), max(rev ∈ δtail)]
// # ∄ rev ∈ δtail: rev changed id && rev ≤ at
...
...
go/zodb/δtail_test.go
View file @
73bc026b
...
...
@@ -25,8 +25,6 @@ import (
"testing"
)
// XXX test Head
func
TestΔTail
(
t
*
testing
.
T
)
{
δtail
:=
NewΔTail
()
...
...
@@ -41,7 +39,7 @@ func TestΔTail(t *testing.T) {
}
// δCheck verifies that δtail state corresponds to provided tailv
δCheck
:=
func
(
tailv
...
δRevEntry
)
{
δCheck
:=
func
(
head
Tid
,
tailv
...
δRevEntry
)
{
t
.
Helper
()
for
i
:=
1
;
i
<
len
(
tailv
);
i
++
{
...
...
@@ -50,6 +48,10 @@ func TestΔTail(t *testing.T) {
}
}
if
h
:=
δtail
.
Head
();
h
!=
head
{
t
.
Fatalf
(
"Head() -> %s ; want %s"
,
h
,
head
)
}
if
!
tailvEqual
(
δtail
.
tailv
,
tailv
)
{
t
.
Fatalf
(
"tailv:
\n
have: %v
\n
want: %v"
,
δtail
.
tailv
,
tailv
)
}
...
...
@@ -85,56 +87,67 @@ func TestΔTail(t *testing.T) {
}
δCheck
()
δCheck
(
0
)
δCheckLastUP
(
4
,
12
,
12
)
// δtail = ø
δAppend
(
R
(
10
,
3
,
5
))
δCheck
(
R
(
10
,
3
,
5
))
δCheck
(
10
,
R
(
10
,
3
,
5
))
δCheckLastUP
(
3
,
9
,
9
)
// at < δtail
δCheckLastUP
(
3
,
12
,
12
)
// at > δtail
δCheckLastUP
(
4
,
10
,
10
)
// id ∉ δtail
δAppend
(
R
(
11
,
7
))
δCheck
(
R
(
10
,
3
,
5
),
R
(
11
,
7
))
δCheck
(
11
,
R
(
10
,
3
,
5
),
R
(
11
,
7
))
δAppend
(
R
(
12
,
7
))
δCheck
(
R
(
10
,
3
,
5
),
R
(
11
,
7
),
R
(
12
,
7
))
δCheck
(
12
,
R
(
10
,
3
,
5
),
R
(
11
,
7
),
R
(
12
,
7
))
δAppend
(
R
(
14
,
3
,
8
))
δCheck
(
R
(
10
,
3
,
5
),
R
(
11
,
7
),
R
(
12
,
7
),
R
(
14
,
3
,
8
))
δCheck
(
14
,
R
(
10
,
3
,
5
),
R
(
11
,
7
),
R
(
12
,
7
),
R
(
14
,
3
,
8
))
δCheckLastUP
(
8
,
12
,
10
)
// id ∈ δtail, but has no entry with rev ≤ at
δtail
.
ForgetBefore
(
10
)
δCheck
(
R
(
10
,
3
,
5
),
R
(
11
,
7
),
R
(
12
,
7
),
R
(
14
,
3
,
8
))
δCheck
(
14
,
R
(
10
,
3
,
5
),
R
(
11
,
7
),
R
(
12
,
7
),
R
(
14
,
3
,
8
))
δtail
.
ForgetBefore
(
11
)
δCheck
(
R
(
11
,
7
),
R
(
12
,
7
),
R
(
14
,
3
,
8
))
δCheck
(
14
,
R
(
11
,
7
),
R
(
12
,
7
),
R
(
14
,
3
,
8
))
δtail
.
ForgetBefore
(
13
)
δCheck
(
R
(
14
,
3
,
8
))
δCheck
(
14
,
R
(
14
,
3
,
8
))
δtail
.
ForgetBefore
(
15
)
δCheck
()
δCheck
(
14
)
// Append panics on non-↑ rev
δAppend
(
R
(
15
,
1
))
func
()
{
// δAppendPanic verifies that Append(δ.rev = rev) panics.
δAppendPanic
:=
func
(
rev
Tid
)
{
defer
func
()
{
r
:=
recover
()
if
r
==
nil
{
t
.
Fatal
(
"append non-↑: not panicked"
)
t
.
Fatal
f
(
"append(rev=%s) non-↑: not panicked"
,
rev
)
}
rev
:=
Tid
(
15
)
want
:=
fmt
.
Sprintf
(
"δtail.Append: rev not ↑: %s -> %s"
,
rev
,
rev
)
want
:=
fmt
.
Sprintf
(
"δtail.Append: rev not ↑: %s -> %s"
,
δtail
.
head
,
rev
)
if
r
!=
want
{
t
.
Fatalf
(
"append non-↑:
\n
have: %q
\n
want: %q"
,
r
,
want
)
}
}()
δAppend
(
R
(
15
,
1
))
}()
δAppend
(
R
(
rev
))
}
// on empty δtail
δAppendPanic
(
14
)
δAppendPanic
(
13
)
δAppendPanic
(
12
)
// on !empty δtail
δAppend
(
R
(
15
,
1
))
δCheck
(
15
,
R
(
15
,
1
))
δAppendPanic
(
15
)
δAppendPanic
(
14
)
// .tailv underlying storage is not kept after forget
...
...
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