Commit 198764da authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent de0b06ea
...@@ -79,8 +79,8 @@ import ( ...@@ -79,8 +79,8 @@ import (
"lab.nexedi.com/kirr/go123/xerr" "lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/neo/go/zodb" "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/xbtree/blib"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xzodb"
) )
const traceDiff = false const traceDiff = false
...@@ -950,32 +950,6 @@ func diffB(ctx context.Context, a, b *Bucket) (δ map[Key]ΔValue, err error) { ...@@ -950,32 +950,6 @@ func diffB(ctx context.Context, a, b *Bucket) (δ map[Key]ΔValue, err error) {
return δ, nil 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 { func (rn *nodeInRange) String() string {
done := " "; if rn.done { done = "*" } done := " "; if rn.done { done = "*" }
return fmt.Sprintf("%s%s%s", done, rn.keycov, vnode(rn.node)) return fmt.Sprintf("%s%s%s", done, rn.keycov, vnode(rn.node))
...@@ -995,6 +969,7 @@ func pop(nodeStk *[]*nodeInRange) *nodeInRange { ...@@ -995,6 +969,7 @@ func pop(nodeStk *[]*nodeInRange) *nodeInRange {
return top return top
} }
func tracefDiff(format string, argv ...interface{}) { func tracefDiff(format string, argv ...interface{}) {
if traceDiff { if traceDiff {
fmt.Printf(format, argv...) fmt.Printf(format, argv...)
......
...@@ -26,12 +26,15 @@ package xbtree ...@@ -26,12 +26,15 @@ package xbtree
import ( import (
"context"
"fmt" "fmt"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/neo/go/zodb" "lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/set" "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/xbtree/blib"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xzodb"
) )
...@@ -109,6 +112,32 @@ func vnode(node Node) string { ...@@ -109,6 +112,32 @@ func vnode(node Node) string {
return kind + node.POid().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 { func kstr(key Key) string {
return blib.KStr(key) return blib.KStr(key)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment