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
6b40eab4
Commit
6b40eab4
authored
Jan 25, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
87e754cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
16 deletions
+14
-16
go/zodb/δtail.go
go/zodb/δtail.go
+14
-16
No files found.
go/zodb/δtail.go
View file @
6b40eab4
...
...
@@ -38,17 +38,17 @@ import (
//
// where
//
// rev - is ZODB revision,
and
// id - is an identifier of what has been changed(*)
//
[
tail, head] - is covered revision range
// rev - is ZODB revision,
// id - is an identifier of what has been changed(*)
, and
//
(
tail, head] - is covered revision range
//
// It provides operations to
//
// - append information to the tail about next revision,
// - forget information in the tail past specified revision,
and
// - query the tail for
len, head and tail.
// - query the tail
for slice with rev ∈ (lo, hi].
// - query the tail
about what is last revision that changed an id
.
// - forget information in the tail past specified revision,
// - query the tail for
slice with rev ∈ (lo, hi],
// - query the tail
about what is last revision that changed an id,
// - query the tail
for len and (tail, head]
.
//
// ΔTail is safe to access for multiple-readers / single writer.
//
...
...
@@ -61,13 +61,11 @@ type ΔTail struct {
tailv
[]
δRevEntry
lastRevOf
map
[
Oid
]
Tid
// index for LastRevOf queries
// TODO also add either tailv idx <-> rev index, or lastRevOf -> tailv idx
// (if linear back-scan of δRevEntry starts to eat cpu).
}
// δRevEntry represents information of what have been changed in one revision.
//
// XXX -> CommitEvent?
// XXX -> CommitEvent?
-> ΔRevEntry?
type
δRevEntry
struct
{
rev
Tid
changev
[]
Oid
...
...
@@ -78,7 +76,7 @@ func NewΔTail() *ΔTail {
return
&
ΔTail
{
lastRevOf
:
make
(
map
[
Oid
]
Tid
)}
}
// Len returns number of
element
s.
// Len returns number of
revision
s.
func
(
δtail
*
ΔTail
)
Len
()
int
{
return
len
(
δtail
.
tailv
)
}
...
...
@@ -102,7 +100,7 @@ func (δtail *ΔTail) Tail() Tid {
return
δtail
.
tailv
[
0
]
.
rev
-
1
}
// SliceByRev returns δtail slice with .rev ∈ (low, high].
// SliceByRev returns δtail slice
of elements
with .rev ∈ (low, high].
//
// it must be called with the following condition:
//
...
...
@@ -110,7 +108,7 @@ func (δtail *ΔTail) Tail() Tid {
//
// the caller must not modify returned slice.
//
// Note: contrary to regular go slicing, low is excl
i
sive while high is inclusive.
// Note: contrary to regular go slicing, low is excl
u
sive while high is inclusive.
func
(
δtail
*
ΔTail
)
SliceByRev
(
low
,
high
Tid
)
/*readonly*/
[]
δRevEntry
{
tail
:=
δtail
.
Tail
()
head
:=
δtail
.
head
...
...
@@ -125,14 +123,14 @@ 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
-> binary search
j
:=
len
(
tailv
)
-
1
for
;
j
>=
0
&&
tailv
[
j
]
.
rev
>
high
;
j
--
{}
if
j
<
0
{
return
nil
// ø
}
// find max i : [i].rev > low XXX linear scan
// find max i : [i].rev > low XXX linear scan
-> binary search
i
:=
j
for
;
i
>=
0
&&
tailv
[
i
]
.
rev
>
low
;
i
--
{}
i
++
...
...
@@ -235,7 +233,7 @@ func (δtail *ΔTail) LastRevOf(id Oid, at Tid) (_ Tid, exact bool) {
}
// what's in index is after at - scan tailv back to find appropriate entry
// XXX linear scan
// XXX linear scan
- fix it by: .lastRevOf = {} oid -> []rev↑
for
i
:=
l
-
1
;
i
>=
0
;
i
--
{
δ
:=
δtail
.
tailv
[
i
]
if
δ
.
rev
>
at
{
...
...
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