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
ca074426
Commit
ca074426
authored
Oct 07, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
b74dda09
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
56 deletions
+3
-56
wcfs/internal/xbtree/xbtreetest/init/init.go
wcfs/internal/xbtree/xbtreetest/init/init.go
+1
-40
wcfs/internal/xbtree/xbtreetest/zdata.go
wcfs/internal/xbtree/xbtreetest/zdata.go
+2
-16
No files found.
wcfs/internal/xbtree/xbtreetest/init/init.go
View file @
ca074426
...
...
@@ -43,50 +43,11 @@ type KeyRange = xbtreetest.KeyRange
type
ZBlk
=
zdata
.
ZBlk
// ztreeGetBlk returns ztree[k] and tree path that lead to this block.
// XXX +return blkRevMax and use it ?
func
ztreeGetBlk
(
ctx
context
.
Context
,
ztree
*
Tree
,
k
Key
)
(
zblk
ZBlk
,
ok
bool
,
path
[]
Node
,
err
error
)
{
path
=
[]
Node
{}
xzblk
,
ok
,
err
:=
ztree
.
VGet
(
ctx
,
k
,
func
(
node
Node
,
keycov
KeyRange
)
{
// XXX use keycov
path
=
append
(
path
,
node
)
})
if
err
!=
nil
{
return
nil
,
false
,
nil
,
err
}
if
ok
{
zblk
,
ok
=
xzblk
.
(
ZBlk
)
if
!
ok
{
return
nil
,
false
,
nil
,
fmt
.
Errorf
(
"expect ZBlk*; got %s"
,
xzodb
.
TypeOf
(
xzblk
))
// XXX errctx
}
}
return
zblk
,
ok
,
path
,
nil
}
func
init
()
{
xbtreetest
.
ZTreeGetBlkData
=
_ZTreeGetBlkData
xbtreetest
.
ZGetBlkData
=
_ZGetBlkData
xbtreetest
.
ZGetBlkData
=
_ZGetBlkData
}
// _ZTreeGetBlkData returns block data from block pointed to by ztree[k].
func
_ZTreeGetBlkData
(
ctx
context
.
Context
,
ztree
*
Tree
,
k
Key
)
(
data
string
,
ok
bool
,
path
[]
Node
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"@%s: tree<%s>: get blkdata from [%d]"
,
ztree
.
PJar
()
.
At
(),
ztree
.
POid
(),
k
)
zblk
,
ok
,
path
,
err
:=
ztreeGetBlk
(
ctx
,
ztree
,
k
)
if
err
!=
nil
||
!
ok
{
return
""
,
ok
,
path
,
err
}
bdata
,
_
,
err
:=
zblk
.
LoadBlkData
(
ctx
)
if
err
!=
nil
{
return
""
,
false
,
nil
,
err
}
return
string
(
bdata
),
true
,
path
,
nil
}
// _ZGetBlkData loads block data from ZBlk object specified by its oid.
func
_ZGetBlkData
(
ctx
context
.
Context
,
zconn
*
zodb
.
Connection
,
zblkOid
zodb
.
Oid
)
(
data
string
,
err
error
)
{
...
...
wcfs/internal/xbtree/xbtreetest/zdata.go
View file @
ca074426
...
...
@@ -25,19 +25,17 @@ import (
"lab.nexedi.com/kirr/go123/exc"
"lab.nexedi.com/kirr/neo/go/transaction"
"lab.nexedi.com/kirr/neo/go/zodb"
_
"lab.nexedi.com/kirr/neo/go/zodb/wks"
)
// ZBlk-related functions are imported at runtime by package xbtreetest/init
var
(
ZTreeGetBlkData
func
(
context
.
Context
,
*
Tree
,
Key
)
(
string
,
bool
,
[]
Node
,
error
)
ZGetBlkData
func
(
context
.
Context
,
*
zodb
.
Connection
,
zodb
.
Oid
)
(
string
,
error
)
ZGetBlkData
func
(
context
.
Context
,
*
zodb
.
Connection
,
zodb
.
Oid
)
(
string
,
error
)
)
func
zassertInitDone
()
{
if
Z
Tree
GetBlkData
==
nil
{
if
ZGetBlkData
==
nil
{
panic
(
"xbtreetest/zdata not initialized -> import xbtreetest/init to fix"
)
}
}
...
...
@@ -54,15 +52,3 @@ func xzgetBlkData(ctx context.Context, zconn *zodb.Connection, zblkOid zodb.Oid)
data
,
err
:=
ZGetBlkData
(
ctx
,
zconn
,
zblkOid
);
X
(
err
)
return
string
(
data
)
}
// xzgetBlkDataAt loads block data from ZBlk object specified by oid@at.
func
xzgetBlkDataAt
(
db
*
zodb
.
DB
,
zblkOid
zodb
.
Oid
,
at
zodb
.
Tid
)
string
{
zassertInitDone
()
X
:=
exc
.
Raiseif
txn
,
ctx
:=
transaction
.
New
(
context
.
Background
())
defer
txn
.
Abort
()
zconn
,
err
:=
db
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
at
});
X
(
err
)
return
xzgetBlkData
(
ctx
,
zconn
,
zblkOid
)
}
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