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
...
@@ -23,7 +23,7 @@ package zdata
//
//
// It translates ZODB object-level changes to information about which blocks of
// It translates ZODB object-level changes to information about which blocks of
// which ZBigFile were modified, and provides service to query that information.
// 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
// ΔFtail organization
...
@@ -96,7 +96,7 @@ type setOid = set.Oid
...
@@ -96,7 +96,7 @@ type setOid = set.Oid
// tracked, even if it was changed in δZ, is not guaranteed to be present in δF.
// 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
// 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.
// further effect.
//
//
// ΔFtail provides the following operations:
// ΔFtail provides the following operations:
...
@@ -121,14 +121,15 @@ type setOid = set.Oid
...
@@ -121,14 +121,15 @@ type setOid = set.Oid
// See also zodb.ΔTail and xbtree.ΔBtail
// See also zodb.ΔTail and xbtree.ΔBtail
type
ΔFtail
struct
{
type
ΔFtail
struct
{
// ΔFtail merges ΔBtail with history of ZBlk
// ΔFtail merges ΔBtail with history of ZBlk
δBtail
*
xbtree
.
ΔBtail
δ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
byFile
map
[
zodb
.
Oid
]
*
_ΔFileTail
// file -> vδf tail XXX
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
// set of files, which are newly tracked and for which byFile[foid].vδE was not yet rebuilt
trackNew
setOid
// {}foid
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.
// _ΔFileTail represents tail of revisional changes to one file.
...
@@ -154,6 +155,7 @@ type zblkTrack struct {
...
@@ -154,6 +155,7 @@ type zblkTrack struct {
inroot
map
[
zodb
.
Oid
]
setI64
// {} root -> {}blk
inroot
map
[
zodb
.
Oid
]
setI64
// {} root -> {}blk
}
}
// ΔF represents a change in files space.
// ΔF represents a change in files space.
type
ΔF
struct
{
type
ΔF
struct
{
Rev
zodb
.
Tid
Rev
zodb
.
Tid
...
@@ -168,6 +170,7 @@ type ΔFile struct {
...
@@ -168,6 +170,7 @@ type ΔFile struct {
Size
bool
// whether file size changed
Size
bool
// whether file size changed
}
}
// NewΔFtail creates new ΔFtail object.
// NewΔFtail creates new ΔFtail object.
//
//
// Initial tracked set is empty.
// Initial tracked set is empty.
...
@@ -178,8 +181,8 @@ type ΔFile struct {
...
@@ -178,8 +181,8 @@ type ΔFile struct {
func
NewΔFtail
(
at0
zodb
.
Tid
,
db
*
zodb
.
DB
)
*
ΔFtail
{
func
NewΔFtail
(
at0
zodb
.
Tid
,
db
*
zodb
.
DB
)
*
ΔFtail
{
return
&
ΔFtail
{
return
&
ΔFtail
{
δBtail
:
xbtree
.
NewΔBtail
(
at0
,
db
),
δBtail
:
xbtree
.
NewΔBtail
(
at0
,
db
),
fileIdx
:
map
[
zodb
.
Oid
]
setOid
{},
byFile
:
map
[
zodb
.
Oid
]
*
_ΔFileTail
{},
byFile
:
map
[
zodb
.
Oid
]
*
_ΔFileTail
{},
filesByRoot
:
map
[
zodb
.
Oid
]
setOid
{},
trackNew
:
setOid
{},
trackNew
:
setOid
{},
trackSetZBlk
:
map
[
zodb
.
Oid
]
*
zblkTrack
{},
trackSetZBlk
:
map
[
zodb
.
Oid
]
*
zblkTrack
{},
}
}
...
@@ -226,10 +229,10 @@ func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, zb
...
@@ -226,10 +229,10 @@ func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, zb
rootObj
:=
path
[
0
]
.
(
*
btree
.
LOBTree
)
rootObj
:=
path
[
0
]
.
(
*
btree
.
LOBTree
)
root
:=
rootObj
.
POid
()
root
:=
rootObj
.
POid
()
files
,
ok
:=
δFtail
.
file
Idx
[
root
]
files
,
ok
:=
δFtail
.
file
sByRoot
[
root
]
if
!
ok
{
if
!
ok
{
files
=
setOid
{}
files
=
setOid
{}
δFtail
.
file
Idx
[
root
]
=
files
δFtail
.
file
sByRoot
[
root
]
=
files
}
}
files
.
Add
(
foid
)
files
.
Add
(
foid
)
...
@@ -420,7 +423,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
...
@@ -420,7 +423,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
//fmt.Printf("δB.ΔByRoot: %v\n", δB.ΔByRoot)
//fmt.Printf("δB.ΔByRoot: %v\n", δB.ΔByRoot)
for
root
,
δt
:=
range
δB
.
ΔByRoot
{
for
root
,
δt
:=
range
δB
.
ΔByRoot
{
//fmt.Printf("root: %v δt: %v\n", root, δt)
//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
// NOTE files might be empty e.g. if a zfile was tracked, then
// deleted, but the tree referenced by zfile.blktab is still
// deleted, but the tree referenced by zfile.blktab is still
// not-deleted, remains tracked and is changed.
// not-deleted, remains tracked and is changed.
...
@@ -484,7 +487,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
...
@@ -484,7 +487,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
continue
continue
}
}
//fmt.Printf("root: %v inblk: %v\n", root, inblk)
//fmt.Printf("root: %v inblk: %v\n", root, inblk)
files
:=
δFtail
.
file
Idx
[
root
]
files
:=
δFtail
.
file
sByRoot
[
root
]
for
file
:=
range
files
{
for
file
:=
range
files
{
δfile
,
ok
:=
δF
.
ByFile
[
file
]
δfile
,
ok
:=
δF
.
ByFile
[
file
]
if
!
ok
{
if
!
ok
{
...
@@ -510,21 +513,21 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
...
@@ -510,21 +513,21 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
//fmt.Printf("δZBigFile: %v\n", δ)
//fmt.Printf("δZBigFile: %v\n", δ)
// update .file
Idx
// update .file
sByRoot
if
δ
.
blktabOld
!=
xbtree
.
VDEL
{
if
δ
.
blktabOld
!=
xbtree
.
VDEL
{
files
,
ok
:=
δFtail
.
file
Idx
[
δ
.
blktabOld
]
files
,
ok
:=
δFtail
.
file
sByRoot
[
δ
.
blktabOld
]
if
ok
{
if
ok
{
files
.
Del
(
foid
)
files
.
Del
(
foid
)
if
len
(
files
)
==
0
{
if
len
(
files
)
==
0
{
delete
(
δFtail
.
file
Idx
,
δ
.
blktabOld
)
delete
(
δFtail
.
file
sByRoot
,
δ
.
blktabOld
)
}
}
}
}
}
}
if
δ
.
blktabNew
!=
xbtree
.
VDEL
{
if
δ
.
blktabNew
!=
xbtree
.
VDEL
{
files
,
ok
:=
δFtail
.
file
Idx
[
δ
.
blktabNew
]
files
,
ok
:=
δFtail
.
file
sByRoot
[
δ
.
blktabNew
]
if
!
ok
{
if
!
ok
{
files
=
setOid
{}
files
=
setOid
{}
δFtail
.
file
Idx
[
δ
.
blktabNew
]
=
files
δFtail
.
file
sByRoot
[
δ
.
blktabNew
]
=
files
}
}
files
.
Add
(
foid
)
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) {
...
@@ -485,14 +485,14 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
vδE
=
vδE
[
icut
:
]
vδE
=
vδE
[
icut
:
]
}
}
// verify δFtail.file
Idx
// verify δFtail.file
sByRoot
file
Idx
OK
:=
map
[
zodb
.
Oid
]
setOid
{}
file
sByRoot
OK
:=
map
[
zodb
.
Oid
]
setOid
{}
if
!
delfile
{
if
!
delfile
{
__
:=
setOid
{};
__
.
Add
(
foid
)
__
:=
setOid
{};
__
.
Add
(
foid
)
file
Idx
OK
[
t
.
Root
()]
=
__
file
sByRoot
OK
[
t
.
Root
()]
=
__
}
}
if
!
reflect
.
DeepEqual
(
δFtail
.
file
Idx
,
fileIdx
OK
)
{
if
!
reflect
.
DeepEqual
(
δFtail
.
file
sByRoot
,
filesByRoot
OK
)
{
t
.
Errorf
(
"file
Idx:
\n
have: %v
\n
want: %v"
,
δFtail
.
fileIdx
,
fileIdx
OK
)
t
.
Errorf
(
"file
sByRoot:
\n
have: %v
\n
want: %v"
,
δFtail
.
filesByRoot
,
filesByRoot
OK
)
}
}
// verify δftail.root
// 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