Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
8b62f868
Commit
8b62f868
authored
Jan 25, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
44b252e6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
22 deletions
+40
-22
go/zodb/δtail.go
go/zodb/δtail.go
+0
-3
go/zodb/δtail_test.go
go/zodb/δtail_test.go
+40
-19
No files found.
go/zodb/δtail.go
View file @
8b62f868
...
...
@@ -132,12 +132,9 @@ func (δtail *ΔTail) SliceByRev(low, high Tid) /*readonly*/ []δRevEntry {
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
+
1
]
...
...
go/zodb/δtail_test.go
View file @
8b62f868
...
...
@@ -72,7 +72,7 @@ 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
]
.
// 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
)
...
...
@@ -81,28 +81,31 @@ func TestΔTail(t *testing.T) {
if
!
tailvEqual
(
have
,
want
)
{
t
.
Fatalf
(
"SliceByRev(%s, %s) -> %v ; want %v"
,
rlo
,
rhi
,
have
,
want
)
}
if
len
(
have
)
==
0
{
return
}
// make sure returned region is indeed correct
tbefore
:=
Tid
(
0
)
if
ilo
-
1
>=
0
{
tbefore
=
tailv
[
ilo
-
1
]
.
rev
-
1
}
tail
:=
tailv
[
ilo
]
.
rev
-
1
head
:=
tailv
[
ihi
-
1
]
.
rev
hafter
:=
TidMax
if
ihi
<
len
(
tailv
)
{
hafter
=
tailv
[
ihi
]
.
rev
}
if
!
(
tbefore
<
rlo
&&
rlo
<=
tail
&&
head
<=
rhi
&&
rhi
<
hafter
)
{
t
.
Fatalf
(
"SliceByRev(%s, %s) -> %v ; edges do not match query:
\n
"
+
"%s (%s, %s] %s"
,
rlo
,
rhi
,
have
,
tbefore
,
tail
,
head
,
hafter
)
}
}
for
ilo
:=
0
;
ilo
<
len
(
tailv
);
ilo
++
{
for
ihi
:=
ilo
;
ihi
<
len
(
tailv
);
ihi
++
{
// (ilo, ihi) ?
if
ilo
+
1
<
len
(
tailv
)
&&
ilo
+
1
<=
ihi
{
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
,
...
...
@@ -116,6 +119,24 @@ func TestΔTail(t *testing.T) {
tailv
[
ihi
]
.
rev
,
ilo
,
ihi
+
1
,
)
// (ilo, ihi]
if
ilo
+
1
<
len
(
tailv
)
{
sliceByRev
(
tailv
[
ilo
]
.
rev
,
tailv
[
ihi
]
.
rev
,
ilo
+
1
,
ihi
+
1
,
)
}
// (ilo, ihi)
if
ilo
+
1
<
len
(
tailv
)
&&
ilo
+
1
<=
ihi
{
sliceByRev
(
tailv
[
ilo
]
.
rev
,
tailv
[
ihi
]
.
rev
-
1
,
ilo
+
1
,
ihi
,
)
}
}
}
...
...
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