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
8a1d3f7c
Commit
8a1d3f7c
authored
May 31, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
1cd48172
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
wcfs/δbtail_test.go
wcfs/δbtail_test.go
+55
-0
No files found.
wcfs/δbtail_test.go
View file @
8a1d3f7c
...
...
@@ -21,6 +21,7 @@ package main
import
(
"bufio"
"context"
"fmt"
"io"
"io/ioutil"
...
...
@@ -33,6 +34,7 @@ import (
"lab.nexedi.com/kirr/go123/exc"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb/btree"
)
// TreeGen represents connection to running `treegen trees` server.
...
...
@@ -141,6 +143,59 @@ func (tg *TreeGen) Commit(tree string) (_ zodb.Tid, err error) {
return
tid
,
nil
}
// GetTree loads LOBtree from zurl@at->obj<root>.
// Tree values must be ZBlk whose data is returned instead of references to ZBlk.
func
XGetTree
(
zurl
string
,
at
zodb
.
Tid
,
root
zodb
.
Oid
)
(
_
map
[
int64
]
string
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"%s: @%s: get tree %s"
,
zurl
,
at
,
root
)
X
:=
exc
.
Raiseif
ctx
:=
context
.
Background
()
// XXX pass IStorage to here instead of zurl?
zstor
,
err
:=
zodb
.
Open
(
ctx
,
zurl
,
&
zodb
.
OpenOptions
{
ReadOnly
:
true
});
X
(
err
)
defer
zstor
.
Close
()
// XXX err
db
:=
zodb
.
NewDB
(
zstor
)
defer
db
.
Close
()
// XXX err
// XXX +transaction
// XXX +defer txn.Abort()
zconn
,
err
:=
db
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
at
});
X
(
err
)
xztree
,
err
:=
zconn
.
Get
(
ctx
,
root
);
X
(
err
)
ztree
,
ok
:=
xztree
.
(
*
btree
.
LOBTree
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"expected LOBTree, got %s"
,
zodb
.
ClassOf
(
xztree
))
}
err
=
ztree
.
PActivate
(
ctx
);
X
(
err
)
defer
ztree
.
PDeactivate
()
zbucket
:=
ztree
.
FirstBucket
()
kv
:=
make
(
map
[
int64
]
string
)
for
zbucket
!=
nil
{
err
=
zbucket
.
PActivate
(
ctx
);
X
(
err
)
defer
zbucket
.
PDeactivate
()
for
_
,
__
:=
range
zbucket
.
Entryv
()
{
k
:=
__
.
Key
()
xv
:=
__
.
Value
()
zv
,
ok
:=
xv
.
(
zBlk
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"[%d] -> %s; want ZBlk"
,
k
,
typeOf
(
xv
))
}
data
,
_
,
err
:=
zv
.
loadBlkData
(
ctx
);
X
(
err
)
kv
[
k
]
=
string
(
data
)
}
zbucket
=
zbucket
.
Next
()
}
return
kv
,
nil
}
func
TestΔBTail
(
t
*
testing
.
T
)
{
X
:=
exc
.
Raiseif
...
...
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