Commit 0ed8303d authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 2b918c95
......@@ -38,19 +38,12 @@ type Key = int64
type Value = zodb.Oid // XXX assumes key points to IPersistent
// XXX how to represent deletion? InvalidOid?
// ΔB represents a change in BTrees space.
//
// XXX place
type ΔB struct {
Rev zodb.Tid
Change map[*Tree]map[Key]Value // {} root -> {}(key, value)
}
// ΔTail represents tail of revisional changes to BTrees.
//
// It semantically consists of
//
// []δB ; rev ∈ (tail, head
// []δB ; rev ∈ (tail, head]
// atTail
//
// where δB represents a change in BTrees space
//
......@@ -58,7 +51,10 @@ type ΔB struct {
// .rev↑
// {} root -> {}(key, value)
//
// XXX + atTail
// and atTail keeps set of k/v @tail for keys changed in (tail, head]
//
// atTail:
// {} root -> {}(key, value)
//
// It covers changes to keys from tracked subset of BTrees parts and
// semantically consists of
......@@ -111,6 +107,13 @@ type ΔTail struct {
trackNew map[zodb.Oid]struct{} // XXX SetOid
}
// Δ represents a change in BTrees space.
type Δ struct {
Rev zodb.Tid
Change map[*Tree]map[Key]Value // {} root -> {}(key, value)
}
// ΔRoots describes which BTrees were change in one revision.
// XXX kill?
type ΔRoots struct {
......@@ -204,9 +207,7 @@ func (δb *ΔTail) Track(path []Node) { // XXX Tree|Bucket; path[0] = root
// Only those objects from δZ that belong to tracked set are guaranteed to be
// taken into account. In other words a tree history will assuredly include
// only those keys, that correspond to tracked subset of δZ.
//
// XXX returned [](root, []key) -> move to separate SliceByRev to get diff?
func (btail *ΔTail) Update(δZ *zodb.EventCommit) ΔB {
func (btail *ΔTail) Update(δZ *zodb.EventCommit) Δ {
btail.ΔZtail.Append(δZ.Tid, δZ.Changev)
// {} root -> []oid changed under that root
......@@ -221,7 +222,7 @@ func (btail *ΔTail) Update(δZ *zodb.EventCommit) ΔB {
}
}
δB := ΔB{Rev: δZ.Tid, Change: make(map[*Tree]map[Key]Value)}
δB := Δ{Rev: δZ.Tid, Change: make(map[*Tree]map[Key]Value)}
if len(δZByRoot) == 0 {
return δB // tracked set not changed
......
......@@ -508,7 +508,7 @@ type BigFileDir struct {
// δ of tracked BTree nodes of all BigFiles + -> which file
// (used only for head/, not revX/)
δFmu sync.RWMutex
δFtail *ΔFTail
δFtail *ΔFtail
}
// /(head|<rev>)/bigfile/<bigfileX> - served by BigFile.
......
......@@ -51,7 +51,7 @@ import (
//
//
// XXX only tracked blocks.
type ΔFTail struct {
type ΔFtail struct {
*xbtree.ΔTail
fileIdx map[*btree.LOBTree]SetBigFile // root -> {} BigFile XXX root -> oid?
}
......@@ -62,8 +62,8 @@ type ΔF struct {
Change map[*BigFile]SetI64 // file -> δfile (= {}#blk)
}
func NewΔFTail(at0 zodb.Tid) *ΔFTail {
return &ΔFTail{
func NewΔFTail(at0 zodb.Tid) *ΔFtail {
return &ΔFtail{
ΔTail: xbtree.NewΔTail(at0),
fileIdx: make(map[*btree.LOBTree]SetBigFile),
}
......@@ -72,7 +72,7 @@ func NewΔFTail(at0 zodb.Tid) *ΔFTail {
// 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).
func (δf *ΔFTail) Track(file *BigFile, path []btree.LONode) {
func (δf *ΔFtail) Track(file *BigFile, path []btree.LONode) {
δf.ΔTail.Track(path)
root := path[0].(*btree.LOBTree)
files, ok := δf.fileIdx[root]
......@@ -86,13 +86,13 @@ func (δf *ΔFTail) Track(file *BigFile, path []btree.LONode) {
// Update updates δFtail given raw ZODB changes.
//
// 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)
δF := ΔF{Rev: δB.Rev, Change: make(map[*BigFile]SetI64)}
for root, δt := range δB.Change {
files := δFtail.fileIdx[root]
if len(files) == 0 {
panicf("ΔFTail: root<%s> -> ø file", root.POid())
panicf("ΔFtail: root<%s> -> ø file", root.POid())
}
for file := range files {
δfile, ok := δF.Change[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