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
675a9e86
Commit
675a9e86
authored
Mar 23, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
4615f651
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
t/neo/storage/fs1/cmd/fstail/fstail.go
t/neo/storage/fs1/cmd/fstail/fstail.go
+1
-0
t/neo/storage/fs1/filestorage.go
t/neo/storage/fs1/filestorage.go
+14
-6
No files found.
t/neo/storage/fs1/cmd/fstail/fstail.go
View file @
675a9e86
...
@@ -99,6 +99,7 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) {
...
@@ -99,6 +99,7 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) {
// read raw data inside transaction record
// read raw data inside transaction record
dataLen
:=
txnh
.
DataLen
()
dataLen
:=
txnh
.
DataLen
()
if
int64
(
cap
(
data
))
<
dataLen
{
if
int64
(
cap
(
data
))
<
dataLen
{
// TODO -> CeilPow2
data
=
make
([]
byte
,
dataLen
)
data
=
make
([]
byte
,
dataLen
)
}
else
{
}
else
{
data
=
data
[
:
dataLen
]
data
=
data
[
:
dataLen
]
...
...
t/neo/storage/fs1/filestorage.go
View file @
675a9e86
...
@@ -19,6 +19,7 @@ package fs1
...
@@ -19,6 +19,7 @@ package fs1
import
(
import
(
"encoding/binary"
"encoding/binary"
"fmt"
"fmt"
"math/bits"
"io"
"io"
"os"
"os"
...
@@ -233,7 +234,7 @@ const (
...
@@ -233,7 +234,7 @@ const (
// LenPrev >= TxnHeaderFixSize LenPrev was read/checked normally
// LenPrev >= TxnHeaderFixSize LenPrev was read/checked normally
func
(
txnh
*
TxnHeader
)
Load
(
r
io
.
ReaderAt
/* *os.File */
,
pos
int64
,
flags
TxnLoadFlags
)
error
{
func
(
txnh
*
TxnHeader
)
Load
(
r
io
.
ReaderAt
/* *os.File */
,
pos
int64
,
flags
TxnLoadFlags
)
error
{
if
cap
(
txnh
.
workMem
)
<
txnXHeaderFixSize
{
if
cap
(
txnh
.
workMem
)
<
txnXHeaderFixSize
{
txnh
.
workMem
=
make
([]
byte
,
txnXHeaderFixSize
)
txnh
.
workMem
=
make
([]
byte
,
txnXHeaderFixSize
,
256
/* to later avoid allocation for typical strings */
)
}
}
work
:=
txnh
.
workMem
[
:
txnXHeaderFixSize
]
work
:=
txnh
.
workMem
[
:
txnXHeaderFixSize
]
...
@@ -314,7 +315,7 @@ func (txnh *TxnHeader) Load(r io.ReaderAt /* *os.File */, pos int64, flags TxnLo
...
@@ -314,7 +315,7 @@ func (txnh *TxnHeader) Load(r io.ReaderAt /* *os.File */, pos int64, flags TxnLo
// NOTE we encode whole strings length into len(.workMem)
// NOTE we encode whole strings length into len(.workMem)
if
cap
(
txnh
.
workMem
)
<
lstr
{
if
cap
(
txnh
.
workMem
)
<
lstr
{
txnh
.
workMem
=
make
([]
byte
,
lstr
)
txnh
.
workMem
=
make
([]
byte
,
lstr
,
ceilPow2
(
uint64
(
lstr
))
)
}
else
{
}
else
{
txnh
.
workMem
=
txnh
.
workMem
[
:
lstr
]
txnh
.
workMem
=
txnh
.
workMem
[
:
lstr
]
}
}
...
@@ -548,13 +549,12 @@ func (dh *DataHeader) LoadBack(r io.ReaderAt /* *os.File */) error {
...
@@ -548,13 +549,12 @@ func (dh *DataHeader) LoadBack(r io.ReaderAt /* *os.File */) error {
bug
(
dh
,
"LoadBack() on non-backpointer data header"
)
bug
(
dh
,
"LoadBack() on non-backpointer data header"
)
}
}
var
xxx
[
8
]
byte
// XXX escapes ?
_
,
err
:=
r
.
ReadAt
(
dh
.
workMem
[
:
8
],
dh
.
Pos
+
DataHeaderSize
)
_
,
err
:=
r
.
ReadAt
(
xxx
[
:
],
dh
.
Pos
+
DataHeaderSize
)
if
err
!=
nil
{
if
err
!=
nil
{
return
dh
.
err
(
"read data"
,
noEOF
(
err
))
return
dh
.
err
(
"read data"
,
noEOF
(
err
))
}
}
backPos
:=
int64
(
binary
.
BigEndian
.
Uint64
(
xxx
[
:
]))
backPos
:=
int64
(
binary
.
BigEndian
.
Uint64
(
dh
.
workMem
[
0
:
]))
if
backPos
==
0
{
if
backPos
==
0
{
return
io
.
EOF
// oid was deleted
return
io
.
EOF
// oid was deleted
}
}
...
@@ -635,6 +635,12 @@ func (dh *DataHeader) loadNext(r io.ReaderAt /* *os.File */, txnh *TxnHeader) er
...
@@ -635,6 +635,12 @@ func (dh *DataHeader) loadNext(r io.ReaderAt /* *os.File */, txnh *TxnHeader) er
return
nil
return
nil
}
}
// XXX move me out of here
// ceilPow2 returns minimal y >= x, such as y = 2^i
func
ceilPow2
(
x
uint64
)
uint64
{
return
1
<<
uint
(
bits
.
Len64
(
x
))
}
// LoadData loads data for the data record taking backpointers into account
// LoadData loads data for the data record taking backpointers into account
// Data is loaded into *buf, which, if needed, is reallocated to hold all loading data size XXX
// Data is loaded into *buf, which, if needed, is reallocated to hold all loading data size XXX
// NOTE on success dh state is changed to data header of original data transaction
// NOTE on success dh state is changed to data header of original data transaction
...
@@ -654,7 +660,9 @@ func (dh *DataHeader) LoadData(r io.ReaderAt /* *os.File */, buf *[]byte) error
...
@@ -654,7 +660,9 @@ func (dh *DataHeader) LoadData(r io.ReaderAt /* *os.File */, buf *[]byte) error
// now read actual data
// now read actual data
if
int64
(
cap
(
*
buf
))
<
dh
.
DataLen
{
if
int64
(
cap
(
*
buf
))
<
dh
.
DataLen
{
*
buf
=
make
([]
byte
,
dh
.
DataLen
)
// ceilPow2 reduces much allocations but is still not enogh to
// remove them all from BenchmarkIterate
*
buf
=
make
([]
byte
,
dh
.
DataLen
,
ceilPow2
(
uint64
(
dh
.
DataLen
)))
}
else
{
}
else
{
*
buf
=
(
*
buf
)[
:
dh
.
DataLen
]
*
buf
=
(
*
buf
)[
:
dh
.
DataLen
]
}
}
...
...
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