Commit d348e51f authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 97acef76
...@@ -40,6 +40,7 @@ type Key = int64 ...@@ -40,6 +40,7 @@ type Key = int64
type Value = zodb.Oid // assumes key points to IPersistent type Value = zodb.Oid // assumes key points to IPersistent
// deletion is represented as InvalidOid // deletion is represented as InvalidOid
type SetKey = SetI64 type SetKey = SetI64
// XXX SetOID
// ΔBtail represents tail of revisional changes to BTrees. // ΔBtail represents tail of revisional changes to BTrees.
...@@ -97,7 +98,7 @@ type ΔBtail struct { ...@@ -97,7 +98,7 @@ type ΔBtail struct {
db *zodb.DB // to open connections to load new/old tree|buckets db *zodb.DB // to open connections to load new/old tree|buckets
// tracked index: BTree|Bucket -> top tree element. // tracked index: BTree|Bucket -> top tree element.
trackIdx map[zodb.Oid]SetTree // oid -> {} roots XXX root -> oid? trackIdx map[zodb.Oid]SetTree // oid -> {} roots XXX root -> oid
// tracked objects that are not yet taken into account in current δBtail // tracked objects that are not yet taken into account in current δBtail
trackNew map[zodb.Oid]struct{} // XXX SetOid trackNew map[zodb.Oid]struct{} // XXX SetOid
...@@ -106,7 +107,7 @@ type ΔBtail struct { ...@@ -106,7 +107,7 @@ type ΔBtail struct {
// ΔB represents a change in BTrees space. // ΔB represents a change in BTrees space.
type ΔB struct { type ΔB struct {
Rev zodb.Tid Rev zodb.Tid
ByRoot map[*Tree]map[Key]Value // {} root -> {}(key, value) ByRoot map[zodb.Oid]map[Key]Value // {} root -> {}(key, value)
} }
// ΔRoots describes which BTrees were change in one revision. // ΔRoots describes which BTrees were change in one revision.
...@@ -211,18 +212,18 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) ΔB { ...@@ -211,18 +212,18 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) ΔB {
δBtail.δZtail.Append(δZ.Tid, δZ.Changev) δBtail.δZtail.Append(δZ.Tid, δZ.Changev)
// {} root -> []oid changed under that root in tracked set // {} root -> []oid changed under that root in tracked set
δZByRoot := map[*Tree][]zodb.Oid{} // XXX -> map[*Tree]SetOid ? δZByRoot := map[zodb.Oid][]zodb.Oid{} // XXX -> map[*Tree]SetOid ?
for _, oid := range δZ.Changev { for _, oid := range δZ.Changev {
roots, ok := δBtail.trackIdx[oid] roots, ok := δBtail.trackIdx[oid]
if !ok { if !ok {
continue continue
} }
for root := range roots { for root := range roots {
δZByRoot[root] = append(δZByRoot[root], oid) δZByRoot[root.POid()] = append(δZByRoot[root.POid()], oid)
} }
} }
δB := ΔB{Rev: δZ.Tid, ByRoot: make(map[*Tree]map[Key]Value)} δB := ΔB{Rev: δZ.Tid, ByRoot: make(map[zodb.Oid]map[Key]Value)}
for root := range δZByRoot { for root := range δZByRoot {
δt, ok := δB.ByRoot[root] δt, ok := δB.ByRoot[root]
......
...@@ -68,7 +68,7 @@ import ( ...@@ -68,7 +68,7 @@ import (
type ΔFtail struct { type ΔFtail struct {
// ΔFtail merges btree.ΔTail with history of ZBlk // ΔFtail merges btree.ΔTail with history of ZBlk
δBtail *ΔBtail δBtail *ΔBtail
fileIdx map[*btree.LOBTree]SetBigFile // root -> {} BigFile XXX root -> oid? XXX as of @head? fileIdx map[zodb.Oid]SetBigFile // tree-root -> {} BigFile XXX as of @head?
// data with δF changes. Actual for part of tracked set that was taken // data with δF changes. Actual for part of tracked set that was taken
// into account. // into account.
...@@ -113,7 +113,7 @@ func (z *zblkInΔFtail) inΔFtail() *zblkInΔFtail { return z } ...@@ -113,7 +113,7 @@ func (z *zblkInΔFtail) inΔFtail() *zblkInΔFtail { return z }
func NewΔFtail(at0 zodb.Tid) *ΔFtail { func NewΔFtail(at0 zodb.Tid) *ΔFtail {
return &ΔFtail{ return &ΔFtail{
δBtail: NewΔBtail(at0), δBtail: NewΔBtail(at0),
fileIdx: make(map[*btree.LOBTree]SetBigFile), fileIdx: make(map[zodb.Oid]SetBigFile),
trackNew: make(map[*BigFile]map[zodb.Oid]*zblkInΔFtail), trackNew: make(map[*BigFile]map[zodb.Oid]*zblkInΔFtail),
} }
} }
...@@ -136,10 +136,10 @@ func (δFtail *ΔFtail) Tail() zodb.Tid { return δFtail.δBtail.Tail() } ...@@ -136,10 +136,10 @@ func (δFtail *ΔFtail) Tail() zodb.Tid { return δFtail.δBtail.Tail() }
func (δFtail *ΔFtail) Track(file *BigFile, blk int64, path []btree.LONode, zblk zBlk) { func (δFtail *ΔFtail) Track(file *BigFile, blk int64, path []btree.LONode, zblk zBlk) {
δFtail.δBtail.Track(path) δFtail.δBtail.Track(path)
root := path[0].(*btree.LOBTree) root := path[0].(*btree.LOBTree)
files, ok := δFtail.fileIdx[root] files, ok := δFtail.fileIdx[root.POid()]
if !ok { if !ok {
files = SetBigFile{} files = SetBigFile{}
δFtail.fileIdx[root] = files δFtail.fileIdx[root.POid()] = files
} }
files.Add(file) files.Add(file)
...@@ -200,7 +200,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit, zhead *ZConn) ΔF { ...@@ -200,7 +200,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit, zhead *ZConn) ΔF {
for root, δt := range δB.ByRoot { for root, δt := range δB.ByRoot {
files := δFtail.fileIdx[root] files := δFtail.fileIdx[root]
if len(files) == 0 { if len(files) == 0 {
panicf("ΔFtail: root<%s> -> ø file", root.POid()) panicf("ΔFtail: root<%s> -> ø file", root)
} }
for file := range files { for file := range files {
δfile, ok := δF.ByFile[file] δfile, ok := δF.ByFile[file]
......
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