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
4a7e9275
Commit
4a7e9275
authored
Jun 17, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f2dde045
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
8 deletions
+36
-8
wcfs/δbtail.go
wcfs/δbtail.go
+36
-8
No files found.
wcfs/δbtail.go
View file @
4a7e9275
...
...
@@ -347,28 +347,42 @@ func (δBtail *ΔBtail) treediff(ctx context.Context, root zodb.Oid, δZT SetOid
case
*
Tree
:
b
:=
xb
.
(
*
Tree
)
// must not fail
// TODO handle
_
=
b
}
}
return
nil
,
nil
// XXX stub
}
// diffB computes difference in between two
buckets
.
// diffB computes difference in between two
revisions of a bucket
.
// the buckets must be already activated
func
diffB
(
a
,
b
*
Bucket
)
map
[
Key
]
Value
{
av
:=
a
.
Entryv
()
bv
:=
b
.
Entryv
()
δ
:=
map
[
Key
]
Value
{}
func
diffB
(
a
,
b
*
Bucket
)
(
δ
map
[
Key
]
Value
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"diffB %s"
,
a
.
POid
())
if
a
.
POid
()
!=
b
.
POid
()
{
panic
(
"different buckets"
)
}
av
:=
a
.
Entryv
()
// key↑
bv
:=
b
.
Entryv
()
// key↑
δ
=
map
[
Key
]
Value
{}
for
len
(
av
)
>
0
||
len
(
bv
)
>
0
{
ka
,
va
:=
KeyMax
,
VDEL
kb
,
vb
:=
KeyMax
,
VDEL
if
len
(
av
)
>
0
{
ka
,
va
=
av
[
0
]
.
Key
(),
av
[
0
]
.
Value
()
ka
=
av
[
0
]
.
Key
()
va
,
err
=
vOid
(
av
[
0
]
.
Value
())
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"a[%v]: %s"
,
ka
,
err
)
}
}
if
len
(
bv
)
>
0
{
kb
,
vb
=
bv
[
0
]
.
Key
(),
bv
[
0
]
.
Value
()
kb
=
bv
[
0
]
.
Key
()
vb
,
err
=
vOid
(
bv
[
0
]
.
Value
())
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"b[%v]: %s"
,
kb
,
err
)
}
}
switch
{
...
...
@@ -377,14 +391,28 @@ func diffB(a, b *Bucket) map[Key]Value {
δ
[
ka
]
=
VDEL
case
ka
>
kb
:
// +b[0]
bv
=
bv
[
1
:
]
δ
[
kb
]
=
vb
// ka == kb // va->vb
default
:
case
va
!=
vb
:
av
=
av
[
1
:
]
bv
=
bv
[
1
:
]
δ
[
ka
]
=
vb
}
}
return
δ
,
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
}
...
...
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