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
94e427fe
Commit
94e427fe
authored
Aug 24, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7ab9fe97
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
9 deletions
+32
-9
go/neo/client/cache.go
go/neo/client/cache.go
+3
-3
go/neo/client/cache_test.go
go/neo/client/cache_test.go
+29
-6
No files found.
go/neo/client/cache.go
View file @
94e427fe
...
@@ -342,7 +342,7 @@ func tryMerge(prev, next, cur *revCacheEntry, oid zodb.Oid) bool {
...
@@ -342,7 +342,7 @@ func tryMerge(prev, next, cur *revCacheEntry, oid zodb.Oid) bool {
// Pok Nok Ns < Pb Ps = Ns
// Pok Nok Ns < Pb Ps = Ns
// Pe Nok Ns < Pb Pe != "nodata" (e.g. it was IO loading error for P)
// Pe Nok Ns < Pb Pe != "nodata" (e.g. it was IO loading error for P)
// Pok Ne ---
// Pok Ne ---
// Ne Pe (Pe="nodata")
=
(Ne="nodata") -> XXX vs deleteObject?
// Ne Pe (Pe="nodata")
&&
(Ne="nodata") -> XXX vs deleteObject?
// -> let deleted object actually read
// -> let deleted object actually read
// -> as special non-error value
// -> as special non-error value
//
//
...
@@ -370,12 +370,12 @@ func tryMerge(prev, next, cur *revCacheEntry, oid zodb.Oid) bool {
...
@@ -370,12 +370,12 @@ func tryMerge(prev, next, cur *revCacheEntry, oid zodb.Oid) bool {
return
true
return
true
}
}
if
prev
.
err
!=
nil
&&
isErrNoData
(
prev
.
err
)
==
isErrNoData
(
next
.
err
)
{
if
isErrNoData
(
prev
.
err
)
&&
isErrNoData
(
next
.
err
)
{
// drop prev
// drop prev
prev
.
parent
.
del
(
prev
)
prev
.
parent
.
del
(
prev
)
// not checking consistency - error is already there and
// not checking consistency - error is already there and
// (Pe="nodata")
=
(Ne="nodata") already indicates prev & next are consistent.
// (Pe="nodata")
&&
(Ne="nodata") already indicates prev & next are consistent.
return
true
return
true
}
}
...
...
go/neo/client/cache_test.go
View file @
94e427fe
...
@@ -47,8 +47,8 @@ type tOidData struct {
...
@@ -47,8 +47,8 @@ type tOidData struct {
}
}
func
(
stor
*
tStorage
)
Load
(
xid
zodb
.
Xid
)
(
data
[]
byte
,
serial
zodb
.
Tid
,
err
error
)
{
func
(
stor
*
tStorage
)
Load
(
xid
zodb
.
Xid
)
(
data
[]
byte
,
serial
zodb
.
Tid
,
err
error
)
{
fmt
.
Printf
(
"> load(%v)
\n
"
,
xid
)
//
fmt.Printf("> load(%v)\n", xid)
defer
func
()
{
fmt
.
Printf
(
"< %v, %v, %v
\n
"
,
data
,
serial
,
err
)
}()
//
defer func() { fmt.Printf("< %v, %v, %v\n", data, serial, err) }()
tid
:=
xid
.
Tid
tid
:=
xid
.
Tid
if
!
xid
.
TidBefore
{
if
!
xid
.
TidBefore
{
tid
++
// XXX overflow
tid
++
// XXX overflow
...
@@ -63,10 +63,10 @@ func (stor *tStorage) Load(xid zodb.Xid) (data []byte, serial zodb.Tid, err erro
...
@@ -63,10 +63,10 @@ func (stor *tStorage) Load(xid zodb.Xid) (data []byte, serial zodb.Tid, err erro
n
:=
len
(
datav
)
n
:=
len
(
datav
)
i
:=
n
-
1
-
sort
.
Search
(
n
,
func
(
i
int
)
bool
{
i
:=
n
-
1
-
sort
.
Search
(
n
,
func
(
i
int
)
bool
{
v
:=
datav
[
n
-
1
-
i
]
.
serial
<
tid
v
:=
datav
[
n
-
1
-
i
]
.
serial
<
tid
fmt
.
Printf
(
"@%d -> %v (@%d; %v)
\n
"
,
i
,
v
,
n
-
1
-
i
,
tid
)
//
fmt.Printf("@%d -> %v (@%d; %v)\n", i, v, n - 1 -i, tid)
return
v
return
v
})
})
fmt
.
Printf
(
"i: %d n: %d
\n
"
,
i
,
n
)
//
fmt.Printf("i: %d n: %d\n", i, n)
if
i
==
-
1
{
if
i
==
-
1
{
// tid < all .serial - no such transaction
// tid < all .serial - no such transaction
return
nil
,
0
,
&
zodb
.
ErrXidMissing
{
xid
}
return
nil
,
0
,
&
zodb
.
ErrXidMissing
{
xid
}
...
@@ -91,7 +91,7 @@ var tstor = &tStorage{
...
@@ -91,7 +91,7 @@ var tstor = &tStorage{
1
:
{
1
:
{
{
4
,
[]
byte
(
"hello"
),
nil
},
{
4
,
[]
byte
(
"hello"
),
nil
},
{
7
,
nil
,
ioerr
},
{
7
,
nil
,
ioerr
},
{
12
,
[]
byte
(
"world"
),
nil
},
{
9
,
[]
byte
(
"world"
),
nil
},
},
},
},
},
}
}
...
@@ -124,6 +124,7 @@ func TestCache(t *testing.T) {
...
@@ -124,6 +124,7 @@ func TestCache(t *testing.T) {
//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"
)
hello
:=
[]
byte
(
"hello"
)
world
:=
[]
byte
(
"world"
)
c
:=
NewCache
(
tstor
)
c
:=
NewCache
(
tstor
)
...
@@ -214,12 +215,34 @@ func TestCache(t *testing.T) {
...
@@ -214,12 +215,34 @@ func TestCache(t *testing.T) {
checkRCE
(
rce1_b7
,
7
,
4
,
hello
,
nil
)
checkRCE
(
rce1_b7
,
7
,
4
,
hello
,
nil
)
checkOCE
(
1
,
rce1_b4
,
rce1_b7
)
checkOCE
(
1
,
rce1_b4
,
rce1_b7
)
// load <8 -> ioerr
|
new rce
// load <8 -> ioerr
+
new rce
checkLoad
(
xidlt
(
1
,
8
),
nil
,
0
,
ioerr
)
checkLoad
(
xidlt
(
1
,
8
),
nil
,
0
,
ioerr
)
ok1
(
len
(
oce1
.
revv
)
==
3
)
ok1
(
len
(
oce1
.
revv
)
==
3
)
rce1_b8
:=
oce1
.
revv
[
2
]
rce1_b8
:=
oce1
.
revv
[
2
]
checkRCE
(
rce1_b8
,
8
,
0
,
nil
,
ioerr
)
checkRCE
(
rce1_b8
,
8
,
0
,
nil
,
ioerr
)
checkOCE
(
1
,
rce1_b4
,
rce1_b7
,
rce1_b8
)
checkOCE
(
1
,
rce1_b4
,
rce1_b7
,
rce1_b8
)
// load <9 -> ioerr + new rce (IO errors are not merged)
checkLoad
(
xidlt
(
1
,
9
),
nil
,
0
,
ioerr
)
ok1
(
len
(
oce1
.
revv
)
==
4
)
rce1_b9
:=
oce1
.
revv
[
3
]
checkRCE
(
rce1_b9
,
9
,
0
,
nil
,
ioerr
)
checkOCE
(
1
,
rce1_b4
,
rce1_b7
,
rce1_b8
,
rce1_b9
)
// load <10 -> new data rce, not merged with ioerr @<9
checkLoad
(
xidlt
(
1
,
10
),
world
,
9
,
nil
)
ok1
(
len
(
oce1
.
revv
)
==
5
)
rce1_b10
:=
oce1
.
revv
[
4
]
checkRCE
(
rce1_b10
,
10
,
9
,
world
,
nil
)
checkOCE
(
1
,
rce1_b4
,
rce1_b7
,
rce1_b8
,
rce1_b9
,
rce1_b10
)
// load <12 -> <10 merged -> <12
checkLoad
(
xidlt
(
1
,
12
),
world
,
9
,
nil
)
ok1
(
len
(
oce1
.
revv
)
==
5
)
rce1_b12
:=
oce1
.
revv
[
4
]
ok1
(
rce1_b12
!=
rce1_b10
)
checkRCE
(
rce1_b12
,
12
,
9
,
world
,
nil
)
checkOCE
(
1
,
rce1_b4
,
rce1_b7
,
rce1_b8
,
rce1_b9
,
rce1_b12
)
}
}
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