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
d1f63f32
Commit
d1f63f32
authored
Jan 24, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3597e916
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
14 deletions
+20
-14
go/zodb/db.go
go/zodb/db.go
+6
-2
go/zodb/δtail.go
go/zodb/δtail.go
+14
-12
No files found.
go/zodb/db.go
View file @
d1f63f32
...
@@ -52,7 +52,7 @@ type DB struct {
...
@@ -52,7 +52,7 @@ type DB struct {
// δtail of database changes for invalidations
// δtail of database changes for invalidations
// min(rev) = min(conn.at) for all conn ∈ db (opened and in the pool)
// min(rev) = min(conn.at) for all conn ∈ db (opened and in the pool)
δtail
ΔTail
// [](rev↑, []oid)
δtail
*
ΔTail
// [](rev↑, []oid)
// openers waiting for δtail.Head to become covering their at.
// openers waiting for δtail.Head to become covering their at.
δwait
map
[
δwaiter
]
struct
{}
// set{(at, ready)} XXX -> set_δwaiter?
δwait
map
[
δwaiter
]
struct
{}
// set{(at, ready)} XXX -> set_δwaiter?
...
@@ -69,7 +69,11 @@ type δwaiter struct {
...
@@ -69,7 +69,11 @@ type δwaiter struct {
// NewDB creates new database handle.
// NewDB creates new database handle.
func
NewDB
(
stor
IStorage
)
*
DB
{
func
NewDB
(
stor
IStorage
)
*
DB
{
// XXX db options?
// XXX db options?
db
:=
&
DB
{
stor
:
stor
}
db
:=
&
DB
{
stor
:
stor
,
δtail
:
NewΔTail
(),
δwait
:
make
(
map
[
δwaiter
]
struct
{}),
}
watchq
:=
make
(
chan
CommitEvent
)
watchq
:=
make
(
chan
CommitEvent
)
stor
.
AddWatch
(
watchq
)
stor
.
AddWatch
(
watchq
)
// XXX DelWatch? in db.Close() ?
// XXX DelWatch? in db.Close() ?
...
...
go/zodb/δtail.go
View file @
d1f63f32
...
@@ -19,18 +19,18 @@
...
@@ -19,18 +19,18 @@
package
zodb
package
zodb
// XXX do we really need ΔTail to be exported from zodb?
// (other users are low level caches + maybe ZEO/NEO -> zplumbing? but then import cycle)
import
(
import
(
"fmt"
"fmt"
)
)
// XXX do we really need ΔTail to be exported from zodb?
// (other users are low level caches + maybe ZEO/NEO -> zplumbing? but then import cycle)
// ΔTail represents tail of revisional changes.
// ΔTail represents tail of revisional changes.
//
//
// It semantically consists of
// It semantically consists of
//
//
// [](rev↑, []id)
// [](rev↑, []id)
XXX + head?
//
//
// and index
// and index
//
//
...
@@ -43,10 +43,10 @@ import (
...
@@ -43,10 +43,10 @@ import (
//
//
// It provides operations to
// It provides operations to
//
//
// - XXX Head
// - append information to the tail about next revision,
// - append information to the tail about next revision,
// - forget information in the tail past specified revision, and
// - forget information in the tail past specified revision, and
// - query the tail about what is last revision that changed an id.
// - query the tail about what is last revision that changed an id.
// - query the tail about what head/tail XXX?
//
//
// ΔTail is safe to access for multiple-readers / single writer.
// ΔTail is safe to access for multiple-readers / single writer.
//
//
...
@@ -55,6 +55,7 @@ import (
...
@@ -55,6 +55,7 @@ import (
// oid - ZODB object identifier, when ΔTail represents changes to ZODB objects,
// oid - ZODB object identifier, when ΔTail represents changes to ZODB objects,
// #blk - file block number, when ΔTail represents changes to a file.
// #blk - file block number, when ΔTail represents changes to a file.
type
ΔTail
struct
{
type
ΔTail
struct
{
head
Tid
tailv
[]
δRevEntry
tailv
[]
δRevEntry
lastRevOf
map
[
Oid
]
Tid
// index for LastRevOf queries
lastRevOf
map
[
Oid
]
Tid
// index for LastRevOf queries
...
@@ -73,9 +74,12 @@ func NewΔTail() *ΔTail {
...
@@ -73,9 +74,12 @@ func NewΔTail() *ΔTail {
return
&
ΔTail
{
lastRevOf
:
make
(
map
[
Oid
]
Tid
)}
return
&
ΔTail
{
lastRevOf
:
make
(
map
[
Oid
]
Tid
)}
}
}
// XXX + .Head() -> max(rev) XXX or 0 if len(tailv) == 0?
// Head returns database state starting from which δtail has history coverage. XXX
//
// For newly created ΔTail Head returns 0.
// Head is ↑, in particular it does not go back to 0 when δtail becomes empty.
func
(
δtail
*
ΔTail
)
Head
()
Tid
{
func
(
δtail
*
ΔTail
)
Head
()
Tid
{
panic
(
"TODO"
)
return
δtail
.
head
}
}
// XXX add way to extend coverage without appending changed data? (i.e. if a
// XXX add way to extend coverage without appending changed data? (i.e. if a
...
@@ -86,13 +90,11 @@ func (δtail *ΔTail) Head() Tid {
...
@@ -86,13 +90,11 @@ func (δtail *ΔTail) Head() Tid {
// rev must be ↑.
// rev must be ↑.
func
(
δtail
*
ΔTail
)
Append
(
rev
Tid
,
changev
[]
Oid
)
{
func
(
δtail
*
ΔTail
)
Append
(
rev
Tid
,
changev
[]
Oid
)
{
// check rev↑
// check rev↑
// XXX better also check even when δtail is ø (after forget)
if
δtail
.
head
>=
rev
{
if
l
:=
len
(
δtail
.
tailv
);
l
>
0
{
panic
(
fmt
.
Sprintf
(
"δtail.Append: rev not ↑: %s -> %s"
,
δtail
.
head
,
rev
))
if
revPrev
:=
δtail
.
tailv
[
l
-
1
]
.
rev
;
revPrev
>=
rev
{
panic
(
fmt
.
Sprintf
(
"δtail.Append: rev not ↑: %s -> %s"
,
revPrev
,
rev
))
}
}
}
δtail
.
head
=
rev
δtail
.
tailv
=
append
(
δtail
.
tailv
,
δRevEntry
{
rev
,
changev
})
δtail
.
tailv
=
append
(
δtail
.
tailv
,
δRevEntry
{
rev
,
changev
})
for
_
,
id
:=
range
changev
{
for
_
,
id
:=
range
changev
{
δtail
.
lastRevOf
[
id
]
=
rev
δtail
.
lastRevOf
[
id
]
=
rev
...
...
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