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
198764da
Commit
198764da
authored
3 years ago
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
de0b06ea
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
27 deletions
+31
-27
wcfs/internal/xbtree/treediff.go
wcfs/internal/xbtree/treediff.go
+2
-27
wcfs/internal/xbtree/xbtree.go
wcfs/internal/xbtree/xbtree.go
+29
-0
No files found.
wcfs/internal/xbtree/treediff.go
View file @
198764da
...
...
@@ -79,8 +79,8 @@ import (
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xzodb"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xbtree/blib"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xzodb"
)
const
traceDiff
=
false
...
...
@@ -950,32 +950,6 @@ func diffB(ctx context.Context, a, b *Bucket) (δ map[Key]ΔValue, err error) {
return
δ
,
nil
}
// zgetNodeOrNil returns btree node corresponding to zconn.Get(oid) .
// if the node does not exist, (nil, ok) is returned.
func
zgetNodeOrNil
(
ctx
context
.
Context
,
zconn
*
zodb
.
Connection
,
oid
zodb
.
Oid
)
(
node
Node
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"getnode %s@%s"
,
oid
,
zconn
.
At
())
xnode
,
err
:=
xzodb
.
ZGetOrNil
(
ctx
,
zconn
,
oid
)
if
xnode
==
nil
||
err
!=
nil
{
return
nil
,
err
}
node
,
ok
:=
xnode
.
(
Node
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"unexpected type: %s"
,
zodb
.
ClassOf
(
xnode
))
}
return
node
,
nil
}
// vOid returns OID of a value object.
// it is an error if value is not persistent object.
func
vOid
(
xvalue
interface
{})
(
zodb
.
Oid
,
error
)
{
value
,
ok
:=
xvalue
.
(
zodb
.
IPersistent
)
if
!
ok
{
return
zodb
.
InvalidOid
,
fmt
.
Errorf
(
"%T is not a persitent object"
,
xvalue
)
}
return
value
.
POid
(),
nil
}
func
(
rn
*
nodeInRange
)
String
()
string
{
done
:=
" "
;
if
rn
.
done
{
done
=
"*"
}
return
fmt
.
Sprintf
(
"%s%s%s"
,
done
,
rn
.
keycov
,
vnode
(
rn
.
node
))
...
...
@@ -995,6 +969,7 @@ func pop(nodeStk *[]*nodeInRange) *nodeInRange {
return
top
}
func
tracefDiff
(
format
string
,
argv
...
interface
{})
{
if
traceDiff
{
fmt
.
Printf
(
format
,
argv
...
)
...
...
This diff is collapsed.
Click to expand it.
wcfs/internal/xbtree/xbtree.go
View file @
198764da
...
...
@@ -26,12 +26,15 @@ package xbtree
import
(
"context"
"fmt"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/set"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xbtree/blib"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xzodb"
)
...
...
@@ -109,6 +112,32 @@ func vnode(node Node) string {
return
kind
+
node
.
POid
()
.
String
()
}
// vOid returns OID of a value object.
// it is an error if value is not persistent object.
func
vOid
(
xvalue
interface
{})
(
zodb
.
Oid
,
error
)
{
value
,
ok
:=
xvalue
.
(
zodb
.
IPersistent
)
if
!
ok
{
return
zodb
.
InvalidOid
,
fmt
.
Errorf
(
"%T is not a persitent object"
,
xvalue
)
}
return
value
.
POid
(),
nil
}
// zgetNodeOrNil returns btree node corresponding to zconn.Get(oid) .
// if the node does not exist, (nil, ok) is returned.
func
zgetNodeOrNil
(
ctx
context
.
Context
,
zconn
*
zodb
.
Connection
,
oid
zodb
.
Oid
)
(
node
Node
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"getnode %s@%s"
,
oid
,
zconn
.
At
())
xnode
,
err
:=
xzodb
.
ZGetOrNil
(
ctx
,
zconn
,
oid
)
if
xnode
==
nil
||
err
!=
nil
{
return
nil
,
err
}
node
,
ok
:=
xnode
.
(
Node
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"unexpected type: %s"
,
zodb
.
ClassOf
(
xnode
))
}
return
node
,
nil
}
func
kstr
(
key
Key
)
string
{
return
blib
.
KStr
(
key
)
...
...
This diff is collapsed.
Click to expand it.
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