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
b8ced44a
Commit
b8ced44a
authored
Sep 21, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c914b109
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
31 deletions
+52
-31
wcfs/internal/xbtree/xbtree.go
wcfs/internal/xbtree/xbtree.go
+19
-0
wcfs/internal/xbtree/δbtail.go
wcfs/internal/xbtree/δbtail.go
+15
-13
wcfs/internal/xbtree/δbtail_test.go
wcfs/internal/xbtree/δbtail_test.go
+15
-15
wcfs/internal/zdata/δftail.go
wcfs/internal/zdata/δftail.go
+3
-3
No files found.
wcfs/internal/xbtree/xbtree.go
View file @
b8ced44a
// Copyright (C) 2021 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// Package xbtree complements package lab.nexedi.com/kirr/neo/go/zodb/btree.
//
// It provides the following amendments:
...
...
wcfs/internal/xbtree/δbtail.go
View file @
b8ced44a
...
...
@@ -20,6 +20,8 @@
package
xbtree
// ΔBtail
// XXX ΔBtail organization
import
(
"context"
"fmt"
...
...
@@ -109,8 +111,8 @@ type _ΔTtail struct {
trackNew
blib
.
PPTreeSubSet
// XXX + trackNewKeys RangedKeySet
// index for
LastRevOf
queries
lastRevOf
map
[
Key
]
zodb
.
Tid
// {} key -> last
// index for
GetAt
queries
lastRevOf
map
[
Key
]
zodb
.
Tid
// {} key -> last
revision
}
// _ΔBroots represents roots-only part of ΔB.
...
...
@@ -130,7 +132,7 @@ type ΔB struct {
// ΔTree describes changes to one BTree in one revision.
type
ΔTree
struct
{
Rev
zodb
.
Tid
ΔKV
map
[
Key
]
ΔValue
// XXX -> KV ?
KV
map
[
Key
]
ΔValue
}
...
...
@@ -211,10 +213,10 @@ func vδTClone(orig []ΔTree) []ΔTree {
for
_
,
origδT
:=
range
orig
{
klonδT
:=
ΔTree
{
Rev
:
origδT
.
Rev
,
ΔKV
:
make
(
map
[
Key
]
ΔValue
,
len
(
origδT
.
Δ
KV
)),
KV
:
make
(
map
[
Key
]
ΔValue
,
len
(
origδT
.
KV
)),
}
for
k
,
δv
:=
range
origδT
.
Δ
KV
{
klonδT
.
Δ
KV
[
k
]
=
δv
for
k
,
δv
:=
range
origδT
.
KV
{
klonδT
.
KV
[
k
]
=
δv
}
klon
=
append
(
klon
,
klonδT
)
}
...
...
@@ -525,7 +527,7 @@ func (δTtail *_ΔTtail) rebuild1(atPrev zodb.Tid, δZ zodb.ΔRevEntry, trackNew
})
if
j
==
l
||
δTtail
.
vδT
[
j
]
.
Rev
!=
δZ
.
Rev
{
newRevEntry
=
true
δTcurr
:=
ΔTree
{
Rev
:
δZ
.
Rev
,
Δ
KV
:
map
[
Key
]
ΔValue
{}}
δTcurr
:=
ΔTree
{
Rev
:
δZ
.
Rev
,
KV
:
map
[
Key
]
ΔValue
{}}
// insert(@j, δTcurr)
δTtail
.
vδT
=
append
(
δTtail
.
vδT
[
:
j
],
append
([]
ΔTree
{
δTcurr
},
...
...
@@ -537,13 +539,13 @@ func (δTtail *_ΔTtail) rebuild1(atPrev zodb.Tid, δZ zodb.ΔRevEntry, trackNew
// the diff was backward; δTtail entries are with diff forward
δv
.
New
,
δv
.
Old
=
δv
.
Old
,
δv
.
New
δv_
,
already
:=
δTcurr
.
Δ
KV
[
k
]
δv_
,
already
:=
δTcurr
.
KV
[
k
]
if
already
{
if
δv
!=
δv_
{
panicf
(
"[%v] inconsistent δv:
\n
δTcurr: %v
\n
δT: %v"
,
k
,
δTcurr
,
δT
)
}
}
else
{
δTcurr
.
Δ
KV
[
k
]
=
δv
δTcurr
.
KV
[
k
]
=
δv
}
}
...
...
@@ -597,7 +599,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
if
l
>
0
{
δT
:=
δTtail
.
vδT
[
l
-
1
]
// δT head
if
δT
.
Rev
==
δZ
.
Tid
{
δB
.
ByRoot
[
root
]
=
δT
.
Δ
KV
δB
.
ByRoot
[
root
]
=
δT
.
KV
}
}
...
...
@@ -677,7 +679,7 @@ func (δBtail *ΔBtail) _Update1(δZ *zodb.EventCommit) (δB1 _ΔBUpdate1, err e
// XXX also needs vδT clone here?
δTtail
:=
δBtail
.
vδTbyRoot
[
root
]
// must be there
if
len
(
δT
)
>
0
{
// an object might be resaved without change
δTtail
.
vδT
=
append
(
δTtail
.
vδT
,
ΔTree
{
Rev
:
δZ
.
Tid
,
Δ
KV
:
δT
})
δTtail
.
vδT
=
append
(
δTtail
.
vδT
,
ΔTree
{
Rev
:
δZ
.
Tid
,
KV
:
δT
})
}
δBtail
.
trackSet
.
ApplyΔ
(
δtrack
)
...
...
@@ -808,10 +810,10 @@ func (δBtail *ΔBtail) GetAt(root zodb.Oid, key Key, at zodb.Tid) (value Value,
panicf
(
"δBtail: root<%s> not tracked"
,
root
)
}
//
XXX -> index lastXXX
Of(key) | linear scan ↓ looking for change <= at
//
TODO -> index lastRev
Of(key) | linear scan ↓ looking for change <= at
for
i
:=
len
(
δTtail
.
vδT
)
-
1
;
i
>=
0
;
i
--
{
δT
:=
δTtail
.
vδT
[
i
]
δvalue
,
ok_
:=
δT
.
Δ
KV
[
key
]
δvalue
,
ok_
:=
δT
.
KV
[
key
]
if
ok_
{
valueExact
=
true
if
δT
.
Rev
>
at
{
...
...
wcfs/internal/xbtree/δbtail_test.go
View file @
b8ced44a
...
...
@@ -1186,12 +1186,12 @@ func TestΔBtailSliceByRootRev(t_ *testing.T) {
t
:=
xbtreetest
.
NewT
(
t_
)
X
:=
exc
.
Raiseif
// ΔT is similar to ΔTree but uses Δstring instead of ΔValue for
Δ
KV
// ΔT is similar to ΔTree but uses Δstring instead of ΔValue for KV
type
ΔT
struct
{
Rev
zodb
.
Tid
ΔKV
map
[
Key
]
Δstring
KV
map
[
Key
]
Δstring
}
// δ is shorthand for ΔKV
// δ is shorthand for Δ
T.
KV
type
δ
=
map
[
Key
]
Δstring
t0
:=
t
.
CommitTree
(
"T2/B1:a-B2:f"
)
...
...
@@ -1219,7 +1219,7 @@ func TestΔBtailSliceByRootRev(t_ *testing.T) {
var
vδT_
[]
ΔT
for
_
,
δT
:=
range
vδT
{
tj
:=
t
.
XGetCommit
(
δT
.
Rev
)
δt
:=
ΔT
{
δT
.
Rev
,
xgetδKV
(
tj
.
Prev
,
tj
,
δT
.
Δ
KV
)}
δt
:=
ΔT
{
δT
.
Rev
,
xgetδKV
(
tj
.
Prev
,
tj
,
δT
.
KV
)}
vδT_
=
append
(
vδT_
,
δt
)
}
...
...
@@ -1228,11 +1228,11 @@ func TestΔBtailSliceByRootRev(t_ *testing.T) {
}
have
:=
[]
string
{}
for
_
,
δT
:=
range
vδT_
{
have
=
append
(
have
,
fmt
.
Sprintf
(
"@%s·%v"
,
t
.
AtSymb
(
δT
.
Rev
),
δT
.
Δ
KV
))
have
=
append
(
have
,
fmt
.
Sprintf
(
"@%s·%v"
,
t
.
AtSymb
(
δT
.
Rev
),
δT
.
KV
))
}
want
:=
[]
string
{}
for
_
,
δT
:=
range
vδTok
{
want
=
append
(
want
,
fmt
.
Sprintf
(
"@%s·%v"
,
t
.
AtSymb
(
δT
.
Rev
),
δT
.
Δ
KV
))
want
=
append
(
want
,
fmt
.
Sprintf
(
"@%s·%v"
,
t
.
AtSymb
(
δT
.
Rev
),
δT
.
KV
))
}
t
.
Errorf
(
"%s:
\n
have: %s
\n
want: %s"
,
subj
,
have
,
want
)
}
...
...
@@ -1254,16 +1254,16 @@ func TestΔBtailSliceByRootRev(t_ *testing.T) {
// sXX should be all aliased to vδT
gg
,
_
:=
t0
.
XGetBlkByName
(
"g"
)
hh
,
_
:=
t0
.
XGetBlkByName
(
"h"
)
vδT
[
0
]
.
Rev
=
t0
.
At
;
δkv0
:=
vδT
[
0
]
.
ΔKV
;
vδT
[
0
]
.
Δ
KV
=
map
[
Key
]
ΔValue
{
11
:
{
gg
,
gg
}}
vδT
[
1
]
.
Rev
=
t0
.
At
;
δkv1
:=
vδT
[
1
]
.
ΔKV
;
vδT
[
1
]
.
Δ
KV
=
map
[
Key
]
ΔValue
{
12
:
{
hh
,
hh
}}
vδT
[
0
]
.
Rev
=
t0
.
At
;
δkv0
:=
vδT
[
0
]
.
KV
;
vδT
[
0
]
.
KV
=
map
[
Key
]
ΔValue
{
11
:
{
gg
,
gg
}}
vδT
[
1
]
.
Rev
=
t0
.
At
;
δkv1
:=
vδT
[
1
]
.
KV
;
vδT
[
1
]
.
KV
=
map
[
Key
]
ΔValue
{
12
:
{
hh
,
hh
}}
assertvδT
(
"t2.vδT*"
,
vδT
,
ΔT
{
t0
.
At
,
δ
{
11
:
{
g
,
g
}}},
ΔT
{
t0
.
At
,
δ
{
12
:
{
h
,
h
}}})
assertvδT
(
"t2.s00*"
,
s00
)
assertvδT
(
"t2.s01*"
,
s01
,
ΔT
{
t0
.
At
,
δ
{
11
:
{
g
,
g
}}})
assertvδT
(
"t2.s02*"
,
s02
,
ΔT
{
t0
.
At
,
δ
{
11
:
{
g
,
g
}}},
ΔT
{
t0
.
At
,
δ
{
12
:
{
h
,
h
}}})
assertvδT
(
"t2.s12*"
,
s12
,
ΔT
{
t0
.
At
,
δ
{
12
:
{
h
,
h
}}})
assertvδT
(
"2.s22*"
,
s22
)
vδT
[
0
]
.
Rev
=
t1
.
At
;
vδT
[
0
]
.
Δ
KV
=
δkv0
vδT
[
1
]
.
Rev
=
t2
.
At
;
vδT
[
1
]
.
Δ
KV
=
δkv1
vδT
[
0
]
.
Rev
=
t1
.
At
;
vδT
[
0
]
.
KV
=
δkv0
vδT
[
1
]
.
Rev
=
t2
.
At
;
vδT
[
1
]
.
KV
=
δkv1
assertvδT
(
"t2.vδT+"
,
vδT
,
ΔT
{
t1
.
At
,
δ
{
2
:
{
f
,
g
}}},
ΔT
{
t2
.
At
,
δ
{
2
:
{
g
,
h
}}})
assertvδT
(
"t2.s00+"
,
s00
)
assertvδT
(
"t2.s01+"
,
s01
,
ΔT
{
t1
.
At
,
δ
{
2
:
{
f
,
g
}}})
...
...
@@ -1299,8 +1299,8 @@ func TestΔBtailSliceByRootRev(t_ *testing.T) {
// sXX_ should be all aliased to vδT, but not sXX
bb
,
_
:=
t0
.
XGetBlkByName
(
"b"
)
cc
,
_
:=
t0
.
XGetBlkByName
(
"c"
)
vδT
[
0
]
.
Rev
=
t0
.
At
;
δkv0
=
vδT
[
0
]
.
ΔKV
;
vδT
[
0
]
.
Δ
KV
=
map
[
Key
]
ΔValue
{
111
:
{
bb
,
bb
}}
vδT
[
1
]
.
Rev
=
t0
.
At
;
δkv1
=
vδT
[
1
]
.
ΔKV
;
vδT
[
1
]
.
Δ
KV
=
map
[
Key
]
ΔValue
{
112
:
{
cc
,
cc
}}
vδT
[
0
]
.
Rev
=
t0
.
At
;
δkv0
=
vδT
[
0
]
.
KV
;
vδT
[
0
]
.
KV
=
map
[
Key
]
ΔValue
{
111
:
{
bb
,
bb
}}
vδT
[
1
]
.
Rev
=
t0
.
At
;
δkv1
=
vδT
[
1
]
.
KV
;
vδT
[
1
]
.
KV
=
map
[
Key
]
ΔValue
{
112
:
{
cc
,
cc
}}
assertvδT
(
"t12.vδT*"
,
vδT
,
ΔT
{
t0
.
At
,
δ
{
111
:
{
b
,
b
}}},
ΔT
{
t0
.
At
,
δ
{
112
:
{
c
,
c
}}})
assertvδT
(
"t12.s00*"
,
s00
)
assertvδT
(
"t12.s00_*"
,
s00_
)
...
...
@@ -1313,8 +1313,8 @@ func TestΔBtailSliceByRootRev(t_ *testing.T) {
assertvδT
(
"t12.s22*"
,
s22
)
assertvδT
(
"t12.s22_*"
,
s22_
)
vδT
[
0
]
.
Rev
=
t1
.
At
;
vδT
[
0
]
.
Δ
KV
=
δkv0
vδT
[
1
]
.
Rev
=
t2
.
At
;
vδT
[
1
]
.
Δ
KV
=
δkv1
vδT
[
0
]
.
Rev
=
t1
.
At
;
vδT
[
0
]
.
KV
=
δkv0
vδT
[
1
]
.
Rev
=
t2
.
At
;
vδT
[
1
]
.
KV
=
δkv1
assertvδT
(
"t12.vδT+"
,
vδT
,
ΔT
{
t1
.
At
,
δ
{
1
:
{
a
,
b
},
2
:
{
f
,
g
}}},
ΔT
{
t2
.
At
,
δ
{
1
:
{
b
,
c
},
2
:
{
g
,
h
}}})
assertvδT
(
"t12.s00+"
,
s00
)
assertvδT
(
"t12.s00_+"
,
s00_
)
...
...
@@ -1547,7 +1547,7 @@ func assertΔTtail(t *testing.T, subj string, δbtail *ΔBtail, tj *xbtreetest.C
atPrev
:=
t0
.
At
for
_
,
δToid
:=
range
vδToid
{
vat
=
append
(
vat
,
δToid
.
Rev
)
δT
:=
xgetδKV
(
T
.
XGetCommit
(
atPrev
),
T
.
XGetCommit
(
δToid
.
Rev
),
δToid
.
Δ
KV
)
// {} k -> δ(ZBlk(oid).data)
δT
:=
xgetδKV
(
T
.
XGetCommit
(
atPrev
),
T
.
XGetCommit
(
δToid
.
Rev
),
δToid
.
KV
)
// {} k -> δ(ZBlk(oid).data)
vδT
=
append
(
vδT
,
δT
)
atPrev
=
δToid
.
Rev
}
...
...
wcfs/internal/zdata/δftail.go
View file @
b8ced44a
...
...
@@ -707,7 +707,7 @@ func (δFtail *ΔFtail) SliceByFileRev(zfile *ZBigFile, lo, hi zodb.Tid) /*reado
// changes to 2 should not be present at all.
ZinblkAdj
:=
map
[
zodb
.
Oid
]
setI64
{}
for
_
,
δT
:=
range
vδT
{
for
blk
,
δzblk
:=
range
δT
.
Δ
KV
{
for
blk
,
δzblk
:=
range
δT
.
KV
{
if
δzblk
.
Old
!=
xbtree
.
VDEL
{
inblk
,
ok
:=
ZinblkAdj
[
δzblk
.
Old
]
if
ok
{
...
...
@@ -756,8 +756,8 @@ func (δFtail *ΔFtail) SliceByFileRev(zfile *ZBigFile, lo, hi zodb.Tid) /*reado
// δT -> adjust Zinblk + update δf
if
it
>=
0
{
δT
:=
vδT
[
it
]
//fmt.Printf("δT @%s %v\n", δT.Rev, δT.
Δ
KV)
for
blk
,
δzblk
:=
range
δT
.
Δ
KV
{
//fmt.Printf("δT @%s %v\n", δT.Rev, δT.KV)
for
blk
,
δzblk
:=
range
δT
.
KV
{
// apply in reverse as we go ←
if
δzblk
.
New
!=
xbtree
.
VDEL
{
inblk
,
ok
:=
Zinblk
[
δzblk
.
New
]
...
...
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