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
4e0c9ad3
Commit
4e0c9ad3
authored
Apr 06, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
5ebd8119
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
15 deletions
+17
-15
wcfs/zblk.go
wcfs/zblk.go
+17
-15
No files found.
wcfs/zblk.go
View file @
4e0c9ad3
...
...
@@ -184,7 +184,7 @@ func (zb *ZBlk0) loadBlkData(ctx context.Context) (_ []byte, _ zodb.Tid, err err
type
ZData
struct
{
zodb
.
Persistent
//
XXX
py source uses bytes(buf) but on python2 it still results in str
//
NOTE
py source uses bytes(buf) but on python2 it still results in str
data
string
}
...
...
@@ -199,7 +199,6 @@ func (zd *zDataState) PyGetState() interface{} {
}
func
(
zd
*
zDataState
)
PySetState
(
pystate
interface
{})
error
{
//log.Printf("ZData.PySetState")
data
,
ok
:=
pystate
.
(
string
)
if
!
ok
{
return
fmt
.
Errorf
(
"expect str; got %s"
,
typeOf
(
pystate
))
...
...
@@ -228,7 +227,6 @@ func (zb *zBlk1State) PyGetState() interface{} {
}
func
(
zb
*
zBlk1State
)
PySetState
(
pystate
interface
{})
error
{
//log.Printf("ZBlk1.PySetState")
chunktab
,
ok
:=
pystate
.
(
*
btree
.
IOBTree
)
if
!
ok
{
return
fmt
.
Errorf
(
"expect IOBTree; got %s"
,
typeOf
(
pystate
))
...
...
@@ -266,8 +264,8 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) (_ []byte, _ zodb.Tid, err err
wg
:=
xsync
.
NewWorkGroup
(
ctx
)
// loadZData loads 1 ZData object into chunktab and leaves it activated.
loadZData
:=
func
(
ctx
context
.
Context
,
offset
int32
,
zd
*
ZData
)
error
{
err
:
=
zd
.
PActivate
(
ctx
)
loadZData
:=
func
(
ctx
context
.
Context
,
offset
int32
,
zd
*
ZData
)
(
err
error
)
{
err
=
zd
.
PActivate
(
ctx
)
if
err
!=
nil
{
return
err
}
...
...
@@ -277,32 +275,37 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) (_ []byte, _ zodb.Tid, err err
mu
.
Lock
()
defer
mu
.
Unlock
()
_
,
already
:=
chunktab
[
offset
]
if
already
{
return
fmt
.
Errorf
(
"duplicate offset %d"
,
offset
)
}
chunktab
[
offset
]
=
zd
return
nil
}
// loadBucket loads all ZData objects from leaf BTree bucket.
loadBucket
:=
func
(
ctx
context
.
Context
,
b
*
btree
.
IOBucket
)
error
{
err
:
=
b
.
PActivate
(
ctx
)
loadBucket
:=
func
(
ctx
context
.
Context
,
b
*
btree
.
IOBucket
)
(
err
error
)
{
err
=
b
.
PActivate
(
ctx
)
if
err
!=
nil
{
return
err
}
defer
b
.
PDeactivate
()
// go through all bucket key/v -> chunktab
// XXX off < 0 !ok
// XXX off + len > blksize !ok
defer
xerr
.
Contextf
(
&
err
,
"%s(%s)"
,
typeOf
(
b
),
b
.
POid
())
//fmt.Printf("\nbucket: %v\n\n", b.Entryv())
for
_
,
e
:=
range
b
.
Entryv
()
{
for
i
,
e
:=
range
b
.
Entryv
()
{
zd
,
ok
:=
e
.
Value
()
.
(
*
ZData
)
if
!
ok
{
return
fmt
.
Errorf
(
"
!ZData (%s)"
,
typeOf
(
e
.
Value
()))
return
fmt
.
Errorf
(
"
[%d]: !ZData (%s)"
,
i
,
typeOf
(
e
.
Value
()))
}
offset
:=
e
.
Key
()
if
offset
<
0
{
return
fmt
.
Errorf
(
"[%d]: offset < 0 (%d)"
,
i
,
offset
)
}
wg
.
Go
(
func
(
ctx
context
.
Context
)
error
{
return
loadZData
(
ctx
,
offset
,
zd
)
})
...
...
@@ -321,7 +324,6 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) (_ []byte, _ zodb.Tid, err err
defer
t
.
PDeactivate
()
//fmt.Printf("\nbtree: %v\n\n", t.Entryv())
for
_
,
e
:=
range
t
.
Entryv
()
{
switch
child
:=
e
.
Child
()
.
(
type
)
{
case
*
btree
.
IOBTree
:
...
...
@@ -348,7 +350,7 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) (_ []byte, _ zodb.Tid, err err
err
=
wg
.
Wait
()
if
err
!=
nil
{
return
nil
,
0
,
err
// XXX err ctx
return
nil
,
0
,
err
}
// empty .chunktab -> ø
...
...
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