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
40f2105f
Commit
40f2105f
authored
Jul 12, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
71c8613d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
21 deletions
+66
-21
wcfs/internal/xbtree/treediff.go
wcfs/internal/xbtree/treediff.go
+4
-21
wcfs/internal/xzodb/xzodb.go
wcfs/internal/xzodb/xzodb.go
+28
-0
wcfs/internal/zdata/δftail.go
wcfs/internal/zdata/δftail.go
+34
-0
No files found.
wcfs/internal/xbtree/treediff.go
View file @
40f2105f
...
@@ -952,34 +952,17 @@ func diffB(ctx context.Context, a, b *Bucket) (δ map[Key]ΔValue, err error) {
...
@@ -952,34 +952,17 @@ func diffB(ctx context.Context, a, b *Bucket) (δ map[Key]ΔValue, err error) {
// zgetNodeOrNil returns btree node corresponding to zconn.Get(oid) .
// zgetNodeOrNil returns btree node corresponding to zconn.Get(oid) .
// if the node does not exist, (nil, ok) is returned.
// if the node does not exist, (nil, ok) is returned.
func
zgetNodeOrNil
(
ctx
context
.
Context
,
zconn
*
zodb
.
Connection
,
oid
zodb
.
Oid
)
(
_
Node
,
err
error
)
{
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
())
defer
xerr
.
Contextf
(
&
err
,
"getnode %s@%s"
,
oid
,
zconn
.
At
())
xnode
,
err
:=
zconn
.
Get
(
ctx
,
oid
)
xnode
,
err
:=
xzodb
.
ZGetOrNil
(
ctx
,
zconn
,
oid
)
if
err
!=
nil
{
if
xnode
==
nil
||
err
!=
nil
{
if
xzodb
.
IsErrNoData
(
err
)
{
return
node
,
err
err
=
nil
}
return
nil
,
err
}
}
node
,
ok
:=
xnode
.
(
Node
)
node
,
ok
:=
xnode
.
(
Node
)
if
!
ok
{
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"unexpected type: %s"
,
zodb
.
ClassOf
(
xnode
))
return
nil
,
fmt
.
Errorf
(
"unexpected type: %s"
,
zodb
.
ClassOf
(
xnode
))
}
}
// activate the node to find out it really exists
// after removal on storage, the object might have stayed in Connection
// cache due to e.g. PCachePinObject, and it will be PActivate that
// will return "deleted" error.
err
=
node
.
PActivate
(
ctx
)
if
err
!=
nil
{
if
xzodb
.
IsErrNoData
(
err
)
{
return
nil
,
nil
}
return
nil
,
err
}
node
.
PDeactivate
()
return
node
,
nil
return
node
,
nil
}
}
...
...
wcfs/internal/xzodb/xzodb.go
View file @
40f2105f
...
@@ -26,6 +26,7 @@ import (
...
@@ -26,6 +26,7 @@ import (
"fmt"
"fmt"
"lab.nexedi.com/kirr/go123/xcontext"
"lab.nexedi.com/kirr/go123/xcontext"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/neo/go/transaction"
"lab.nexedi.com/kirr/neo/go/transaction"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb"
...
@@ -82,6 +83,33 @@ func ZOpen(ctx context.Context, zdb *zodb.DB, zopt *zodb.ConnOptions) (_ *ZConn,
...
@@ -82,6 +83,33 @@ func ZOpen(ctx context.Context, zdb *zodb.DB, zopt *zodb.ConnOptions) (_ *ZConn,
},
nil
},
nil
}
}
// ZGetOrNil returns zconn.Get(oid), or (nil,ok) if the object does not exist.
func
ZGetOrNil
(
ctx
context
.
Context
,
zconn
*
zodb
.
Connection
,
oid
zodb
.
Oid
)
(
_
zodb
.
IPersistent
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"zget %s@%s"
,
oid
,
zconn
.
At
())
obj
,
err
:=
zconn
.
Get
(
ctx
,
oid
)
if
err
!=
nil
{
if
IsErrNoData
(
err
)
{
err
=
nil
}
return
nil
,
err
}
// activate the object to find out it really exists
// after removal on storage, the object might have stayed in Connection
// cache due to e.g. PCachePinObject, and it will be PActivate that
// will return "deleted" error.
err
=
obj
.
PActivate
(
ctx
)
if
err
!=
nil
{
if
IsErrNoData
(
err
)
{
return
nil
,
nil
}
return
nil
,
err
}
obj
.
PDeactivate
()
return
obj
,
nil
}
// IsErrNoData returns whether err is due to NoDataError or NoObjectError.
// IsErrNoData returns whether err is due to NoDataError or NoObjectError.
func
IsErrNoData
(
err
error
)
bool
{
func
IsErrNoData
(
err
error
)
bool
{
var
eNoData
*
zodb
.
NoDataError
var
eNoData
*
zodb
.
NoDataError
...
...
wcfs/internal/zdata/δftail.go
View file @
40f2105f
...
@@ -507,3 +507,37 @@ func (δFtail *ΔFtail) LastBlkRev(ctx context.Context, zf *ZBigFile, blk int64,
...
@@ -507,3 +507,37 @@ func (δFtail *ΔFtail) LastBlkRev(ctx context.Context, zf *ZBigFile, blk int64,
return
tabRev
,
tabRevExact
return
tabRev
,
tabRevExact
}
}
}
}
// diffF computes direct differece in between two ZBigFiles.
type
_ΔZBigFile
struct
{
blksizeOld
,
blksizeNew
int64
blktabOld
,
blktabNew
zodb
.
Oid
}
func
diffF
(
ctx
context
.
Context
,
a
,
b
*
ZBigFile
)
(
δ
*
_ΔZBigFile
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"diffF %s %s"
,
xidOf
(
a
),
xidOf
(
b
))
δ
=
&
_ΔZBigFile
{}
if
a
==
nil
{
δ
.
blksizeOld
=
-
1
δ
.
blktabOld
=
xbtree
.
VDEL
}
else
{
err
=
a
.
PActivate
(
ctx
);
if
err
!=
nil
{
return
nil
,
err
}
defer
a
.
PDeactivate
()
δ
.
blksizeOld
=
a
.
blksize
δ
.
blktabOld
=
a
.
blktab
.
POid
()
}
if
b
==
nil
{
δ
.
blksizeNew
=
-
1
δ
.
blktabNew
=
xbtree
.
VDEL
}
else
{
err
=
b
.
PActivate
(
ctx
);
if
err
!=
nil
{
return
nil
,
err
}
defer
b
.
PDeactivate
()
δ
.
blksizeNew
=
b
.
blksize
δ
.
blktabNew
=
b
.
blktab
.
POid
()
}
return
δ
,
nil
}
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