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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
wendelin.core
Commits
313bc6ab
Commit
313bc6ab
authored
Sep 04, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
8081df49
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
22 deletions
+18
-22
wcfs/zblk.go
wcfs/zblk.go
+14
-22
wcfs/zblk_test.go
wcfs/zblk_test.go
+4
-0
No files found.
wcfs/zblk.go
View file @
313bc6ab
...
...
@@ -117,7 +117,7 @@ func (zb *zBlk1State) DropState() {
func
(
zb
*
zBlk1State
)
PySetState
(
pystate
interface
{})
error
{
chunktab
,
ok
:=
pystate
.
(
*
btree
.
IOBTree
)
if
!
ok
{
//return fmt.Errorf("expect IOBTree; got %T", pystate)
//return fmt.Errorf("expect IOBTree; got %T", pystate)
XXX no details for Broken
return
fmt
.
Errorf
(
"expect IOBTree; got %#v"
,
pystate
)
}
...
...
@@ -134,12 +134,6 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
}
defer
zb
.
PDeactivate
()
// // empty .chunktab -> ø
// ev := zb.chunktab.Entryv()
// if len(ev) == 0 {
// return nil, nil
// }
// get to all ZData objects; activate them and build
//
// {} offset -> ZData
...
...
@@ -148,7 +142,7 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
var
mu
sync
.
Mutex
chunktab
:=
make
(
map
[
int32
]
*
ZData
)
// on return deactivate all
loaded ZData objects
in chunktab
// on return deactivate all
ZData objects loaded
in chunktab
defer
func
()
{
for
_
,
zd
:=
range
chunktab
{
zd
.
PDeactivate
()
...
...
@@ -166,15 +160,11 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
}
// no PDeactivate, zd remains live
fmt
.
Printf
(
"@%d -> zdata #%s (%d)
\n
"
,
offset
,
zd
.
POid
(),
len
(
zd
.
data
))
//
fmt.Printf("@%d -> zdata #%s (%d)\n", offset, zd.POid(), len(zd.data))
mu
.
Lock
()
defer
mu
.
Unlock
()
// check dup keys
if
_
,
already
:=
chunktab
[
offset
];
already
{
panic
(
fmt
.
Sprintf
(
"already %v"
,
offset
))
// XXX
}
chunktab
[
offset
]
=
zd
return
nil
}
...
...
@@ -187,19 +177,21 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
}
defer
b
.
PDeactivate
()
// XXX go through all bucket key/v -> chunktab
// go through all bucket key/v -> chunktab
// XXX off < 0 !ok
// XXX off + len > blksize !ok
fmt
.
Printf
(
"
\n
bucket: %v
\n
"
,
b
.
Entryv
())
//fmt.Printf("\nbucket: %v\n
\n", b.Entryv())
for
_
,
e
:=
range
b
.
Entryv
()
{
zd
,
ok
:=
e
.
Value
()
.
(
*
ZData
)
if
!
ok
{
return
fmt
.
Errorf
(
"!ZData (%T)"
,
e
.
Value
())
// XXX
}
offset
:=
e
.
Key
()
wg
.
Go
(
func
()
error
{
return
loadZData
(
e
.
Key
()
,
zd
)
return
loadZData
(
offset
,
zd
)
})
}
...
...
@@ -216,7 +208,7 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
}
defer
t
.
PDeactivate
()
fmt
.
Printf
(
"
\n
btree: %v
\n
"
,
t
.
Entryv
())
//fmt.Printf("\nbtree: %v\n
\n", t.Entryv())
for
_
,
e
:=
range
t
.
Entryv
()
{
switch
child
:=
e
.
Child
()
.
(
type
)
{
...
...
@@ -231,7 +223,7 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
})
default
:
panic
(
0
)
// XXX
panic
(
fmt
.
Sprintf
(
"IOBTree has %T child"
,
child
))
}
}
...
...
@@ -261,8 +253,8 @@ 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
)
//
fmt.Printf("#chunktab: %d\n", len(chunktab))
//
fmt.Printf("offv: %v\n", offv)
// find out whole blk len via inspecting tail chunk
...
...
@@ -279,10 +271,10 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
for
_
,
start
:=
range
offv
[
:
len
(
offv
)
-
1
]
{
chunk
:=
chunktab
[
start
]
if
!
(
start
>=
stop
)
{
// verify chunks don't overlap
panic
(
"!(start >= stop)"
)
// XXX
return
nil
,
fmt
.
Errorf
(
"!(start >= stop)"
)
// XXX
}
if
!
(
start
+
int32
(
len
(
chunk
.
data
))
<=
int32
(
len
(
blkdata
)))
{
// XXX overflow?
panic
(
"blkdata overrun"
)
// XXX
return
nil
,
fmt
.
Errorf
(
"blkdata overrun"
)
// XXX
}
stop
=
start
+
int32
(
len
(
chunk
.
data
))
// XXX overflow?
copy
(
blkdata
[
start
:
],
chunk
.
data
)
...
...
wcfs/zblk_test.go
View file @
313bc6ab
...
...
@@ -21,6 +21,10 @@ package main
//go:generate ./testdata/zblk_test_gen.py
// XXX do not commit 4MB (ZBlk*) to testdata - generate them at test runtime.
// XXX save into git only small-sized ZBlk0 and ZBlk1 so that we can be sure
// their format does not change.
import
(
"context"
"encoding/binary"
...
...
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