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
8c2aea28
Commit
8c2aea28
authored
Jul 12, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
1c30f2bb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
2 deletions
+60
-2
wcfs/internal/xbtree/treediff.go
wcfs/internal/xbtree/treediff.go
+1
-1
wcfs/internal/xbtree/δbtail.go
wcfs/internal/xbtree/δbtail.go
+5
-0
wcfs/internal/zdata/δftail.go
wcfs/internal/zdata/δftail.go
+54
-1
No files found.
wcfs/internal/xbtree/treediff.go
View file @
8c2aea28
...
@@ -956,7 +956,7 @@ func zgetNodeOrNil(ctx context.Context, zconn *zodb.Connection, oid zodb.Oid) (n
...
@@ -956,7 +956,7 @@ func zgetNodeOrNil(ctx context.Context, zconn *zodb.Connection, oid zodb.Oid) (n
defer
xerr
.
Contextf
(
&
err
,
"getnode %s@%s"
,
oid
,
zconn
.
At
())
defer
xerr
.
Contextf
(
&
err
,
"getnode %s@%s"
,
oid
,
zconn
.
At
())
xnode
,
err
:=
xzodb
.
ZGetOrNil
(
ctx
,
zconn
,
oid
)
xnode
,
err
:=
xzodb
.
ZGetOrNil
(
ctx
,
zconn
,
oid
)
if
xnode
==
nil
||
err
!=
nil
{
if
xnode
==
nil
||
err
!=
nil
{
return
n
ode
,
err
return
n
il
,
err
}
}
node
,
ok
:=
xnode
.
(
Node
)
node
,
ok
:=
xnode
.
(
Node
)
...
...
wcfs/internal/xbtree/δbtail.go
View file @
8c2aea28
...
@@ -874,6 +874,11 @@ func (δBtail *ΔBtail) ΔZtail() /*readonly*/*zodb.ΔTail {
...
@@ -874,6 +874,11 @@ func (δBtail *ΔBtail) ΔZtail() /*readonly*/*zodb.ΔTail {
return
δBtail
.
δZtail
return
δBtail
.
δZtail
}
}
// DB returns database handle that δBtail is using to access ZODB.
func
(
δBtail
*
ΔBtail
)
DB
()
*
zodb
.
DB
{
return
δBtail
.
db
}
func
tracefΔBtail
(
format
string
,
argv
...
interface
{})
{
func
tracefΔBtail
(
format
string
,
argv
...
interface
{})
{
if
traceΔBtail
{
if
traceΔBtail
{
...
...
wcfs/internal/zdata/δftail.go
View file @
8c2aea28
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"fmt"
"fmt"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/neo/go/transaction"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb/btree"
"lab.nexedi.com/kirr/neo/go/zodb/btree"
...
@@ -213,6 +214,8 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
...
@@ -213,6 +214,8 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
// XXX verify zhead.At() == δFtail.Head()
// XXX verify zhead.At() == δFtail.Head()
// XXX locking
// XXX locking
headOld
:=
δFtail
.
Head
()
δB
,
err
:=
δFtail
.
δBtail
.
Update
(
δZ
)
δB
,
err
:=
δFtail
.
δBtail
.
Update
(
δZ
)
if
err
!=
nil
{
if
err
!=
nil
{
return
ΔF
{},
err
return
ΔF
{},
err
...
@@ -283,6 +286,14 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
...
@@ -283,6 +286,14 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
// TODO check that .blksize and .blktab (it is only
// TODO check that .blksize and .blktab (it is only
// persistent reference) do not change. XXX -> EPOCH
// persistent reference) do not change. XXX -> EPOCH
δ
,
err
:=
zfilediff
(
δFtail
.
δBtail
.
DB
(),
oid
,
headOld
,
δZ
.
Tid
)
if
err
!=
nil
{
return
ΔF
{},
err
}
// XXX
fmt
.
Printf
(
"δZBigFile: %v
\n
"
,
δ
)
return
ΔF
{},
fmt
.
Errorf
(
"ZBigFile<%s> changed @%s"
,
oid
,
δZ
.
Tid
)
return
ΔF
{},
fmt
.
Errorf
(
"ZBigFile<%s> changed @%s"
,
oid
,
δZ
.
Tid
)
}
}
...
@@ -509,12 +520,37 @@ func (δFtail *ΔFtail) LastBlkRev(ctx context.Context, zf *ZBigFile, blk int64,
...
@@ -509,12 +520,37 @@ func (δFtail *ΔFtail) LastBlkRev(ctx context.Context, zf *ZBigFile, blk int64,
}
}
// ----------------------------------------
//
diffF computes direct differece in between two ZBigFile objects.
//
zfilediff ... XXX
type
_ΔZBigFile
struct
{
type
_ΔZBigFile
struct
{
blksizeOld
,
blksizeNew
int64
blksizeOld
,
blksizeNew
int64
blktabOld
,
blktabNew
zodb
.
Oid
blktabOld
,
blktabNew
zodb
.
Oid
}
}
func
zfilediff
(
db
*
zodb
.
DB
,
foid
zodb
.
Oid
,
old
,
new
zodb
.
Tid
)
(
δ
*
_ΔZBigFile
,
err
error
)
{
txn
,
ctx
:=
transaction
.
New
(
context
.
TODO
())
// XXX - merge in ctx arg?
defer
txn
.
Abort
()
zconnOld
,
err
:=
db
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
old
})
if
err
!=
nil
{
return
nil
,
err
}
zconnNew
,
err
:=
db
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
new
})
if
err
!=
nil
{
return
nil
,
err
}
a
,
err1
:=
zgetFileOrNil
(
ctx
,
zconnOld
,
foid
)
b
,
err2
:=
zgetFileOrNil
(
ctx
,
zconnNew
,
foid
)
err
=
xerr
.
Merge
(
err1
,
err2
)
if
err
!=
nil
{
return
nil
,
err
}
return
diffF
(
ctx
,
a
,
b
)
}
// diffF computes direct difference in between two ZBigFile objects.
func
diffF
(
ctx
context
.
Context
,
a
,
b
*
ZBigFile
)
(
δ
*
_ΔZBigFile
,
err
error
)
{
func
diffF
(
ctx
context
.
Context
,
a
,
b
*
ZBigFile
)
(
δ
*
_ΔZBigFile
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"diffF %s %s"
,
xzodb
.
XidOf
(
a
),
xzodb
.
XidOf
(
b
))
defer
xerr
.
Contextf
(
&
err
,
"diffF %s %s"
,
xzodb
.
XidOf
(
a
),
xzodb
.
XidOf
(
b
))
...
@@ -542,3 +578,20 @@ func diffF(ctx context.Context, a, b *ZBigFile) (δ *_ΔZBigFile, err error) {
...
@@ -542,3 +578,20 @@ func diffF(ctx context.Context, a, b *ZBigFile) (δ *_ΔZBigFile, err error) {
// XXX return δ=nil if no change?
// XXX return δ=nil if no change?
return
δ
,
nil
return
δ
,
nil
}
}
// zgetFileOrNil returns ZBigFile corresponding to zconn.Get(oid) .
// if the file does not exist, (nil, ok) is returned.
func
zgetFileOrNil
(
ctx
context
.
Context
,
zconn
*
zodb
.
Connection
,
oid
zodb
.
Oid
)
(
zfile
*
ZBigFile
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"getfile %s@%s"
,
oid
,
zconn
.
At
())
xfile
,
err
:=
xzodb
.
ZGetOrNil
(
ctx
,
zconn
,
oid
)
if
xfile
==
nil
||
err
!=
nil
{
return
nil
,
err
}
zfile
,
ok
:=
xfile
.
(
*
ZBigFile
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"unexpected type: %s"
,
zodb
.
ClassOf
(
xfile
))
}
return
zfile
,
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