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
9e3260a7
Commit
9e3260a7
authored
Jan 25, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6dfc69dd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
7 deletions
+62
-7
go/zodb/δtail.go
go/zodb/δtail.go
+4
-4
go/zodb/δtail_test.go
go/zodb/δtail_test.go
+58
-3
No files found.
go/zodb/δtail.go
View file @
9e3260a7
...
@@ -30,7 +30,7 @@ import (
...
@@ -30,7 +30,7 @@ import (
//
//
// It semantically consists of
// It semantically consists of
//
//
// [](rev↑, []id) ; rev ∈
[
tail, head]
// [](rev↑, []id) ; rev ∈
(
tail, head]
//
//
// and index
// and index
//
//
...
@@ -96,10 +96,10 @@ func (δtail *ΔTail) Head() Tid {
...
@@ -96,10 +96,10 @@ func (δtail *ΔTail) Head() Tid {
// For newly created ΔTail Tail returns 0.
// For newly created ΔTail Tail returns 0.
// Tail is ↑, in particular it does not go back to 0 when δtail becomes empty.
// Tail is ↑, in particular it does not go back to 0 when δtail becomes empty.
func
(
δtail
*
ΔTail
)
Tail
()
Tid
{
func
(
δtail
*
ΔTail
)
Tail
()
Tid
{
if
len
(
δtail
.
tailv
)
>
0
{
if
len
(
δtail
.
tailv
)
==
0
{
return
δtail
.
tailv
[
0
]
.
rev
}
return
δtail
.
head
return
δtail
.
head
}
return
δtail
.
tailv
[
0
]
.
rev
-
1
}
}
// SliceByRev returns δtail slice with .rev ∈ (low, high].
// SliceByRev returns δtail slice with .rev ∈ (low, high].
...
...
go/zodb/δtail_test.go
View file @
9e3260a7
...
@@ -48,19 +48,74 @@ func TestΔTail(t *testing.T) {
...
@@ -48,19 +48,74 @@ func TestΔTail(t *testing.T) {
}
}
}
}
// XXX Len
// Len/Head/Tail
if
l
:=
δtail
.
Len
();
l
!=
len
(
tailv
)
{
t
.
Fatalf
(
"Len() -> %d ; want %d"
,
l
,
len
(
tailv
))
}
if
h
:=
δtail
.
Head
();
h
!=
head
{
if
h
:=
δtail
.
Head
();
h
!=
head
{
t
.
Fatalf
(
"Head() -> %s ; want %s"
,
h
,
head
)
t
.
Fatalf
(
"Head() -> %s ; want %s"
,
h
,
head
)
}
}
// XXX Tail
tail
:=
head
if
len
(
tailv
)
>
0
{
tail
=
tailv
[
0
]
.
rev
-
1
}
if
tt
:=
δtail
.
Tail
();
tt
!=
tail
{
t
.
Fatalf
(
"Tail() -> %s ; want %s"
,
tt
,
tail
)
}
if
!
tailvEqual
(
δtail
.
tailv
,
tailv
)
{
if
!
tailvEqual
(
δtail
.
tailv
,
tailv
)
{
t
.
Fatalf
(
"tailv:
\n
have: %v
\n
want: %v"
,
δtail
.
tailv
,
tailv
)
t
.
Fatalf
(
"tailv:
\n
have: %v
\n
want: %v"
,
δtail
.
tailv
,
tailv
)
}
}
// XXX verify SliceRevBy
// SliceByRev
// check that δtail.SliceByRev(rlo, rhi) == tailv[ilo:ihi].
sliceByRev
:=
func
(
rlo
,
rhi
Tid
,
ilo
,
ihi
int
)
{
t
.
Helper
()
have
:=
δtail
.
SliceByRev
(
rlo
,
rhi
)
want
:=
tailv
[
ilo
:
ihi
]
if
!
tailvEqual
(
have
,
want
)
{
t
.
Fatalf
(
"SliceByRev(%s, %s) -> %v ; want %v"
,
rlo
,
rhi
,
have
,
want
)
}
}
for
ilo
:=
0
;
ilo
<
len
(
tailv
);
ilo
++
{
for
ihi
:=
ilo
;
ihi
<
len
(
tailv
);
ihi
++
{
// (ilo, ihi) ?
if
ilo
+
1
<
len
(
tailv
)
{
sliceByRev
(
tailv
[
ilo
]
.
rev
,
tailv
[
ihi
]
.
rev
-
1
,
ilo
+
1
,
ihi
,
)
}
// (ilo, ihi]
if
ilo
+
1
<
len
(
tailv
)
{
sliceByRev
(
tailv
[
ilo
]
.
rev
,
tailv
[
ihi
]
.
rev
,
ilo
+
1
,
ihi
+
1
,
)
}
// [ilo, ihi)
sliceByRev
(
tailv
[
ilo
]
.
rev
-
1
,
tailv
[
ihi
]
.
rev
-
1
,
ilo
,
ihi
,
)
// [ilo, ihi]
sliceByRev
(
tailv
[
ilo
]
.
rev
-
1
,
tailv
[
ihi
]
.
rev
,
ilo
,
ihi
+
1
,
)
}
}
// verify lastRevOf query / index
// verify lastRevOf query / index
lastRevOf
:=
make
(
map
[
Oid
]
Tid
)
lastRevOf
:=
make
(
map
[
Oid
]
Tid
)
...
...
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