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
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
2d2242a9
Commit
2d2242a9
authored
Aug 24, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
ec7dafb1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
13 deletions
+38
-13
go/neo/client/cache.go
go/neo/client/cache.go
+1
-1
go/neo/client/cache_test.go
go/neo/client/cache_test.go
+37
-12
No files found.
go/neo/client/cache.go
View file @
2d2242a9
...
@@ -68,7 +68,7 @@ type oidCacheEntry struct {
...
@@ -68,7 +68,7 @@ type oidCacheEntry struct {
// XXX or?
// XXX or?
// cached revisions in descending order
// cached revisions in descending order
// .before > .serial >= next.before > next.serial ?
// .before > .serial >= next.before > next.serial ?
revv
[]
*
revCacheEntry
revv
[]
*
revCacheEntry
// XXX -> rcev ?
}
}
// revCacheEntry is information about 1 cached oid revision
// revCacheEntry is information about 1 cached oid revision
...
...
go/neo/client/cache_test.go
View file @
2d2242a9
...
@@ -82,7 +82,7 @@ var tstor = &tStorage{
...
@@ -82,7 +82,7 @@ var tstor = &tStorage{
dataMap
:
map
[
zodb
.
Oid
][]
tOidData
{
dataMap
:
map
[
zodb
.
Oid
][]
tOidData
{
1
:
{
1
:
{
{
4
,
[]
byte
(
"hello"
)},
{
4
,
[]
byte
(
"hello"
)},
{
7
,
[]
byte
(
"world"
)},
{
8
,
[]
byte
(
"world"
)},
},
},
},
},
}
}
...
@@ -114,6 +114,8 @@ func TestCache(t *testing.T) {
...
@@ -114,6 +114,8 @@ func TestCache(t *testing.T) {
ok1
:=
func
(
v
bool
)
{
t
.
Helper
();
tc
.
ok1
(
v
)
}
ok1
:=
func
(
v
bool
)
{
t
.
Helper
();
tc
.
ok1
(
v
)
}
//eq := func(a, b interface{}) { t.Helper(); tc.assertEq(a, b) }
//eq := func(a, b interface{}) { t.Helper(); tc.assertEq(a, b) }
hello
:=
[]
byte
(
"hello"
)
c
:=
NewCache
(
tstor
)
c
:=
NewCache
(
tstor
)
checkLoad
:=
func
(
xid
zodb
.
Xid
,
data
[]
byte
,
serial
zodb
.
Tid
,
err
error
)
{
checkLoad
:=
func
(
xid
zodb
.
Xid
,
data
[]
byte
,
serial
zodb
.
Tid
,
err
error
)
{
...
@@ -121,13 +123,13 @@ func TestCache(t *testing.T) {
...
@@ -121,13 +123,13 @@ func TestCache(t *testing.T) {
bad
:=
&
bytes
.
Buffer
{}
bad
:=
&
bytes
.
Buffer
{}
d
,
s
,
e
:=
c
.
Load
(
xid
)
d
,
s
,
e
:=
c
.
Load
(
xid
)
if
!
reflect
.
DeepEqual
(
data
,
d
)
{
if
!
reflect
.
DeepEqual
(
data
,
d
)
{
fmt
.
Fprintf
(
bad
,
"data:
\n
%s"
,
pretty
.
Compare
(
data
,
d
))
fmt
.
Fprintf
(
bad
,
"data:
\n
%s
\n
"
,
pretty
.
Compare
(
data
,
d
))
}
}
if
serial
!=
s
{
if
serial
!=
s
{
fmt
.
Fprintf
(
bad
,
"serial:
\n
%s"
,
pretty
.
Compare
(
serial
,
s
))
fmt
.
Fprintf
(
bad
,
"serial:
\n
%s
\n
"
,
pretty
.
Compare
(
serial
,
s
))
}
}
if
!
reflect
.
DeepEqual
(
err
,
e
)
{
if
!
reflect
.
DeepEqual
(
err
,
e
)
{
fmt
.
Fprintf
(
bad
,
"err:
\n
%s"
,
pretty
.
Compare
(
err
,
e
))
fmt
.
Fprintf
(
bad
,
"err:
\n
%s
\n
"
,
pretty
.
Compare
(
err
,
e
))
}
}
if
bad
.
Len
()
!=
0
{
if
bad
.
Len
()
!=
0
{
...
@@ -139,16 +141,16 @@ func TestCache(t *testing.T) {
...
@@ -139,16 +141,16 @@ func TestCache(t *testing.T) {
t
.
Helper
()
t
.
Helper
()
bad
:=
&
bytes
.
Buffer
{}
bad
:=
&
bytes
.
Buffer
{}
if
rce
.
before
!=
before
{
if
rce
.
before
!=
before
{
fmt
.
Fprintf
(
bad
,
"before:
\n
%s"
,
pretty
.
Compare
(
before
,
rce
.
before
))
fmt
.
Fprintf
(
bad
,
"before:
\n
%s
\n
"
,
pretty
.
Compare
(
before
,
rce
.
before
))
}
}
if
rce
.
serial
!=
serial
{
if
rce
.
serial
!=
serial
{
fmt
.
Fprintf
(
bad
,
"serial:
\n
%s"
,
pretty
.
Compare
(
serial
,
rce
.
serial
))
fmt
.
Fprintf
(
bad
,
"serial:
\n
%s
\n
"
,
pretty
.
Compare
(
serial
,
rce
.
serial
))
}
}
if
!
reflect
.
DeepEqual
(
rce
.
data
,
data
)
{
if
!
reflect
.
DeepEqual
(
rce
.
data
,
data
)
{
fmt
.
Fprintf
(
bad
,
"data:
\n
%s"
,
pretty
.
Compare
(
data
,
rce
.
data
))
fmt
.
Fprintf
(
bad
,
"data:
\n
%s
\n
"
,
pretty
.
Compare
(
data
,
rce
.
data
))
}
}
if
!
reflect
.
DeepEqual
(
rce
.
err
,
err
)
{
if
!
reflect
.
DeepEqual
(
rce
.
err
,
err
)
{
fmt
.
Fprintf
(
bad
,
"err:
\n
%s"
,
pretty
.
Compare
(
err
,
rce
.
err
))
fmt
.
Fprintf
(
bad
,
"err:
\n
%s
\n
"
,
pretty
.
Compare
(
err
,
rce
.
err
))
}
}
if
bad
.
Len
()
!=
0
{
if
bad
.
Len
()
!=
0
{
...
@@ -156,10 +158,16 @@ func TestCache(t *testing.T) {
...
@@ -156,10 +158,16 @@ func TestCache(t *testing.T) {
}
}
}
}
checkOCE
:=
func
(
oid
zodb
.
Oid
,
rcev
...*
revCacheEntry
)
{
t
.
Helper
()
oce
:=
c
.
entryMap
[
oid
]
if
!
reflect
.
DeepEqual
(
oce
.
revv
,
rcev
)
{
t
.
Fatalf
(
"oce(%v):
\n
%s"
,
oid
,
pretty
.
Compare
(
rcev
,
oce
.
revv
))
}
}
// load <3 -> new rce entry
// load <3 -> new rce entry
checkLoad
(
xidlt
(
1
,
3
),
nil
,
0
,
&
zodb
.
ErrXidMissing
{
xidlt
(
1
,
3
)})
checkLoad
(
xidlt
(
1
,
3
),
nil
,
0
,
&
zodb
.
ErrXidMissing
{
xidlt
(
1
,
3
)})
//checkOCE(1, rce1_b3)
oce1
:=
c
.
entryMap
[
1
]
oce1
:=
c
.
entryMap
[
1
]
ok1
(
len
(
oce1
.
revv
)
==
1
)
ok1
(
len
(
oce1
.
revv
)
==
1
)
rce1_b3
:=
oce1
.
revv
[
0
]
rce1_b3
:=
oce1
.
revv
[
0
]
...
@@ -167,7 +175,6 @@ func TestCache(t *testing.T) {
...
@@ -167,7 +175,6 @@ func TestCache(t *testing.T) {
// load <4 -> <3 merged with <4
// load <4 -> <3 merged with <4
checkLoad
(
xidlt
(
1
,
4
),
nil
,
0
,
&
zodb
.
ErrXidMissing
{
xidlt
(
1
,
4
)})
checkLoad
(
xidlt
(
1
,
4
),
nil
,
0
,
&
zodb
.
ErrXidMissing
{
xidlt
(
1
,
4
)})
ok1
(
len
(
oce1
.
revv
)
==
1
)
ok1
(
len
(
oce1
.
revv
)
==
1
)
rce1_b4
:=
oce1
.
revv
[
0
]
rce1_b4
:=
oce1
.
revv
[
0
]
ok1
(
rce1_b4
!=
rce1_b3
)
// rce1_b3 was merged into rce1_b4
ok1
(
rce1_b4
!=
rce1_b3
)
// rce1_b3 was merged into rce1_b4
...
@@ -175,10 +182,28 @@ func TestCache(t *testing.T) {
...
@@ -175,10 +182,28 @@ func TestCache(t *testing.T) {
// load <2 -> <2 merged with <4
// load <2 -> <2 merged with <4
checkLoad
(
xidlt
(
1
,
2
),
nil
,
0
,
&
zodb
.
ErrXidMissing
{
xidlt
(
1
,
2
)})
checkLoad
(
xidlt
(
1
,
2
),
nil
,
0
,
&
zodb
.
ErrXidMissing
{
xidlt
(
1
,
2
)})
ok1
(
len
(
oce1
.
revv
)
==
1
)
ok1
(
len
(
oce1
.
revv
)
==
1
)
ok1
(
oce1
.
revv
[
0
]
==
rce1_b4
)
ok1
(
oce1
.
revv
[
0
]
==
rce1_b4
)
checkRCE
(
rce1_b4
,
4
,
0
,
nil
,
&
zodb
.
ErrXidMissing
{
xidlt
(
1
,
4
)})
checkRCE
(
rce1_b4
,
4
,
0
,
nil
,
&
zodb
.
ErrXidMissing
{
xidlt
(
1
,
4
)})
// load <6 -> new rce entry with data
checkLoad
(
xidlt
(
1
,
6
),
hello
,
4
,
nil
)
ok1
(
len
(
oce1
.
revv
)
==
2
)
rce1_b6
:=
oce1
.
revv
[
1
]
checkRCE
(
rce1_b6
,
6
,
4
,
hello
,
nil
)
checkOCE
(
1
,
rce1_b4
,
rce1_b6
)
// load <5 -> merged with <6
checkLoad
(
xidlt
(
1
,
5
),
hello
,
4
,
nil
)
checkOCE
(
1
,
rce1_b4
,
rce1_b6
)
// load <7 -> <6 merged -> <7
checkLoad
(
xidlt
(
1
,
7
),
hello
,
4
,
nil
)
ok1
(
len
(
oce1
.
revv
)
==
2
)
rce1_b7
:=
oce1
.
revv
[
1
]
ok1
(
rce1_b7
!=
rce1_b6
)
checkRCE
(
rce1_b7
,
7
,
4
,
hello
,
nil
)
checkOCE
(
1
,
rce1_b4
,
rce1_b7
)
}
}
type
Checker
struct
{
type
Checker
struct
{
...
...
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