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
e7b598c6
Commit
e7b598c6
authored
Jul 09, 2021
by
Kirill Smelkov
2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X start of ΔFtail.SliceByFileRev rework to function via merging δB and δZ histories on the fly
parent
19c593ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
70 deletions
+56
-70
wcfs/internal/zdata/δftail.go
wcfs/internal/zdata/δftail.go
+56
-70
No files found.
wcfs/internal/zdata/δftail.go
View file @
e7b598c6
...
...
@@ -81,7 +81,7 @@ type ΔFtail struct {
trackSetZBlk
map
[
zodb
.
Oid
]
*
zblkTrack
// zblk -> {} root -> {}blk as of @head
// XXX kill
/
//
*
/*
// XXX don't need vδF - everything is reconstructed at runtime from .δBtail.vδT
// this way we also don't need to keep up updating vδF from vδT on its rebuild during.
// data with δF changes. Actual for part of tracked set that was taken
...
...
@@ -91,7 +91,7 @@ type ΔFtail struct {
// tracked ZBlk that are not yet taken into account in current vδF.
// grows on new track requests; flushes on queries and update.
trackNew map[zodb.Oid]map[zodb.Oid]*zblkTrack // {} foid -> {} zoid -> zblk
//
*/
*/
}
// zblkTrack keeps information in which root/blocks ZBlk is present as of @head.
...
...
@@ -126,7 +126,7 @@ func NewΔFtail(at0 zodb.Tid, db *zodb.DB) *ΔFtail {
fileIdx
:
map
[
zodb
.
Oid
]
setOid
{},
trackSetZFile
:
setOid
{},
trackSetZBlk
:
map
[
zodb
.
Oid
]
*
zblkTrack
{},
trackNew
:
map
[
zodb
.
Oid
]
map
[
zodb
.
Oid
]
*
zblkTrack
{},
//
trackNew: map[zodb.Oid]map[zodb.Oid]*zblkTrack{},
}
}
...
...
@@ -190,6 +190,7 @@ func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, zb
}
inblk
.
Add
(
blk
)
/* XXX kill
if !ok {
// zblk was not associated with this file
ft := δFtail.trackNew[foid]
...
...
@@ -199,17 +200,8 @@ func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, zb
}
ft[zoid] = zt
}
}
// XXX mark something dirty so that LastBlkRev and Slice* know what to rebuild?
// XXX debug
/*
leaf := path[len(path)-1].(*btree.LOBucket)
for _, e := range leaf.Entryv() { // XXX activate
δFtail.tracked.Add(e.Key())
}
*/
}
}
// Update updates δFtail given raw ZODB changes.
...
...
@@ -225,7 +217,6 @@ func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, zb
//func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit, zhead *xzodb.ZConn) (_ ΔF, err error) {
func
(
δFtail
*
ΔFtail
)
Update
(
δZ
*
zodb
.
EventCommit
)
(
_
ΔF
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"ΔFtail update %s -> %s"
,
δFtail
.
Head
(),
δZ
.
Tid
)
// XXX δFtail.update() first?
// XXX verify zhead.At() == δFtail.Head()
// XXX locking
...
...
@@ -328,10 +319,11 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
// fmt.Printf("-> δF: %v\n", δF)
δFtail
.
vδF
=
append
(
δFtail
.
vδF
,
δF
)
//
δFtail.vδF = append(δFtail.vδF, δF)
return
δF
,
nil
}
/*
// XXX kill after vδF is gone
// update processes new track requests and updates vδF.
//
...
...
@@ -378,6 +370,7 @@ func (δFtail *ΔFtail) update(file *ZBigFile) {
}
}
}
*/
// ForgetPast discards all δFtail entries with rev ≤ revCut.
func
(
δFtail
*
ΔFtail
)
ForgetPast
(
revCut
zodb
.
Tid
)
{
...
...
@@ -399,50 +392,11 @@ func (δFtail *ΔFtail) ForgetPast(revCut zodb.Tid) {
// the caller must not modify returned slice.
//
// Note: contrary to regular go slicing, low is exclusive while high is inclusive.
func
(
δFtail
*
ΔFtail
)
SliceByFileRev
(
file
*
ZBigFile
,
lo
,
hi
zodb
.
Tid
)
/*readonly*/
[]
*
ΔFile
{
func
(
δFtail
*
ΔFtail
)
SliceByFileRev
(
z
file
*
ZBigFile
,
lo
,
hi
zodb
.
Tid
)
/*readonly*/
[]
*
ΔFile
{
xtail
.
AssertSlice
(
δFtail
,
lo
,
hi
)
// FIXME rework to just query .δBtail.SliceByRootRev(file.blktab, lo, hi) +
// merge δZBlk history with that.
// XXX locking?
δFtail
.
update
(
file
)
// find vδF range corresponding to (lo, hi]
// XXX linear scan
vδF
:=
δFtail
.
vδF
if
len
(
vδF
)
==
0
{
return
nil
}
// find max j : [j].rev ≤ hi XXX linear scan -> binary search
j
:=
len
(
vδF
)
-
1
for
;
j
>=
0
&&
vδF
[
j
]
.
Rev
>
hi
;
j
--
{}
if
j
<
0
{
return
nil
// ø
}
// find max i : [i].rev > low XXX linear scan -> binary search
i
:=
j
for
;
i
>=
0
&&
vδF
[
i
]
.
Rev
>
lo
;
i
--
{}
i
++
vδF
=
vδF
[
i
:
j
+
1
]
// filter found changed to have only file-related bits
foid
:=
file
.
POid
()
var
vδfile
[]
*
ΔFile
for
_
,
δF
:=
range
vδF
{
δfile
,
ok
:=
δF
.
ByFile
[
foid
]
if
ok
{
vδfile
=
append
(
vδfile
,
δfile
)
}
}
// XXX merge into vδF zblk from not yet handled tracked part
return
vδfile
// query .δBtail.SliceByRootRev(file.blktab, lo, hi) +
// merge δZBlk history with that.
// merging tree (δT) and Zblk (δZblk) histories into file history (δFile):
...
...
@@ -457,19 +411,10 @@ func (δFtail *ΔFtail) SliceByFileRev(file *ZBigFile, lo, hi zodb.Tid) /*readon
//
// δFile ────────o───────o──────x─────x────────────────────────
/*
vδZ := δFtail.δBtail.ΔZtail().SliceByRev(lo, hi)
// XXX stub that takes only ZBlk changes into account
// XXX dumb
for _, δZ := range vδZ {
}
*/
/*
// XXX activate zfile?
vδT := δFtail.δBtail.SliceByRootRev(file.zfile.blktab, lo, hi)
vδT
:=
δFtail
.
δBtail
.
SliceByRootRev
(
zfile
.
blktab
,
lo
,
hi
)
// XXX needs activate zfile
vδZ
:=
δFtail
.
δBtail
.
ΔZtail
()
.
SliceByRev
(
lo
,
hi
)
var
vδf
[]
*
ΔFile
// state of `{} blk -> zblk` as we are scanning ↓
δblktab
:=
map
[
int64
]
struct
{
...
...
@@ -497,8 +442,49 @@ func (δFtail *ΔFtail) SliceByFileRev(file *ZBigFile, lo, hi zodb.Tid) /*readon
...
}
}
*/
return
vδf
/*
// XXX locking?
δFtail.update(file)
// find vδF range corresponding to (lo, hi]
// XXX linear scan
vδF := δFtail.vδF
if len(vδF) == 0 {
return nil
}
// find max j : [j].rev ≤ hi XXX linear scan -> binary search
j := len(vδF)-1
for ; j >= 0 && vδF[j].Rev > hi; j-- {}
if j < 0 {
return nil // ø
}
// find max i : [i].rev > low XXX linear scan -> binary search
i := j
for ; i >= 0 && vδF[i].Rev > lo; i-- {}
i++
vδF = vδF[i:j+1]
// filter found changed to have only file-related bits
foid := file.POid()
var vδfile []*ΔFile
for _, δF := range vδF {
δfile, ok := δF.ByFile[foid]
if ok {
vδfile = append(vδfile, δfile)
}
}
// XXX merge into vδF zblk from not yet handled tracked part
return vδfile
*/
}
// XXX rename -> BlkRevAt
...
...
Kirill Smelkov
@kirr
mentioned in commit
23d8da82
·
Oct 27, 2021
mentioned in commit
23d8da82
mentioned in commit 23d8da82b89134b00ae8dafeb0a5c7348dd8b4fe
Toggle commit list
Kirill Smelkov
@kirr
mentioned in commit
f980471f
·
Oct 28, 2021
mentioned in commit
f980471f
mentioned in commit f980471f6bd466f7da6fbe6753a7a14b1d3c8151
Toggle commit list
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