Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
8081df49
Commit
8081df49
authored
Sep 03, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a34148fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
wcfs/zblk.go
wcfs/zblk.go
+11
-9
No files found.
wcfs/zblk.go
View file @
8081df49
...
...
@@ -146,7 +146,7 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
//
// with all ZData being live.
var
mu
sync
.
Mutex
chunktab
:=
make
(
map
[
int
64
]
*
ZData
)
chunktab
:=
make
(
map
[
int
32
]
*
ZData
)
// on return deactivate all loaded ZData objects in chunktab
defer
func
()
{
...
...
@@ -159,7 +159,7 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
wg
,
ctx
:=
errgroup
.
WithContext
(
ctx
)
// loadZData loads 1 ZData object into chunktab and leaves it activated.
loadZData
:=
func
(
offset
int
64
,
zd
*
ZData
)
error
{
loadZData
:=
func
(
offset
int
32
,
zd
*
ZData
)
error
{
err
:=
zd
.
PActivate
(
ctx
)
if
err
!=
nil
{
return
err
...
...
@@ -199,7 +199,7 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
}
wg
.
Go
(
func
()
error
{
return
loadZData
(
int64
(
e
.
Key
()),
zd
)
// XXX cast
return
loadZData
(
e
.
Key
(),
zd
)
})
}
...
...
@@ -253,7 +253,7 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
}
// glue all chunks from chunktab
offv
:=
make
([]
int
64
,
0
,
len
(
chunktab
))
// ↑
offv
:=
make
([]
int
32
,
0
,
len
(
chunktab
))
// ↑
for
off
:=
range
(
chunktab
)
{
offv
=
append
(
offv
,
off
)
}
...
...
@@ -268,23 +268,23 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
// find out whole blk len via inspecting tail chunk
tailStart
:=
offv
[
len
(
offv
)
-
1
]
tailChunk
:=
chunktab
[
tailStart
]
blklen
:=
tailStart
+
int
64
(
len
(
tailChunk
.
data
))
blklen
:=
tailStart
+
int
32
(
len
(
tailChunk
.
data
))
// XXX overflow?
// whole buffer initialized as 0 + tail_chunk
blkdata
:=
make
([]
byte
,
blklen
)
copy
(
blkdata
[
tailStart
:
],
tailChunk
.
data
)
// go through all chunks besides tail and extract them
stop
:=
int
64
(
0
)
stop
:=
int
32
(
0
)
for
_
,
start
:=
range
offv
[
:
len
(
offv
)
-
1
]
{
chunk
:=
chunktab
[
start
]
if
!
(
start
>=
stop
)
{
// verify chunks don't overlap
panic
(
"!(start >= stop)"
)
// XXX
}
if
!
(
start
+
int
64
(
len
(
chunk
.
data
))
<=
int64
(
len
(
blkdata
)))
{
if
!
(
start
+
int
32
(
len
(
chunk
.
data
))
<=
int32
(
len
(
blkdata
)))
{
// XXX overflow?
panic
(
"blkdata overrun"
)
// XXX
}
stop
=
start
+
int
64
(
len
(
chunk
.
data
))
stop
=
start
+
int
32
(
len
(
chunk
.
data
))
// XXX overflow?
copy
(
blkdata
[
start
:
],
chunk
.
data
)
}
...
...
@@ -347,9 +347,11 @@ func (bf *zBigFileState) PySetState(pystate interface{}) (err error) {
func
init
()
{
t
:=
reflect
.
TypeOf
zodb
.
RegisterClass
(
zwendelin
+
".ZBlk"
,
t
(
ZBlk0
{}),
t
(
zBlk0State
{}))
zodb
.
RegisterClass
(
zwendelin
+
".ZBlk0"
,
t
(
ZBlk0
{}),
t
(
zBlk0State
{}))
zodb
.
RegisterClass
(
zwendelin
+
".ZBlk1"
,
t
(
ZBlk1
{}),
t
(
zBlk1State
{}))
zodb
.
RegisterClass
(
zwendelin
+
".ZData"
,
t
(
ZData
{}),
t
(
zDataState
{}))
zodb
.
RegisterClass
(
zwendelin
+
".ZBigFile"
,
t
(
ZBigFile
{}),
t
(
zBigFileState
{}))
// backward compatibility
zodb
.
RegisterClassAlias
(
zwendelin
+
".ZBlk"
,
zwendelin
+
".ZBlk0"
)
}
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