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
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 {
// (0 if there is no previous txn record)
Len
int64
// whole transaction record length
// XXX recheck ^^^ Len are validated on load
// transaction metadata tself
zodb
.
TxnInfo
...
...
@@ -106,25 +104,24 @@ var ErrVersionNonZero = errors.New("non-zero version")
// load reads and decodes transaction record header from a readerAt
// pos: points to
header begin XXX tex
t
// no requirements are made to previous t
h state XXX text
// pos: points to
transaction star
t
// no requirements are made to previous t
xnh state
// 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
(
th
*
TxnHeader
)
load
(
r
io
.
ReaderAt
,
pos
int64
,
tmpBuf
*
[
txnXHeaderFixSize
]
byte
)
error
{
th
.
Pos
=
pos
func
(
txnh
*
TxnHeader
)
load
(
r
io
.
ReaderAt
,
pos
int64
,
tmpBuf
*
[
txnXHeaderFixSize
]
byte
)
error
{
txnh
.
Pos
=
pos
if
pos
>
4
+
8
{
// XXX -> magic
// read together with previous's txn record redundand length
n
,
err
=
r
.
ReadAt
(
tmpBuf
[
:
],
pos
-
8
)
n
-=
8
// relative to pos
if
n
>=
0
{
t
h
.
PrevLenm8
=
u
int64
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
8
-
8
:
]))
if
t
h
.
PrevLenm8
<
txnHeaderFixSize
{
t
xnh
.
PrevLen
=
8
+
int64
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
8
-
8
:
]))
if
t
xnh
.
PrevLen
<
txnHeaderFixSize
{
panic
(
"too small txn prev record length"
)
// XXX
}
}
}
else
{
t
h
.
PrevLenm8
=
0
t
xnh
.
PrevLen
=
0
n
,
err
=
r
.
ReadAt
(
tmpBuf
[
8
:
],
pos
)
}
...
...
@@ -142,11 +139,11 @@ func (th *TxnHeader) load(r io.ReaderAt, pos int64, tmpBuf *[txnXHeaderFixSize]b
return
n
,
&
ErrTxnRecord
{
pos
,
"read"
,
err
}
}
th
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
8
+
0
:
]))
t
h
.
Lenm8
=
u
int64
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
8
+
8
:
]))
th
.
Status
=
zodb
.
TxnStatus
(
tmpBuf
[
8
+
16
])
t
xn
h
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
8
+
0
:
]))
t
xnh
.
Len
=
8
+
int64
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
8
+
8
:
]))
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
}
...
...
@@ -156,22 +153,22 @@ func (th *TxnHeader) load(r io.ReaderAt, pos int64, tmpBuf *[txnXHeaderFixSize]b
// XXX load strings only optionally
lstr
:=
int
(
luser
)
+
int
(
ldesc
)
+
int
(
lext
)
if
lstr
<=
cap
(
th
.
stringsMem
)
{
t
h
.
stringsMem
=
t
h
.
stringsMem
[
:
lstr
]
if
lstr
<=
cap
(
t
xn
h
.
stringsMem
)
{
t
xnh
.
stringsMem
=
txn
h
.
stringsMem
[
:
lstr
]
}
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
if
err
!=
nil
{
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
h
.
Extension
=
t
h
.
stringsMem
[
luser
+
ldesc
:
luser
+
ldesc
+
lext
]
t
xnh
.
Description
=
txn
h
.
stringsMem
[
luser
:
luser
+
ldesc
]
t
xnh
.
Extension
=
txn
h
.
stringsMem
[
luser
+
ldesc
:
luser
+
ldesc
+
lext
]
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