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
4a11940d
Commit
4a11940d
authored
Feb 23, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d2dd9a96
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
27 deletions
+25
-27
t/neo/storage/fs1/filestorage.go
t/neo/storage/fs1/filestorage.go
+25
-27
No files found.
t/neo/storage/fs1/filestorage.go
View file @
4a11940d
...
...
@@ -41,28 +41,20 @@ var _ zodb.IStorage = (*FileStorage)(nil)
// TxnHeader represents header of a transaction record
type
TxnHeader
struct
{
RecLenm8
uint64
// XXX consider reorder with zodb.TxnInfo ?
// XXX consider reorder with zodb.TxnInfo ?
PrevRecLenm8
uint64
// 0 if no previous record
RecLenm8
uint64
zodb
.
TxnInfo
// underlying storage for user/desc/extension
stringsRam
[]
byte
/*
Tid zodb.Tid
RecLenm8 uint64
Status zodb.TxnStatus
//UserLen uint16
//DescriptionLen uint16
//ExtensionLen uint16
User []byte // TODO Encode ^^^
Description []byte
Extension []byte
*/
//Datav []DataRec
}
const
txnHeaderFixSize
=
8
+
8
+
1
+
2
+
2
+
2
// = 23
const
(
txnHeaderFixSize
=
8
+
8
+
1
+
2
+
2
+
2
// = 23
txnXHeaderFixSize
=
8
+
txnHeaderFixSize
// with trail lengthm8 from previous record
)
// ErrTxnRecord is returned on transaction record read / decode errors
// XXX merge with ErrDataRecord -> ErrRecord{pos, "transaction|data", "read", err} ?
...
...
@@ -112,20 +104,26 @@ var ErrVersionNonZero = errors.New("non-zero version")
// pos: points to header begin XXX text
// no requirements are made to previous th state XXX text
// XXX io.ReaderAt -> *os.File (if iface conv costly)
func
(
th
*
TxnHeader
)
decode
(
r
io
.
ReaderAt
,
pos
int64
,
tmpBuf
*
[
txnHeaderFixSize
]
byte
)
(
n
int
,
err
error
)
{
n
,
err
=
r
.
ReadAt
(
tmpBuf
[
:
],
pos
)
func
(
th
*
TxnHeader
)
decode
(
r
io
.
ReaderAt
,
pos
int64
,
tmpBuf
*
[
txnXHeaderFixSize
]
byte
)
(
n
int
,
err
error
)
{
if
pos
>
4
+
8
{
// XXX -> magic
_
,
err
=
r
.
ReadAt
(
tmpBuf
[
:
],
pos
-
8
)
}
else
{
binary
.
BigEndian
.
PutUint64
(
tmpBuf
[
0
:
],
0
)
// XXX simpler ?
_
,
err
=
r
.
ReadAt
(
tmpBuf
[
8
:
],
pos
)
}
// XXX EOF after txn header is not good
if
err
!=
nil
{
return
0
,
&
ErrTxnRecord
{
pos
,
"read"
,
err
}
}
th
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
0
:
]))
th
.
RecLenm8
=
uint64
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
8
:
]))
th
.
Status
=
zodb
.
TxnStatus
(
tmpBuf
[
16
])
th
.
PrevRecLenm8
=
uint64
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
8
-
8
:
]))
th
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
8
+
0
:
]))
th
.
RecLenm8
=
uint64
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
8
+
8
:
]))
th
.
Status
=
zodb
.
TxnStatus
(
tmpBuf
[
8
+
16
])
luser
:=
binary
.
BigEndian
.
Uint16
(
tmpBuf
[
17
:
])
ldesc
:=
binary
.
BigEndian
.
Uint16
(
tmpBuf
[
19
:
])
lext
:=
binary
.
BigEndian
.
Uint16
(
tmpBuf
[
21
:
])
luser
:=
binary
.
BigEndian
.
Uint16
(
tmpBuf
[
8
+
17
:
])
ldesc
:=
binary
.
BigEndian
.
Uint16
(
tmpBuf
[
8
+
19
:
])
lext
:=
binary
.
BigEndian
.
Uint16
(
tmpBuf
[
8
+
21
:
])
lstr
:=
int
(
luser
)
+
int
(
ldesc
)
+
int
(
lext
)
if
lstr
<=
cap
(
th
.
stringsRam
)
{
...
...
@@ -150,7 +148,7 @@ func (th *TxnHeader) decode(r io.ReaderAt, pos int64, tmpBuf *[txnHeaderFixSize]
// decodePrev reads and decodes transaction record header from a readerAt XXX from next ...
// pos: points to header begin XXX text
// no requirements are made to previous th state XXX text
func
(
th
*
TxnHeader
)
decodePrev
(
r
io
.
ReaderAt
,
pos
int64
,
tmpBuf
*
[
txnHeaderFixSize
]
byte
)
(
posPrev
int64
,
n
int
,
err
error
)
{
func
(
th
*
TxnHeader
)
decodePrev
(
r
io
.
ReaderAt
,
pos
int64
,
tmpBuf
*
[
txn
X
HeaderFixSize
]
byte
)
(
posPrev
int64
,
n
int
,
err
error
)
{
if
pos
==
4
{
// XXX 4 -> magicsize
panic
(
"no prev"
)
// TODO
}
...
...
@@ -180,12 +178,12 @@ func (th *TxnHeader) decodePrev(r io.ReaderAt, pos int64, tmpBuf *[txnHeaderFixS
// XXX do we need Decode when decode() is there?
func
(
th
*
TxnHeader
)
Decode
(
r
io
.
ReaderAt
,
pos
int64
)
(
n
int
,
err
error
)
{
var
tmpBuf
[
txnHeaderFixSize
]
byte
var
tmpBuf
[
txn
X
HeaderFixSize
]
byte
return
th
.
decode
(
r
,
pos
,
&
tmpBuf
)
}
func
(
th
*
TxnHeader
)
DecodePrev
(
r
io
.
ReaderAt
,
pos
int64
)
(
posPrev
int64
,
n
int
,
err
error
)
{
var
tmpBuf
[
txnHeaderFixSize
]
byte
var
tmpBuf
[
txn
X
HeaderFixSize
]
byte
return
th
.
decodePrev
(
r
,
pos
,
&
tmpBuf
)
}
...
...
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