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
3c6aaea6
Commit
3c6aaea6
authored
Sep 21, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
b54817e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
21 deletions
+24
-21
wcfs/internal/zdata/δftail.go
wcfs/internal/zdata/δftail.go
+19
-16
wcfs/internal/zdata/δftail_test.go
wcfs/internal/zdata/δftail_test.go
+5
-5
No files found.
wcfs/internal/zdata/δftail.go
View file @
3c6aaea6
...
...
@@ -23,7 +23,7 @@ package zdata
//
// It translates ZODB object-level changes to information about which blocks of
// which ZBigFile were modified, and provides service to query that information.
// See ΔFtail class documentation for details.
// See ΔFtail class documentation for
usage
details.
//
//
// ΔFtail organization
...
...
@@ -96,7 +96,7 @@ type setOid = set.Oid
// tracked, even if it was changed in δZ, is not guaranteed to be present in δF.
//
// After file epoch (file creation, deletion, or any other change to file
// object) previous track requests for that file become forgotten and ha
s
no
// object) previous track requests for that file become forgotten and ha
ve
no
// further effect.
//
// ΔFtail provides the following operations:
...
...
@@ -121,14 +121,15 @@ type setOid = set.Oid
// See also zodb.ΔTail and xbtree.ΔBtail
type
ΔFtail
struct
{
// ΔFtail merges ΔBtail with history of ZBlk
δBtail
*
xbtree
.
ΔBtail
fileIdx
map
[
zodb
.
Oid
]
setOid
// tree-root -> {} ZBigFile<oid> as of @head XXX -> root2file ?
byFile
map
[
zodb
.
Oid
]
*
_ΔFileTail
// file -> vδf tail XXX
δBtail
*
xbtree
.
ΔBtail
byFile
map
[
zodb
.
Oid
]
*
_ΔFileTail
// file -> vδf tail
filesByRoot
map
[
zodb
.
Oid
]
setOid
// tree-root -> {} ZBigFile<oid> as of @head
// set of files, which are newly tracked and for which byFile[foid].vδE was not yet rebuilt
trackNew
setOid
// {}foid
trackSetZBlk
map
[
zodb
.
Oid
]
*
zblkTrack
// zblk -> {} root -> {}blk as of @head
// set of tracked ZBlk objects reverse-mapped to trees and block numbers
trackSetZBlk
map
[
zodb
.
Oid
]
*
zblkTrack
// zblk -> {} root -> {}blk as of @head
}
// _ΔFileTail represents tail of revisional changes to one file.
...
...
@@ -154,6 +155,7 @@ type zblkTrack struct {
inroot
map
[
zodb
.
Oid
]
setI64
// {} root -> {}blk
}
// ΔF represents a change in files space.
type
ΔF
struct
{
Rev
zodb
.
Tid
...
...
@@ -168,6 +170,7 @@ type ΔFile struct {
Size
bool
// whether file size changed
}
// NewΔFtail creates new ΔFtail object.
//
// Initial tracked set is empty.
...
...
@@ -178,8 +181,8 @@ type ΔFile struct {
func
NewΔFtail
(
at0
zodb
.
Tid
,
db
*
zodb
.
DB
)
*
ΔFtail
{
return
&
ΔFtail
{
δBtail
:
xbtree
.
NewΔBtail
(
at0
,
db
),
fileIdx
:
map
[
zodb
.
Oid
]
setOid
{},
byFile
:
map
[
zodb
.
Oid
]
*
_ΔFileTail
{},
filesByRoot
:
map
[
zodb
.
Oid
]
setOid
{},
trackNew
:
setOid
{},
trackSetZBlk
:
map
[
zodb
.
Oid
]
*
zblkTrack
{},
}
...
...
@@ -226,10 +229,10 @@ func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, zb
rootObj
:=
path
[
0
]
.
(
*
btree
.
LOBTree
)
root
:=
rootObj
.
POid
()
files
,
ok
:=
δFtail
.
file
Idx
[
root
]
files
,
ok
:=
δFtail
.
file
sByRoot
[
root
]
if
!
ok
{
files
=
setOid
{}
δFtail
.
file
Idx
[
root
]
=
files
δFtail
.
file
sByRoot
[
root
]
=
files
}
files
.
Add
(
foid
)
...
...
@@ -420,7 +423,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
//fmt.Printf("δB.ΔByRoot: %v\n", δB.ΔByRoot)
for
root
,
δt
:=
range
δB
.
ΔByRoot
{
//fmt.Printf("root: %v δt: %v\n", root, δt)
files
:=
δFtail
.
file
Idx
[
root
]
files
:=
δFtail
.
file
sByRoot
[
root
]
// NOTE files might be empty e.g. if a zfile was tracked, then
// deleted, but the tree referenced by zfile.blktab is still
// not-deleted, remains tracked and is changed.
...
...
@@ -484,7 +487,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
continue
}
//fmt.Printf("root: %v inblk: %v\n", root, inblk)
files
:=
δFtail
.
file
Idx
[
root
]
files
:=
δFtail
.
file
sByRoot
[
root
]
for
file
:=
range
files
{
δfile
,
ok
:=
δF
.
ByFile
[
file
]
if
!
ok
{
...
...
@@ -510,21 +513,21 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
//fmt.Printf("δZBigFile: %v\n", δ)
// update .file
Idx
// update .file
sByRoot
if
δ
.
blktabOld
!=
xbtree
.
VDEL
{
files
,
ok
:=
δFtail
.
file
Idx
[
δ
.
blktabOld
]
files
,
ok
:=
δFtail
.
file
sByRoot
[
δ
.
blktabOld
]
if
ok
{
files
.
Del
(
foid
)
if
len
(
files
)
==
0
{
delete
(
δFtail
.
file
Idx
,
δ
.
blktabOld
)
delete
(
δFtail
.
file
sByRoot
,
δ
.
blktabOld
)
}
}
}
if
δ
.
blktabNew
!=
xbtree
.
VDEL
{
files
,
ok
:=
δFtail
.
file
Idx
[
δ
.
blktabNew
]
files
,
ok
:=
δFtail
.
file
sByRoot
[
δ
.
blktabNew
]
if
!
ok
{
files
=
setOid
{}
δFtail
.
file
Idx
[
δ
.
blktabNew
]
=
files
δFtail
.
file
sByRoot
[
δ
.
blktabNew
]
=
files
}
files
.
Add
(
foid
)
}
...
...
wcfs/internal/zdata/δftail_test.go
View file @
3c6aaea6
...
...
@@ -485,14 +485,14 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
vδE
=
vδE
[
icut
:
]
}
// verify δFtail.file
Idx
file
Idx
OK
:=
map
[
zodb
.
Oid
]
setOid
{}
// verify δFtail.file
sByRoot
file
sByRoot
OK
:=
map
[
zodb
.
Oid
]
setOid
{}
if
!
delfile
{
__
:=
setOid
{};
__
.
Add
(
foid
)
file
Idx
OK
[
t
.
Root
()]
=
__
file
sByRoot
OK
[
t
.
Root
()]
=
__
}
if
!
reflect
.
DeepEqual
(
δFtail
.
file
Idx
,
fileIdx
OK
)
{
t
.
Errorf
(
"file
Idx:
\n
have: %v
\n
want: %v"
,
δFtail
.
fileIdx
,
fileIdx
OK
)
if
!
reflect
.
DeepEqual
(
δFtail
.
file
sByRoot
,
filesByRoot
OK
)
{
t
.
Errorf
(
"file
sByRoot:
\n
have: %v
\n
want: %v"
,
δFtail
.
filesByRoot
,
filesByRoot
OK
)
}
// verify δftail.root
...
...
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