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
c285c610
Commit
c285c610
authored
Feb 24, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e6f9c797
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
21 deletions
+18
-21
t/neo/storage/fs1/filestorage.go
t/neo/storage/fs1/filestorage.go
+18
-21
No files found.
t/neo/storage/fs1/filestorage.go
View file @
c285c610
...
@@ -47,8 +47,6 @@ type TxnHeader struct {
...
@@ -47,8 +47,6 @@ type TxnHeader struct {
// (0 if there is no previous txn record)
// (0 if there is no previous txn record)
Len
int64
// whole transaction record length
Len
int64
// whole transaction record length
// XXX recheck ^^^ Len are validated on load
// transaction metadata tself
// transaction metadata tself
zodb
.
TxnInfo
zodb
.
TxnInfo
...
@@ -106,25 +104,24 @@ var ErrVersionNonZero = errors.New("non-zero version")
...
@@ -106,25 +104,24 @@ var ErrVersionNonZero = errors.New("non-zero version")
// load reads and decodes transaction record header from a readerAt
// load reads and decodes transaction record header from a readerAt
// pos: points to
header begin XXX tex
t
// pos: points to
transaction star
t
// no requirements are made to previous t
h state XXX text
// no requirements are made to previous t
xnh state
// XXX io.ReaderAt -> *os.File (if iface conv costly)
// XXX io.ReaderAt -> *os.File (if iface conv costly)
//func (th *TxnHeader) load(r io.ReaderAt, pos int64, tmpBuf *[txnXHeaderFixSize]byte) (n int, err error) {
func
(
txnh
*
TxnHeader
)
load
(
r
io
.
ReaderAt
,
pos
int64
,
tmpBuf
*
[
txnXHeaderFixSize
]
byte
)
error
{
func
(
th
*
TxnHeader
)
load
(
r
io
.
ReaderAt
,
pos
int64
,
tmpBuf
*
[
txnXHeaderFixSize
]
byte
)
error
{
txnh
.
Pos
=
pos
th
.
Pos
=
pos
if
pos
>
4
+
8
{
// XXX -> magic
if
pos
>
4
+
8
{
// XXX -> magic
// read together with previous's txn record redundand length
// read together with previous's txn record redundand length
n
,
err
=
r
.
ReadAt
(
tmpBuf
[
:
],
pos
-
8
)
n
,
err
=
r
.
ReadAt
(
tmpBuf
[
:
],
pos
-
8
)
n
-=
8
// relative to pos
n
-=
8
// relative to pos
if
n
>=
0
{
if
n
>=
0
{
t
h
.
PrevLenm8
=
u
int64
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
8
-
8
:
]))
t
xnh
.
PrevLen
=
8
+
int64
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
8
-
8
:
]))
if
t
h
.
PrevLenm8
<
txnHeaderFixSize
{
if
t
xnh
.
PrevLen
<
txnHeaderFixSize
{
panic
(
"too small txn prev record length"
)
// XXX
panic
(
"too small txn prev record length"
)
// XXX
}
}
}
}
}
else
{
}
else
{
t
h
.
PrevLenm8
=
0
t
xnh
.
PrevLen
=
0
n
,
err
=
r
.
ReadAt
(
tmpBuf
[
8
:
],
pos
)
n
,
err
=
r
.
ReadAt
(
tmpBuf
[
8
:
],
pos
)
}
}
...
@@ -142,11 +139,11 @@ func (th *TxnHeader) load(r io.ReaderAt, pos int64, tmpBuf *[txnXHeaderFixSize]b
...
@@ -142,11 +139,11 @@ func (th *TxnHeader) load(r io.ReaderAt, pos int64, tmpBuf *[txnXHeaderFixSize]b
return
n
,
&
ErrTxnRecord
{
pos
,
"read"
,
err
}
return
n
,
&
ErrTxnRecord
{
pos
,
"read"
,
err
}
}
}
th
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
8
+
0
:
]))
t
xn
h
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
8
+
0
:
]))
t
h
.
Lenm8
=
u
int64
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
8
+
8
:
]))
t
xnh
.
Len
=
8
+
int64
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
8
+
8
:
]))
th
.
Status
=
zodb
.
TxnStatus
(
tmpBuf
[
8
+
16
])
t
xn
h
.
Status
=
zodb
.
TxnStatus
(
tmpBuf
[
8
+
16
])
if
t
h
.
Lenm8
<
txnHeaderFixSize
{
if
t
xnh
.
Len
<
txnHeaderFixSize
{
panic
(
"too small txn record length"
)
// XXX
panic
(
"too small txn record length"
)
// XXX
}
}
...
@@ -156,22 +153,22 @@ func (th *TxnHeader) load(r io.ReaderAt, pos int64, tmpBuf *[txnXHeaderFixSize]b
...
@@ -156,22 +153,22 @@ func (th *TxnHeader) load(r io.ReaderAt, pos int64, tmpBuf *[txnXHeaderFixSize]b
// XXX load strings only optionally
// XXX load strings only optionally
lstr
:=
int
(
luser
)
+
int
(
ldesc
)
+
int
(
lext
)
lstr
:=
int
(
luser
)
+
int
(
ldesc
)
+
int
(
lext
)
if
lstr
<=
cap
(
th
.
stringsMem
)
{
if
lstr
<=
cap
(
t
xn
h
.
stringsMem
)
{
t
h
.
stringsMem
=
t
h
.
stringsMem
[
:
lstr
]
t
xnh
.
stringsMem
=
txn
h
.
stringsMem
[
:
lstr
]
}
else
{
}
else
{
th
.
stringsMem
=
make
([]
byte
,
lstr
)
t
xn
h
.
stringsMem
=
make
([]
byte
,
lstr
)
}
}
nstr
,
err
=
r
.
ReadAt
(
th
.
stringsMem
,
pos
+
txnHeaderFixSize
)
nstr
,
err
=
r
.
ReadAt
(
t
xn
h
.
stringsMem
,
pos
+
txnHeaderFixSize
)
// XXX EOF after txn header is not good
// XXX EOF after txn header is not good
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
&
ErrTxnRecord
{
pos
,
"read"
,
noEof
(
err
)}
return
0
,
&
ErrTxnRecord
{
pos
,
"read"
,
noEof
(
err
)}
}
}
t
h
.
User
=
t
h
.
stringsMem
[
0
:
luser
]
t
xnh
.
User
=
txn
h
.
stringsMem
[
0
:
luser
]
t
h
.
Description
=
t
h
.
stringsMem
[
luser
:
luser
+
ldesc
]
t
xnh
.
Description
=
txn
h
.
stringsMem
[
luser
:
luser
+
ldesc
]
t
h
.
Extension
=
t
h
.
stringsMem
[
luser
+
ldesc
:
luser
+
ldesc
+
lext
]
t
xnh
.
Extension
=
txn
h
.
stringsMem
[
luser
+
ldesc
:
luser
+
ldesc
+
lext
]
return
txnHeaderFixSize
+
lstr
,
nil
return
txnHeaderFixSize
+
lstr
,
nil
}
}
...
...
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