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
9c90d3f4
Commit
9c90d3f4
authored
Jul 14, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7fbd0360
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
15 deletions
+40
-15
wcfs/internal/zdata/δftail.go
wcfs/internal/zdata/δftail.go
+40
-15
No files found.
wcfs/internal/zdata/δftail.go
View file @
9c90d3f4
...
...
@@ -81,13 +81,27 @@ type setOid = set.Oid
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
rootIdx
map
[
zodb
.
Oid
]
zodb
.
Oid
// file -> tree-root as of @head
fileIdx
map
[
zodb
.
Oid
]
setOid
// tree-root -> {} ZBigFile<oid> as of @head XXX -> root2file ?
// rootIdx map[zodb.Oid]zodb.Oid // file -> tree-root as of @head
byFile
map
[
zodb
.
Oid
]
*
_ΔFileTail
// file -> δf tail XXX
trackSetZFile
setOid
// set of tracked ZBigFiles as of @head
//
trackSetZFile setOid // set of tracked ZBigFiles as of @head
trackSetZBlk
map
[
zodb
.
Oid
]
*
zblkTrack
// zblk -> {} root -> {}blk as of @head
}
// _ΔFileTail represents tail of revisional changes to one file.
type
_ΔFileTail
struct
{
root
zodb
.
Oid
// .blktab as of @head
vδE
[]
_ΔFileEpoch
// changes to ZBigFile object itself ; nil if not yet rebuilt
}
// _ΔFileEpoch represent change to ZBigFile object.
type
_ΔFileEpoch
struct
{
Rev
zodb
.
Tid
newRoot
zodb
.
Oid
// .blktab was changed to point to newRoot ; VDEL if ZBigFile deleted
newBlkSize
int64
// .blksize was changed to newBlkSize ; -1 if ZBigFile deleted
}
// zblkTrack keeps information in which root/blocks ZBlk is present as of @head.
type
zblkTrack
struct
{
inroot
map
[
zodb
.
Oid
]
setI64
// {} root -> {}blk
...
...
@@ -118,8 +132,9 @@ func NewΔFtail(at0 zodb.Tid, db *zodb.DB) *ΔFtail {
return
&
ΔFtail
{
δBtail
:
xbtree
.
NewΔBtail
(
at0
,
db
),
fileIdx
:
map
[
zodb
.
Oid
]
setOid
{},
rootIdx
:
map
[
zodb
.
Oid
]
zodb
.
Oid
{},
trackSetZFile
:
setOid
{},
// rootIdx: map[zodb.Oid]zodb.Oid{},
// trackSetZFile: setOid{},
byFile
:
map
[
zodb
.
Oid
]
*
_ΔFileTail
{},
trackSetZBlk
:
map
[
zodb
.
Oid
]
*
zblkTrack
{},
}
}
...
...
@@ -163,17 +178,17 @@ func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, zb
}
files
.
Add
(
foid
)
roid_
,
ok
:=
δFtail
.
rootIdx
[
foid
]
if
ok
{
if
roid
!=
roid_
{
panicf
(
"zfile<%s> changed root from %s -> %s"
,
foid
,
roid_
,
roid
)
}
}
else
{
δFtail
.
rootIdx
[
foid
]
=
roid
δftail
,
ok
:=
δFtail
.
byFile
[
foid
]
if
!
ok
{
δftail
=
&
_ΔFileTail
{
root
:
roid
,
vδE
:
nil
/*will need to be rebuilt till past*/
}
δFtail
.
byFile
[
foid
]
=
δftail
}
if
δftail
.
root
!=
roid
{
panicf
(
"zfile<%s> changed root from %s -> %s"
,
foid
,
δftail
.
root
,
roid
)
}
δFtail
.
trackSetZFile
.
Add
(
foid
)
//
δFtail.trackSetZFile.Add(foid)
// associate zblk with file, if it was not hole
if
zblk
!=
nil
{
...
...
@@ -282,7 +297,8 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
// take zblk changes into account
δzfile
:=
map
[
zodb
.
Oid
]
*
_ΔZBigFile
{}
// which tracked ZBigFiles are changed
for
_
,
oid
:=
range
δZ
.
Changev
{
if
δFtail
.
trackSetZFile
.
Has
(
oid
)
{
δftail
,
ok
:=
δFtail
.
byFile
[
oid
]
if
ok
{
δ
,
err
:=
zfilediff
(
δFtail
.
δBtail
.
DB
(),
oid
,
headOld
,
δZ
.
Tid
)
if
err
!=
nil
{
return
ΔF
{},
err
...
...
@@ -290,6 +306,11 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
if
δ
!=
nil
{
δzfile
[
oid
]
=
δ
δftail
.
vδE
=
append
(
δftail
.
vδE
,
_ΔFileEpoch
{
Rev
:
δZ
.
Tid
,
newRoot
:
δ
.
blktabNew
,
newBlkSize
:
δ
.
blksizeNew
,
})
}
continue
...
...
@@ -373,6 +394,7 @@ func (δFtail *ΔFtail) SliceByFileRev(zfile *ZBigFile, lo, hi zodb.Tid) /*reado
// query .δBtail.SliceByRootRev(file.blktab, lo, hi) +
// merge δZBlk history with that.
// merging tree (δT) and Zblk (δZblk) histories into file history (δFile):
// δT ────────·──────────────·─────────────────·────────────
...
...
@@ -387,7 +409,8 @@ func (δFtail *ΔFtail) SliceByFileRev(zfile *ZBigFile, lo, hi zodb.Tid) /*reado
// δFile ────────o───────o──────x─────x────────────────────────
root
:=
δFtail
.
rootIdx
[
zfile
.
POid
()]
δftail
:=
δFtail
.
byFile
[
zfile
.
POid
()]
root
:=
δftail
.
root
// XXX take epochs into account
vδT
:=
δFtail
.
δBtail
.
SliceByRootRev
(
root
,
lo
,
δFtail
.
Head
())
// NOTE @head, not hi
vδZ
:=
δFtail
.
δBtail
.
ΔZtail
()
.
SliceByRev
(
lo
,
hi
)
...
...
@@ -514,6 +537,8 @@ func (δFtail *ΔFtail) LastBlkRev(ctx context.Context, zf *ZBigFile, blk int64,
}
defer
zf
.
PDeactivate
()
// XXX take epochs into account
// XXX tabRev -> treeRev ?
zblkOid
,
ok
,
tabRev
,
tabRevExact
,
err
:=
δFtail
.
δBtail
.
GetAt
(
ctx
,
zf
.
blktab
,
blk
,
at
)
//fmt.Printf("GetAt #%d @%s -> %s, %v, @%s, %v\n", blk, at, zblkOid, ok, tabRev, tabRevExact)
...
...
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