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
cda8c398
Commit
cda8c398
authored
Oct 18, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
00bb8991
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
46 deletions
+44
-46
wcfs/internal/zdata/δftail.go
wcfs/internal/zdata/δftail.go
+41
-43
wcfs/internal/zdata/δftail_test.go
wcfs/internal/zdata/δftail_test.go
+3
-3
No files found.
wcfs/internal/zdata/δftail.go
View file @
cda8c398
...
...
@@ -62,6 +62,7 @@ package zdata
// Concurrency
//
// XXX
// XXX note about SliceByFileRev Zinblk snapshotting
import
(
"context"
...
...
@@ -138,10 +139,10 @@ type ΔFtail struct {
// ΔFtail merges ΔBtail with history of ZBlk
δBtail
*
xbtree
.
ΔBtail
// mu protects ΔFtail data _and_ all _ΔFileTail
data for all file
s.
// mu protects ΔFtail data _and_ all _ΔFileTail
/_RootTrack data for all files and root
s.
//
// NOTE: even though this lock is global
, since ... XXX
//
working with retrieved vδE snapshot(?)
does not need to hold the lock.
// NOTE: even though this lock is global
it is used only for brief periouds of time. In
//
particular working with retrieved vδE and Zinblk snapshot
does not need to hold the lock.
mu
sync
.
Mutex
byFile
map
[
zodb
.
Oid
]
*
_ΔFileTail
// file -> vδf tail
...
...
@@ -150,9 +151,8 @@ type ΔFtail struct {
// set of files, which are newly tracked and for which byFile[foid].vδE was not yet rebuilt
ftrackNew
setOid
// {}foid
// set of tracked ZBlk objects mapped to trees as of @head
// XXX -> ztrackInRoot ?
zinroot
map
[
zodb
.
Oid
]
setOid
// {} zblk -> {}root
// set of tracked ZBlk objects mapped to tree roots as of @head
ztrackInRoot
map
[
zodb
.
Oid
]
setOid
// {} zblk -> {}root
}
// _ΔFileTail represents tail of revisional changes to one file.
...
...
@@ -171,17 +171,14 @@ type _ΔFileEpoch struct {
oldBlkSize
int64
// .blksize was oldBlkSize ; -1 if ZBigFile deleted
newBlkSize
int64
// .blksize was changed to newBlkSize ; ----//----
// snapshot of
trackSetZ
Blk for this file right before this epoch
// snapshot of
ztrackIn
Blk for this file right before this epoch
oldZinblk
map
[
zodb
.
Oid
]
setI64
// {} zblk -> {}blk
}
// _RootTrack represents tracking information about one particular tree as of @head.
// XXX -> _TreeTrack ? _BlktabTrack ?
type
_RootTrack
struct
{
// XXX -> ftrackSet ?
files
setOid
// {}foid which ZBigFiles refer to this tree
// XXX -> ztrackInBlk ? trackZInblk ?
Zinblk
map
[
zodb
.
Oid
]
setI64
// {} zblk -> {}blk which blocks map to zblk
ftrackSet
setOid
// {}foid which ZBigFiles refer to this tree
ztrackInBlk
map
[
zodb
.
Oid
]
setI64
// {} zblk -> {}blk which blocks map to zblk
}
// _RebuildJob represents currently in-progress vδE rebuilding job.
...
...
@@ -219,7 +216,7 @@ func NewΔFtail(at0 zodb.Tid, db *zodb.DB) *ΔFtail {
byFile
:
map
[
zodb
.
Oid
]
*
_ΔFileTail
{},
byRoot
:
map
[
zodb
.
Oid
]
*
_RootTrack
{},
ftrackNew
:
setOid
{},
z
inroot
:
map
[
zodb
.
Oid
]
setOid
{},
z
trackInRoot
:
map
[
zodb
.
Oid
]
setOid
{},
}
}
...
...
@@ -266,12 +263,12 @@ func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, bl
rt
,
ok
:=
δFtail
.
byRoot
[
root
]
if
!
ok
{
rt
=
&
_RootTrack
{
f
iles
:
setOid
{},
Zinb
lk
:
map
[
zodb
.
Oid
]
setI64
{},
f
trackSet
:
setOid
{},
ztrackInB
lk
:
map
[
zodb
.
Oid
]
setI64
{},
}
δFtail
.
byRoot
[
root
]
=
rt
}
rt
.
f
iles
.
Add
(
foid
)
rt
.
f
trackSet
.
Add
(
foid
)
δftail
,
ok
:=
δFtail
.
byFile
[
foid
]
if
!
ok
{
...
...
@@ -289,17 +286,17 @@ func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, bl
if
zblk
!=
nil
{
zoid
:=
zblk
.
POid
()
inroot
,
ok
:=
δFtail
.
z
inr
oot
[
zoid
]
inroot
,
ok
:=
δFtail
.
z
trackInR
oot
[
zoid
]
if
!
ok
{
inroot
=
make
(
setOid
,
1
)
δFtail
.
z
inr
oot
[
zoid
]
=
inroot
δFtail
.
z
trackInR
oot
[
zoid
]
=
inroot
}
inroot
.
Add
(
root
)
inblk
,
ok
:=
rt
.
Zinb
lk
[
zoid
]
inblk
,
ok
:=
rt
.
ztrackInB
lk
[
zoid
]
if
!
ok
{
inblk
=
make
(
setI64
,
1
)
rt
.
Zinb
lk
[
zoid
]
=
inblk
rt
.
ztrackInB
lk
[
zoid
]
=
inblk
}
inblk
.
Add
(
blk
)
}
...
...
@@ -435,20 +432,21 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
rt
,
ok
:=
δFtail
.
byRoot
[
δftail
.
root
]
if
ok
{
for
zoid
,
inblk
:=
range
rt
.
Zinb
lk
{
for
zoid
,
inblk
:=
range
rt
.
ztrackInB
lk
{
δE
.
oldZinblk
[
zoid
]
=
inblk
.
Clone
()
inroot
,
ok
:=
δFtail
.
z
inr
oot
[
zoid
]
inroot
,
ok
:=
δFtail
.
z
trackInR
oot
[
zoid
]
if
ok
{
inroot
.
Del
(
δftail
.
root
)
if
len
(
inroot
)
==
0
{
delete
(
δFtail
.
z
inr
oot
,
zoid
)
delete
(
δFtail
.
z
trackInR
oot
,
zoid
)
}
}
}
}
δftail
.
root
=
δE
.
newRoot
δftail
.
vδE
=
append
(
δftail
.
vδE
,
δE
)
// XXX note that we do not change older snapshots
// NOTE no need to clone vδE: we are writer, vδE is not returned to outside
δftail
.
vδE
=
append
(
δftail
.
vδE
,
δE
)
}
}
...
...
@@ -464,7 +462,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
continue
}
for
file
:=
range
rt
.
f
iles
{
for
file
:=
range
rt
.
f
trackSet
{
δfile
,
ok
:=
δF
.
ByFile
[
file
]
if
!
ok
{
δfile
=
&
ΔFile
{
Rev
:
δF
.
Rev
,
Blocks
:
make
(
setI64
)}
...
...
@@ -481,32 +479,32 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
δfile
.
Size
=
true
}
// update
Zinb
lk according to btree changes
// update
ztrackInB
lk according to btree changes
for
blk
,
δzblk
:=
range
δt
{
if
δzblk
.
Old
!=
xbtree
.
VDEL
{
inblk
,
ok
:=
rt
.
Zinb
lk
[
δzblk
.
Old
]
inblk
,
ok
:=
rt
.
ztrackInB
lk
[
δzblk
.
Old
]
if
ok
{
inblk
.
Del
(
blk
)
if
len
(
inblk
)
==
0
{
delete
(
rt
.
Zinb
lk
,
δzblk
.
Old
)
inroot
:=
δFtail
.
z
inr
oot
[
δzblk
.
Old
]
delete
(
rt
.
ztrackInB
lk
,
δzblk
.
Old
)
inroot
:=
δFtail
.
z
trackInR
oot
[
δzblk
.
Old
]
inroot
.
Del
(
root
)
if
len
(
inroot
)
==
0
{
delete
(
δFtail
.
z
inr
oot
,
δzblk
.
Old
)
delete
(
δFtail
.
z
trackInR
oot
,
δzblk
.
Old
)
}
}
}
}
if
δzblk
.
New
!=
xbtree
.
VDEL
{
inblk
,
ok
:=
rt
.
Zinb
lk
[
δzblk
.
New
]
inblk
,
ok
:=
rt
.
ztrackInB
lk
[
δzblk
.
New
]
if
!
ok
{
inblk
=
make
(
setI64
,
1
)
rt
.
Zinb
lk
[
δzblk
.
New
]
=
inblk
inroot
,
ok
:=
δFtail
.
z
inr
oot
[
δzblk
.
New
]
rt
.
ztrackInB
lk
[
δzblk
.
New
]
=
inblk
inroot
,
ok
:=
δFtail
.
z
trackInR
oot
[
δzblk
.
New
]
if
!
ok
{
inroot
=
make
(
setOid
,
1
)
δFtail
.
z
inr
oot
[
δzblk
.
New
]
=
inroot
δFtail
.
z
trackInR
oot
[
δzblk
.
New
]
=
inroot
}
inroot
.
Add
(
root
)
}
...
...
@@ -517,19 +515,19 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
// take zblk changes into account
for
_
,
oid
:=
range
δZ
.
Changev
{
inroot
,
ok
:=
δFtail
.
z
inr
oot
[
oid
]
inroot
,
ok
:=
δFtail
.
z
trackInR
oot
[
oid
]
if
!
ok
{
continue
// not tracked
}
for
root
:=
range
inroot
{
rt
:=
δFtail
.
byRoot
[
root
]
// must be there
inblk
,
ok
:=
rt
.
Zinb
lk
[
oid
]
inblk
,
ok
:=
rt
.
ztrackInB
lk
[
oid
]
if
!
ok
||
len
(
inblk
)
==
0
{
continue
}
//fmt.Printf("root: %v inblk: %v\n", root, inblk)
for
file
:=
range
rt
.
f
iles
{
for
file
:=
range
rt
.
f
trackSet
{
δfile
,
ok
:=
δF
.
ByFile
[
file
]
if
!
ok
{
δfile
=
&
ΔFile
{
Rev
:
δF
.
Rev
,
Blocks
:
make
(
setI64
)}
...
...
@@ -558,8 +556,8 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
if
δ
.
blktabOld
!=
xbtree
.
VDEL
{
rt
,
ok
:=
δFtail
.
byRoot
[
δ
.
blktabOld
]
if
ok
{
rt
.
f
iles
.
Del
(
foid
)
if
len
(
rt
.
f
iles
)
==
0
{
rt
.
f
trackSet
.
Del
(
foid
)
if
len
(
rt
.
f
trackSet
)
==
0
{
delete
(
δFtail
.
byRoot
,
δ
.
blktabOld
)
// XXX reset Zinroot -= δ.blktabNew
}
...
...
@@ -569,13 +567,13 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
rt
,
ok
:=
δFtail
.
byRoot
[
δ
.
blktabNew
]
if
!
ok
{
rt
=
&
_RootTrack
{
f
iles
:
setOid
{},
Zinb
lk
:
map
[
zodb
.
Oid
]
setI64
{},
f
trackSet
:
setOid
{},
ztrackInB
lk
:
map
[
zodb
.
Oid
]
setI64
{},
// XXX reset Zinroot -= δ.blktabNew
}
δFtail
.
byRoot
[
δ
.
blktabNew
]
=
rt
}
rt
.
f
iles
.
Add
(
foid
)
rt
.
f
trackSet
.
Add
(
foid
)
}
}
...
...
@@ -752,7 +750,7 @@ func (δFtail *ΔFtail) SliceByFileRev(zfile *ZBigFile, lo, hi zodb.Tid) /*reado
rt
,
ok
:=
δFtail
.
byRoot
[
root
]
if
ok
{
for
oid
:=
range
δZAllOid
{
inblk
,
ok
:=
rt
.
Zinb
lk
[
oid
]
inblk
,
ok
:=
rt
.
ztrackInB
lk
[
oid
]
if
ok
{
ZinblkSnap
[
oid
]
=
inblk
.
Clone
()
}
...
...
wcfs/internal/zdata/δftail_test.go
View file @
cda8c398
...
...
@@ -452,7 +452,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
// verify byRoot
trackRfiles
:=
map
[
zodb
.
Oid
]
setOid
{}
for
root
,
rt
:=
range
δFtail
.
byRoot
{
trackRfiles
[
root
]
=
rt
.
f
iles
trackRfiles
[
root
]
=
rt
.
f
trackSet
}
filesOK
:=
setOid
{}
if
!
delfile
{
...
...
@@ -468,7 +468,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
// verify Zinroot
trackZinroot
:=
map
[
string
]
setOid
{}
for
zoid
,
inroot
:=
range
δFtail
.
z
inr
oot
{
for
zoid
,
inroot
:=
range
δFtail
.
z
trackInR
oot
{
zblki
:=
commit
.
ZBlkTab
[
zoid
]
trackZinroot
[
zblki
.
Name
]
=
inroot
.
Clone
()
// XXX clone needed?
}
...
...
@@ -492,7 +492,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
if
!
ok
{
t
.
Errorf
(
".byRoot points to unexpected blktab"
)
}
else
{
for
zoid
,
inblk
:=
range
rt
.
Zinb
lk
{
for
zoid
,
inblk
:=
range
rt
.
ztrackInB
lk
{
zblki
:=
commit
.
ZBlkTab
[
zoid
]
trackZinblk
[
zblki
.
Name
]
=
inblk
.
Clone
()
// XXX clone needed?
}
...
...
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