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
44b252e6
Commit
44b252e6
authored
Jan 25, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
9e3260a7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
go/zodb/δtail.go
go/zodb/δtail.go
+10
-4
go/zodb/δtail_test.go
go/zodb/δtail_test.go
+3
-1
No files found.
go/zodb/δtail.go
View file @
44b252e6
...
...
@@ -115,7 +115,7 @@ func (δtail *ΔTail) SliceByRev(low, high Tid) /*readonly*/ []δRevEntry {
tail
:=
δtail
.
Tail
()
head
:=
δtail
.
head
if
!
(
tail
<=
low
&&
low
<=
high
&&
high
<=
head
)
{
panic
(
fmt
.
Sprintf
(
"δtail.Slice:
(%s, %s] invalid; tail..head = %s..%s
"
,
low
,
high
,
tail
,
head
))
panic
(
fmt
.
Sprintf
(
"δtail.Slice:
invalid query: (%s, %s]; (tail, head] = (%s, %s]
"
,
low
,
high
,
tail
,
head
))
}
tailv
:=
δtail
.
tailv
...
...
@@ -125,16 +125,22 @@ func (δtail *ΔTail) SliceByRev(low, high Tid) /*readonly*/ []δRevEntry {
return
tailv
}
// find max j : [j].rev
<=
high XXX linear scan
// find max j : [j].rev
≤
high XXX linear scan
j
:=
len
(
tailv
)
-
1
for
;
tailv
[
j
]
.
rev
>
high
;
j
--
{}
for
;
j
>=
0
&&
tailv
[
j
]
.
rev
>
high
;
j
--
{}
if
j
<
0
{
return
nil
// ø
}
//fmt.Printf("j: %d\n", j)
// find max i : [i].rev > low XXX linear scan
i
:=
j
for
;
i
>=
0
&&
tailv
[
i
]
.
rev
>
low
;
i
--
{}
// XXX i < 0
i
++
return
tailv
[
i
:
j
]
return
tailv
[
i
:
j
+
1
]
}
// XXX add way to extend coverage without appending changed data? (i.e. if a
...
...
go/zodb/δtail_test.go
View file @
44b252e6
...
...
@@ -71,9 +71,11 @@ func TestΔTail(t *testing.T) {
// SliceByRev
fmt
.
Printf
(
"
\n
whole: (%s, %s] %v
\n
"
,
δtail
.
Tail
(),
δtail
.
Head
(),
tailv
)
// check that δtail.SliceByRev(rlo, rhi) == tailv[ilo:ihi].
sliceByRev
:=
func
(
rlo
,
rhi
Tid
,
ilo
,
ihi
int
)
{
t
.
Helper
()
fmt
.
Printf
(
"(%s, %s] -> [%d:%d)
\n
"
,
rlo
,
rhi
,
ilo
,
ihi
)
have
:=
δtail
.
SliceByRev
(
rlo
,
rhi
)
want
:=
tailv
[
ilo
:
ihi
]
if
!
tailvEqual
(
have
,
want
)
{
...
...
@@ -84,7 +86,7 @@ func TestΔTail(t *testing.T) {
for
ilo
:=
0
;
ilo
<
len
(
tailv
);
ilo
++
{
for
ihi
:=
ilo
;
ihi
<
len
(
tailv
);
ihi
++
{
// (ilo, ihi) ?
if
ilo
+
1
<
len
(
tailv
)
{
if
ilo
+
1
<
len
(
tailv
)
&&
ilo
+
1
<=
ihi
{
sliceByRev
(
tailv
[
ilo
]
.
rev
,
tailv
[
ihi
]
.
rev
-
1
,
...
...
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