Commit 6b23c395 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 0ed8303d
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
// See https://www.nexedi.com/licensing for rationale and options. // See https://www.nexedi.com/licensing for rationale and options.
package main package main
// ΔFtail - merge btree.ΔTail with history of ZBlk
import ( import (
"lab.nexedi.com/kirr/neo/go/zodb" "lab.nexedi.com/kirr/neo/go/zodb"
...@@ -51,8 +50,9 @@ import ( ...@@ -51,8 +50,9 @@ import (
// //
// //
// XXX only tracked blocks. // XXX only tracked blocks.
// XXX ΔFtail - merge btree.ΔTail with history of ZBlk
type ΔFtail struct { type ΔFtail struct {
*xbtree.ΔTail δBtail *xbtree.ΔTail
fileIdx map[*btree.LOBTree]SetBigFile // root -> {} BigFile XXX root -> oid? fileIdx map[*btree.LOBTree]SetBigFile // root -> {} BigFile XXX root -> oid?
} }
...@@ -64,21 +64,26 @@ type ΔF struct { ...@@ -64,21 +64,26 @@ type ΔF struct {
func NewΔFTail(at0 zodb.Tid) *ΔFtail { func NewΔFTail(at0 zodb.Tid) *ΔFtail {
return &ΔFtail{ return &ΔFtail{
ΔTail: xbtree.NewΔTail(at0), δBtail: xbtree.NewΔTail(at0),
fileIdx: make(map[*btree.LOBTree]SetBigFile), fileIdx: make(map[*btree.LOBTree]SetBigFile),
} }
} }
// XXX
func (δFtail *ΔFtail) Head() zodb.Tid { panic("TODO") }
func (δFtail *ΔFtail) Tail() zodb.Tid { panic("TODO") }
// Track adds tree path to tracked set and associates path root with file. // Track adds tree path to tracked set and associates path root with file.
// //
// A root can be associated with several files (each provided on different Track call). // A root can be associated with several files (each provided on different Track call).
func (δf *ΔFtail) Track(file *BigFile, path []btree.LONode) { func (δFtail *ΔFtail) Track(file *BigFile, path []btree.LONode) {
δf.ΔTail.Track(path) δFtail.δBtail.Track(path)
root := path[0].(*btree.LOBTree) root := path[0].(*btree.LOBTree)
files, ok := δf.fileIdx[root] files, ok := δFtail.fileIdx[root]
if !ok { if !ok {
files = SetBigFile{} files = SetBigFile{}
δf.fileIdx[root] = files δFtail.fileIdx[root] = files
} }
files.Add(file) files.Add(file)
} }
...@@ -87,7 +92,7 @@ func (δf *ΔFtail) Track(file *BigFile, path []btree.LONode) { ...@@ -87,7 +92,7 @@ func (δf *ΔFtail) Track(file *BigFile, path []btree.LONode) {
// //
// It returns corresponding change in files space. // It returns corresponding change in files space.
func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) ΔF { func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) ΔF {
δB := δFtail.ΔTail.Update(δZ) δB := δFtail.δBtail.Update(δZ)
δF := ΔF{Rev: δB.Rev, Change: make(map[*BigFile]SetI64)} δF := ΔF{Rev: δB.Rev, Change: make(map[*BigFile]SetI64)}
for root, δt := range δB.Change { for root, δt := range δB.Change {
files := δFtail.fileIdx[root] files := δFtail.fileIdx[root]
...@@ -120,9 +125,9 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) ΔF { ...@@ -120,9 +125,9 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) ΔF {
// //
// XXX -> LastTrackedBlkRev ? // XXX -> LastTrackedBlkRev ?
func (f *BigFile) LastBlkRev(blk int64, at zodb.Tid) (_ zodb.Tid, exact bool) { func (f *BigFile) LastBlkRev(blk int64, at zodb.Tid) (_ zodb.Tid, exact bool) {
δf := f.head.bfdir.δFtail δFtail := f.head.bfdir.δFtail
zblkOid, ok, tabRev, tabRevExact := δf.ΔTail.Get(f.zfile.blktab, blk, at) zblkOid, ok, tabRev, tabRevExact := δFtail.δBtail.Get(f.zfile.blktab, blk, at)
// block was removed // block was removed
// XXX or not in tracked set? // XXX or not in tracked set?
...@@ -134,7 +139,7 @@ func (f *BigFile) LastBlkRev(blk int64, at zodb.Tid) (_ zodb.Tid, exact bool) { ...@@ -134,7 +139,7 @@ func (f *BigFile) LastBlkRev(blk int64, at zodb.Tid) (_ zodb.Tid, exact bool) {
// blk revision is max rev and when zblk changed last in (rev, at] range. // blk revision is max rev and when zblk changed last in (rev, at] range.
// //
// XXX need to use full δZ, not only connected to tracked subset? // XXX need to use full δZ, not only connected to tracked subset?
zblkRev, zblkRevExact := δf.ΔTail.ΔZtail.LastRevOf(zblkOid, at) zblkRev, zblkRevExact := δFtail.δBtail.ΔZtail.LastRevOf(zblkOid, at)
if zblkRev > tabRev { if zblkRev > tabRev {
return zblkRev, zblkRevExact return zblkRev, zblkRevExact
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment