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
d88f5fe5
Commit
d88f5fe5
authored
Jul 11, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X Adjust ΔTail to what wcfs expects
parent
8ae11b81
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
32 deletions
+20
-32
go/zodb/δtail.go
go/zodb/δtail.go
+15
-26
go/zodb/δtail_test.go
go/zodb/δtail_test.go
+5
-6
No files found.
go/zodb/δtail.go
View file @
d88f5fe5
// Copyright (C) 2018-202
0
Nexedi SA and Contributors.
// Copyright (C) 2018-202
1
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Kirill Smelkov <kirr@nexedi.com>
//
//
// This program is free software: you can Use, Study, Modify and Redistribute
// This program is free software: you can Use, Study, Modify and Redistribute
...
@@ -202,46 +202,35 @@ func (δtail *ΔTail) ForgetPast(revCut Tid) {
...
@@ -202,46 +202,35 @@ func (δtail *ΔTail) ForgetPast(revCut Tid) {
// XXX -> RevAt ?
// XXX -> RevAt ?
// LastRevOf tries to return what was the last revision that changed id as of at database state.
// LastRevOf tries to return what was the last revision that changed id as of at database state.
//
//
// Depending on current information in δtail it returns either exact result, or
// it must be called with the following condition:
// an upper-bound estimate for the last id revision, assuming id was changed ≤ at:
//
//
//
1) if δtail does not cover at, at is returned:
//
tail ≤ at ≤ head
//
//
//
# at ∉ [min(rev ∈ δtail), max(rev ∈ δtail)]
//
Depending on current information in δtail it returns either exact result, or
//
LastRevOf(id, at) = at
//
an upper-bound estimate for the last id revision:
//
//
//
2
) if δtail has an entry corresponding to id change, it gives exactly the
//
1
) if δtail has an entry corresponding to id change, it gives exactly the
// last revision that changed id:
// last revision that changed id:
//
//
// # at ∈ [min(rev ∈ δtail), max(rev ∈ δtail)]
// # ∃ rev ∈ δtail: rev changed id && rev ≤ at
// # ∃ rev ∈ δtail: rev changed id && rev ≤ at
// LastRevOf(id, at) = max(rev: rev changed id && rev ≤ at)
// LastRevOf(id, at) = max(rev: rev changed id && rev ≤ at)
, true
//
//
//
3
) if δtail does not contain appropriate record with id - it returns δtail's
//
2
) if δtail does not contain appropriate record with id - it returns δtail's
// lower bound as the estimate for the upper bound of the last id revision:
// lower bound as the estimate for the upper bound of the last id revision:
//
//
// # at ∈ [min(rev ∈ δtail), max(rev ∈ δtail)]
// # ∄ rev ∈ δtail: rev changed id && rev ≤ at
// # ∄ rev ∈ δtail: rev changed id && rev ≤ at
// LastRevOf(id, at) =
min(rev ∈ δtail)
// LastRevOf(id, at) =
δtail.tail, false
//
//
// On return exact indicates whether returned revision is exactly the last
// On return exact indicates whether returned revision is exactly the last
// revision of id, or only an upper-bound estimate of it.
// revision of id, or only an upper-bound estimate of it.
func
(
δtail
*
ΔTail
)
LastRevOf
(
id
Oid
,
at
Tid
)
(
_
Tid
,
exact
bool
)
{
func
(
δtail
*
ΔTail
)
LastRevOf
(
id
Oid
,
at
Tid
)
(
_
Tid
,
exact
bool
)
{
// check if we have no coverage at all
if
!
(
δtail
.
tail
<=
at
&&
at
<=
δtail
.
head
)
{
l
:=
len
(
δtail
.
tailv
)
panic
(
fmt
.
Sprintf
(
"at out of bounds: at: @%s, (tail, head] = (@%s, @%s]"
,
at
,
δtail
.
tail
,
δtail
.
head
))
if
l
==
0
{
}
return
at
,
false
}
revMin
:=
δtail
.
tailv
[
0
]
.
Rev
revMax
:=
δtail
.
tailv
[
l
-
1
]
.
Rev
if
!
(
revMin
<=
at
&&
at
<=
revMax
)
{
return
at
,
false
}
// we have the coverage
rev
,
ok
:=
δtail
.
lastRevOf
[
id
]
rev
,
ok
:=
δtail
.
lastRevOf
[
id
]
if
!
ok
{
if
!
ok
{
return
δtail
.
tail
v
[
0
]
.
Rev
,
false
return
δtail
.
tail
,
false
}
}
if
rev
<=
at
{
if
rev
<=
at
{
...
@@ -250,7 +239,7 @@ func (δtail *ΔTail) LastRevOf(id Oid, at Tid) (_ Tid, exact bool) {
...
@@ -250,7 +239,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
// what's in index is after at - scan tailv back to find appropriate entry
// XXX linear scan - see .lastRevOf comment.
// XXX linear scan - see .lastRevOf comment.
for
i
:=
l
-
1
;
i
>=
0
;
i
--
{
for
i
:=
l
en
(
δtail
.
tailv
)
-
1
;
i
>=
0
;
i
--
{
δ
:=
δtail
.
tailv
[
i
]
δ
:=
δtail
.
tailv
[
i
]
if
δ
.
Rev
>
at
{
if
δ
.
Rev
>
at
{
continue
continue
...
@@ -264,5 +253,5 @@ func (δtail *ΔTail) LastRevOf(id Oid, at Tid) (_ Tid, exact bool) {
...
@@ -264,5 +253,5 @@ func (δtail *ΔTail) LastRevOf(id Oid, at Tid) (_ Tid, exact bool) {
}
}
// nothing found
// nothing found
return
δtail
.
tail
v
[
0
]
.
Rev
,
false
return
δtail
.
tail
,
false
}
}
go/zodb/δtail_test.go
View file @
d88f5fe5
// Copyright (C) 2018-20
19
Nexedi SA and Contributors.
// Copyright (C) 2018-20
21
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Kirill Smelkov <kirr@nexedi.com>
//
//
// This program is free software: you can Use, Study, Modify and Redistribute
// This program is free software: you can Use, Study, Modify and Redistribute
...
@@ -174,14 +174,13 @@ func TestΔTail(t *testing.T) {
...
@@ -174,14 +174,13 @@ func TestΔTail(t *testing.T) {
δtail
=
NewΔTail
(
3
)
δtail
=
NewΔTail
(
3
)
δCheck
(
3
,
3
)
δCheck
(
3
,
3
)
δCheckLastUP
(
4
,
12
,
12
)
// δtail = ø
δCheckLastUP
(
3
,
3
,
3
)
// δtail = ø
δAppend
(
R
(
10
,
3
,
5
))
δAppend
(
R
(
10
,
3
,
5
))
δCheck
(
3
,
10
,
R
(
10
,
3
,
5
))
δCheck
(
3
,
10
,
R
(
10
,
3
,
5
))
δCheckLastUP
(
3
,
2
,
2
)
// at < δtail
δCheckLastUP
(
3
,
9
,
3
)
// id ∈ δtail, but has no entry with rev ≤ at
δCheckLastUP
(
3
,
12
,
12
)
// at > δtail
δCheckLastUP
(
4
,
10
,
3
)
// id ∉ δtail
δCheckLastUP
(
4
,
10
,
10
)
// id ∉ δtail
δAppend
(
R
(
11
,
7
))
δAppend
(
R
(
11
,
7
))
δCheck
(
3
,
11
,
R
(
10
,
3
,
5
),
R
(
11
,
7
))
δCheck
(
3
,
11
,
R
(
10
,
3
,
5
),
R
(
11
,
7
))
...
@@ -192,7 +191,7 @@ func TestΔTail(t *testing.T) {
...
@@ -192,7 +191,7 @@ func TestΔTail(t *testing.T) {
δAppend
(
R
(
14
,
3
,
8
))
δAppend
(
R
(
14
,
3
,
8
))
δCheck
(
3
,
14
,
R
(
10
,
3
,
5
),
R
(
11
,
7
),
R
(
12
,
7
),
R
(
14
,
3
,
8
))
δCheck
(
3
,
14
,
R
(
10
,
3
,
5
),
R
(
11
,
7
),
R
(
12
,
7
),
R
(
14
,
3
,
8
))
δCheckLastUP
(
8
,
12
,
10
)
// id ∈ δtail, but has no entry with rev ≤ at
δCheckLastUP
(
8
,
12
,
3
)
// id ∈ δtail, but has no entry with rev ≤ at
δtail
.
ForgetPast
(
9
)
δtail
.
ForgetPast
(
9
)
δCheck
(
9
,
14
,
R
(
10
,
3
,
5
),
R
(
11
,
7
),
R
(
12
,
7
),
R
(
14
,
3
,
8
))
δCheck
(
9
,
14
,
R
(
10
,
3
,
5
),
R
(
11
,
7
),
R
(
12
,
7
),
R
(
14
,
3
,
8
))
...
...
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