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
5c5ba580
Commit
5c5ba580
authored
Mar 06, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
cb13a9f4
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
96 additions
and
89 deletions
+96
-89
t/neo/storage/fs1/filestorage.go
t/neo/storage/fs1/filestorage.go
+23
-22
t/neo/storage/fs1/filestorage_test.go
t/neo/storage/fs1/filestorage_test.go
+5
-3
t/neo/storage/fs1/py/gen-testdata
t/neo/storage/fs1/py/gen-testdata
+3
-1
t/neo/storage/fs1/testdata_expect_test.go
t/neo/storage/fs1/testdata_expect_test.go
+62
-62
t/neo/zodb/str.go
t/neo/zodb/str.go
+3
-1
No files found.
t/neo/storage/fs1/filestorage.go
View file @
5c5ba580
...
@@ -148,21 +148,22 @@ func bug(e xerr, format string, a ...interface{}) {
...
@@ -148,21 +148,22 @@ func bug(e xerr, format string, a ...interface{}) {
}
}
// // noEOF returns err, but changes io.EOF -> io.ErrUnexpectedEOF
// XXX -> xio ?
// func NoEOF(err error) error {
// noEOF returns err, but changes io.EOF -> io.ErrUnexpectedEOF
// if err == io.EOF {
func
noEOF
(
err
error
)
error
{
// err = io.ErrUnexpectedEOF
if
err
==
io
.
EOF
{
// }
err
=
io
.
ErrUnexpectedEOF
// return err
}
// }
return
err
//
}
// // okEOF returns err, but changes io.EOF -> nil
// func okEOF(err error) error {
// okEOF returns err, but changes io.EOF -> nil
// if err == io.EOF {
func
okEOF
(
err
error
)
error
{
// err = nil
if
err
==
io
.
EOF
{
// }
err
=
nil
// return err
}
// }
return
err
}
// --- Transaction record ---
// --- Transaction record ---
...
@@ -268,7 +269,7 @@ func (txnh *TxnHeader) Load(r io.ReaderAt /* *os.File */, pos int64, flags TxnLo
...
@@ -268,7 +269,7 @@ func (txnh *TxnHeader) Load(r io.ReaderAt /* *os.File */, pos int64, flags TxnLo
// EOF after txn header is not good - because at least
// EOF after txn header is not good - because at least
// redundant length should be also there
// redundant length should be also there
return
txnh
.
err
(
"read"
,
xio
.
N
oEOF
(
err
))
return
txnh
.
err
(
"read"
,
n
oEOF
(
err
))
}
}
txnh
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
work
[
8
+
0
:
]))
txnh
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
work
[
8
+
0
:
]))
...
@@ -294,7 +295,7 @@ func (txnh *TxnHeader) Load(r io.ReaderAt /* *os.File */, pos int64, flags TxnLo
...
@@ -294,7 +295,7 @@ func (txnh *TxnHeader) Load(r io.ReaderAt /* *os.File */, pos int64, flags TxnLo
lext
:=
binary
.
BigEndian
.
Uint16
(
work
[
8
+
21
:
])
lext
:=
binary
.
BigEndian
.
Uint16
(
work
[
8
+
21
:
])
lstr
:=
int
(
luser
)
+
int
(
ldesc
)
+
int
(
lext
)
lstr
:=
int
(
luser
)
+
int
(
ldesc
)
+
int
(
lext
)
if
TxnHeaderFixSize
+
lstr
+
8
>
txnh
.
Len
{
if
TxnHeaderFixSize
+
int64
(
lstr
)
+
8
>
txnh
.
Len
{
return
decodeErr
(
txnh
,
"strings overlap with txn boundary: %v / %v"
,
lstr
,
txnh
.
Len
)
return
decodeErr
(
txnh
,
"strings overlap with txn boundary: %v / %v"
,
lstr
,
txnh
.
Len
)
}
}
...
@@ -331,7 +332,7 @@ func (txnh *TxnHeader) loadStrings(r io.ReaderAt /* *os.File */) error {
...
@@ -331,7 +332,7 @@ func (txnh *TxnHeader) loadStrings(r io.ReaderAt /* *os.File */) error {
// we rely on Load leaving len(workMem) = sum of all strings length ...
// we rely on Load leaving len(workMem) = sum of all strings length ...
_
,
err
:=
r
.
ReadAt
(
txnh
.
workMem
,
txnh
.
Pos
+
TxnHeaderFixSize
)
_
,
err
:=
r
.
ReadAt
(
txnh
.
workMem
,
txnh
.
Pos
+
TxnHeaderFixSize
)
if
err
!=
nil
{
if
err
!=
nil
{
return
txnh
.
err
(
"read strings"
,
xio
.
noEOF
(
err
))
return
txnh
.
err
(
"read strings"
,
noEOF
(
err
))
}
}
// ... and presetting x to point to appropriate places in .workMem .
// ... and presetting x to point to appropriate places in .workMem .
...
@@ -442,7 +443,7 @@ func (dh *DataHeader) load(r io.ReaderAt /* *os.File */, pos int64, tmpBuf *[Dat
...
@@ -442,7 +443,7 @@ func (dh *DataHeader) load(r io.ReaderAt /* *os.File */, pos int64, tmpBuf *[Dat
_
,
err
:=
r
.
ReadAt
(
tmpBuf
[
:
],
pos
)
_
,
err
:=
r
.
ReadAt
(
tmpBuf
[
:
],
pos
)
if
err
!=
nil
{
if
err
!=
nil
{
return
dh
.
err
(
"read"
,
xio
.
noEOF
(
err
))
return
dh
.
err
(
"read"
,
noEOF
(
err
))
}
}
// XXX also check oid.Valid() ?
// XXX also check oid.Valid() ?
...
@@ -542,7 +543,7 @@ func (dh *DataHeader) LoadBack(r io.ReaderAt /* *os.File */) error {
...
@@ -542,7 +543,7 @@ func (dh *DataHeader) LoadBack(r io.ReaderAt /* *os.File */) error {
var
xxx
[
8
]
byte
// XXX escapes ?
var
xxx
[
8
]
byte
// XXX escapes ?
_
,
err
:=
r
.
ReadAt
(
xxx
[
:
],
dh
.
Pos
+
DataHeaderSize
)
_
,
err
:=
r
.
ReadAt
(
xxx
[
:
],
dh
.
Pos
+
DataHeaderSize
)
if
err
!=
nil
{
if
err
!=
nil
{
return
dh
.
err
(
"read data"
,
xio
.
noEOF
(
err
))
return
dh
.
err
(
"read data"
,
noEOF
(
err
))
}
}
backPos
:=
int64
(
binary
.
BigEndian
.
Uint64
(
xxx
[
:
]))
backPos
:=
int64
(
binary
.
BigEndian
.
Uint64
(
xxx
[
:
]))
...
@@ -651,7 +652,7 @@ func (dh *DataHeader) LoadData(r io.ReaderAt /* *os.File */, buf *[]byte) error
...
@@ -651,7 +652,7 @@ func (dh *DataHeader) LoadData(r io.ReaderAt /* *os.File */, buf *[]byte) error
}
}
_
,
err
:=
r
.
ReadAt
(
*
buf
,
dh
.
Pos
+
DataHeaderSize
)
_
,
err
:=
r
.
ReadAt
(
*
buf
,
dh
.
Pos
+
DataHeaderSize
)
if
err
!=
nil
{
if
err
!=
nil
{
return
dh
.
err
(
"read data"
,
xio
.
noEOF
(
err
))
// XXX recheck
return
dh
.
err
(
"read data"
,
noEOF
(
err
))
// XXX recheck
}
}
return
nil
return
nil
...
@@ -945,7 +946,7 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
...
@@ -945,7 +946,7 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
for
{
for
{
err
=
iter
.
NextTxn
(
LoadNoStrings
)
err
=
iter
.
NextTxn
(
LoadNoStrings
)
if
err
!=
nil
{
if
err
!=
nil
{
err
=
xio
.
O
kEOF
(
err
)
err
=
o
kEOF
(
err
)
break
break
}
}
}
}
...
...
t/neo/storage/fs1/filestorage_test.go
View file @
5c5ba580
...
@@ -37,14 +37,16 @@ type dbEntry struct {
...
@@ -37,14 +37,16 @@ type dbEntry struct {
type
txnEntry
struct
{
type
txnEntry
struct
{
Header
DataHeader
Header
DataHeader
rawData
[]
byte
// what is on disk, e.g. it can be backpointer
rawData
[]
byte
// what is on disk, e.g. it can be backpointer
userData
[]
byte
// data client should see on load;
nil
means same as RawData
userData
[]
byte
// data client should see on load;
`sameAsRaw`
means same as RawData
dataTid
zodb
.
Tid
// data tid client should see on iter; 0 means same as Header.Tid
dataTid
zodb
.
Tid
// data tid client should see on iter; 0 means same as Header.Tid
}
}
var
sameAsRaw
=
[]
byte
{
0
}
// Data returns data a client should see
// Data returns data a client should see
func
(
txe
*
txnEntry
)
Data
()
[]
byte
{
func
(
txe
*
txnEntry
)
Data
()
[]
byte
{
data
:=
txe
.
userData
data
:=
txe
.
userData
if
data
==
nil
{
if
len
(
data
)
>
0
&&
&
data
[
0
]
==
&
sameAsRaw
[
0
]
{
data
=
txe
.
rawData
data
=
txe
.
rawData
}
}
return
data
return
data
...
@@ -74,7 +76,7 @@ func checkLoad(t *testing.T, fs *FileStorage, xid zodb.Xid, expect oidLoadedOk)
...
@@ -74,7 +76,7 @@ func checkLoad(t *testing.T, fs *FileStorage, xid zodb.Xid, expect oidLoadedOk)
if
tid
!=
expect
.
tid
{
if
tid
!=
expect
.
tid
{
t
.
Errorf
(
"load %v: returned tid unexpected: %v ; want: %v"
,
xid
,
tid
,
expect
.
tid
)
t
.
Errorf
(
"load %v: returned tid unexpected: %v ; want: %v"
,
xid
,
tid
,
expect
.
tid
)
}
}
if
!
bytes
.
Equal
(
data
,
expect
.
data
)
{
if
!
bytes
.
Equal
(
data
,
expect
.
data
)
{
// XXX -> reflect.DeepEqual
t
.
Errorf
(
"load %v: different data:
\n
have: %q
\n
want: %q"
,
xid
,
data
,
expect
.
data
)
t
.
Errorf
(
"load %v: different data:
\n
have: %q
\n
want: %q"
,
xid
,
data
,
expect
.
data
)
}
}
}
}
...
...
t/neo/storage/fs1/py/gen-testdata
View file @
5c5ba580
...
@@ -39,6 +39,7 @@ def xtime():
...
@@ -39,6 +39,7 @@ def xtime():
time
.
time
=
xtime
time
.
time
=
xtime
# prepare transaction for a commit
def
precommit
(
user
,
description
,
extension
):
def
precommit
(
user
,
description
,
extension
):
txn
=
transaction
.
get
()
txn
=
transaction
.
get
()
txn
.
user
=
user
txn
.
user
=
user
...
@@ -50,6 +51,7 @@ def commit(user, description, extension):
...
@@ -50,6 +51,7 @@ def commit(user, description, extension):
txn
=
precommit
(
user
,
description
,
extension
)
txn
=
precommit
(
user
,
description
,
extension
)
txn
.
commit
()
txn
.
commit
()
class
Object
(
Persistent
):
class
Object
(
Persistent
):
# .value
# .value
def
__init__
(
self
,
value
):
def
__init__
(
self
,
value
):
...
@@ -201,7 +203,7 @@ def main():
...
@@ -201,7 +203,7 @@ def main():
datatid
=
hex64
(
drec
.
data_txn
)
datatid
=
hex64
(
drec
.
data_txn
)
else
:
else
:
rawdata
=
drec
.
data
rawdata
=
drec
.
data
data
=
"/* same as ^^^ */
nil
"
data
=
"/* same as ^^^ */
sameAsRaw
"
datatid
=
"/* same as ^^^ */ 0"
datatid
=
"/* same as ^^^ */ 0"
emit
(
"
\
t
\
t
\
t
\
t
[]byte(%s),"
%
escapeqq
(
rawdata
))
emit
(
"
\
t
\
t
\
t
\
t
[]byte(%s),"
%
escapeqq
(
rawdata
))
...
...
t/neo/storage/fs1/testdata_expect_test.go
View file @
5c5ba580
This diff is collapsed.
Click to expand it.
t/neo/zodb/str.go
View file @
5c5ba580
...
@@ -6,7 +6,7 @@ package zodb
...
@@ -6,7 +6,7 @@ package zodb
import
(
import
(
"fmt"
"fmt"
"encoding/hex"
//
"encoding/hex"
)
)
func
(
tid
Tid
)
String
()
string
{
func
(
tid
Tid
)
String
()
string
{
...
@@ -39,6 +39,7 @@ func (xid Xid) String() string {
...
@@ -39,6 +39,7 @@ func (xid Xid) String() string {
}
}
/*
func ParseTid(s string) (Tid, error) {
func ParseTid(s string) (Tid, error) {
// -> scanf("%016x")
// -> scanf("%016x")
var b[8]byte
var b[8]byte
...
@@ -50,3 +51,4 @@ func ParseTid(s string) (Tid, error) {
...
@@ -50,3 +51,4 @@ func ParseTid(s string) (Tid, error) {
...
...
}
}
}
}
*/
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