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
0d2aec32
Commit
0d2aec32
authored
Aug 10, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
bea140c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
6 deletions
+24
-6
wcfs/zblk.go
wcfs/zblk.go
+19
-5
wcfs/zblk_test.go
wcfs/zblk_test.go
+5
-1
No files found.
wcfs/zblk.go
View file @
0d2aec32
...
...
@@ -164,12 +164,17 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
if
err
!=
nil
{
return
err
}
// no PDeactivate
// no PDeactivate, zd remains live
fmt
.
Printf
(
"@%d -> zdata #%s (%d)
\n
"
,
offset
,
zd
.
POid
(),
len
(
zd
.
data
))
mu
.
Lock
()
defer
mu
.
Unlock
()
// XXX check dup keys?
// check dup keys
if
_
,
already
:=
chunktab
[
offset
];
already
{
panic
(
fmt
.
Sprintf
(
"already %v"
,
offset
))
// XXX
}
chunktab
[
offset
]
=
zd
return
nil
}
...
...
@@ -186,6 +191,7 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
// XXX off < 0 !ok
// XXX off + len > blksize !ok
fmt
.
Printf
(
"
\n
bucket: %v
\n
"
,
b
.
Entryv
())
for
_
,
e
:=
range
b
.
Entryv
()
{
zd
,
ok
:=
e
.
Value
()
.
(
*
ZData
)
if
!
ok
{
...
...
@@ -210,6 +216,8 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
}
defer
t
.
PDeactivate
()
fmt
.
Printf
(
"
\n
btree: %v
\n
"
,
t
.
Entryv
())
for
_
,
e
:=
range
t
.
Entryv
()
{
switch
child
:=
e
.
Child
()
.
(
type
)
{
case
*
btree
.
BTree
:
...
...
@@ -253,6 +261,9 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
return
offv
[
i
]
<
offv
[
j
]
})
fmt
.
Printf
(
"#chunktab: %d
\n
"
,
len
(
chunktab
))
fmt
.
Printf
(
"offv: %v
\n
"
,
offv
)
// find out whole blk len via inspecting tail chunk
tailStart
:=
offv
[
len
(
offv
)
-
1
]
...
...
@@ -265,11 +276,14 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
// go through all chunks besides tail and extract them
stop
:=
int64
(
0
)
_
=
stop
// XXX
for
_
,
start
:=
range
offv
[
:
len
(
offv
)
-
1
]
{
chunk
:=
chunktab
[
start
]
// XXX assert start >= stop // verify chunks don't overlap
// XXX assert start + len(chunk.data) <= len(blkdata)
if
!
(
start
>=
stop
)
{
// verify chunks don't overlap
panic
(
"!(start >= stop)"
)
// XXX
}
if
!
(
start
+
int64
(
len
(
chunk
.
data
))
<=
int64
(
len
(
blkdata
)))
{
panic
(
"blkdata overrun"
)
// XXX
}
stop
=
start
+
int64
(
len
(
chunk
.
data
))
copy
(
blkdata
[
start
:
],
chunk
.
data
)
}
...
...
wcfs/zblk_test.go
View file @
0d2aec32
...
...
@@ -24,6 +24,7 @@ package main
import
(
"context"
"encoding/binary"
"fmt"
"testing"
"lab.nexedi.com/kirr/go123/exc"
...
...
@@ -84,7 +85,10 @@ func TestZBlk(t *testing.T) {
assert
.
Equal
(
z0Data
,
data
,
"ZBlk0 data wrong"
)
z1Data
,
err
:=
z1
.
LoadBlkData
(
ctx
);
X
(
err
)
assert
.
Equal
(
z1Data
,
data
,
"ZBlk1 data wrong"
)
if
false
{
fmt
.
Printf
(
"%#v
\n
"
,
z1Data
)
}
assert
.
Equal
(
z1Data
[
:
20
],
data
[
:
20
],
"ZBlk1 data wrong"
)
...
...
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