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
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) {
// read raw data inside transaction record
dataLen
:=
txnh
.
DataLen
()
if
int64
(
cap
(
data
))
<
dataLen
{
// TODO -> CeilPow2
data
=
make
([]
byte
,
dataLen
)
}
else
{
data
=
data
[
:
dataLen
]
...
...
t/neo/storage/fs1/filestorage.go
View file @
675a9e86
...
...
@@ -19,6 +19,7 @@ package fs1
import
(
"encoding/binary"
"fmt"
"math/bits"
"io"
"os"
...
...
@@ -233,7 +234,7 @@ const (
// LenPrev >= TxnHeaderFixSize LenPrev was read/checked normally
func
(
txnh
*
TxnHeader
)
Load
(
r
io
.
ReaderAt
/* *os.File */
,
pos
int64
,
flags
TxnLoadFlags
)
error
{
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
]
...
...
@@ -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)
if
cap
(
txnh
.
workMem
)
<
lstr
{
txnh
.
workMem
=
make
([]
byte
,
lstr
)
txnh
.
workMem
=
make
([]
byte
,
lstr
,
ceilPow2
(
uint64
(
lstr
))
)
}
else
{
txnh
.
workMem
=
txnh
.
workMem
[
:
lstr
]
}
...
...
@@ -548,13 +549,12 @@ func (dh *DataHeader) LoadBack(r io.ReaderAt /* *os.File */) error {
bug
(
dh
,
"LoadBack() on non-backpointer data header"
)
}
var
xxx
[
8
]
byte
// XXX escapes ?
_
,
err
:=
r
.
ReadAt
(
xxx
[
:
],
dh
.
Pos
+
DataHeaderSize
)
_
,
err
:=
r
.
ReadAt
(
dh
.
workMem
[
:
8
],
dh
.
Pos
+
DataHeaderSize
)
if
err
!=
nil
{
return
dh
.
err
(
"read data"
,
noEOF
(
err
))
}
backPos
:=
int64
(
binary
.
BigEndian
.
Uint64
(
xxx
[
:
]))
backPos
:=
int64
(
binary
.
BigEndian
.
Uint64
(
dh
.
workMem
[
0
:
]))
if
backPos
==
0
{
return
io
.
EOF
// oid was deleted
}
...
...
@@ -635,6 +635,12 @@ func (dh *DataHeader) loadNext(r io.ReaderAt /* *os.File */, txnh *TxnHeader) er
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
// 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
...
...
@@ -654,7 +660,9 @@ func (dh *DataHeader) LoadData(r io.ReaderAt /* *os.File */, buf *[]byte) error
// now read actual data
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
{
*
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