Commit 9214be19 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 790bee70
......@@ -38,6 +38,12 @@ type Key = int64
type Value = zodb.Oid // XXX assumes key points to IPersistent
// XXX how to represent deletion? InvalidOid?
// XXX
//
// δB:
// .rev↑
// {} root -> {}(key, value)
// ΔTail represents tail of revisional changes to BTrees.
//
// It covers changes to keys from tracked subset of BTrees parts and
......@@ -59,9 +65,9 @@ type Value = zodb.Oid // XXX assumes key points to IPersistent
// It provides the following operations:
//
// - Track(path) - start tracking tree nodes and keys; root=path[0], keys=path[-1].keys
// - ForgetPast(revCut) - forget changes past revCut
// - Get(root, key, at) - get root[key] @at assuming root[key] ∈ tracked
// - Update(δZ) - update BTree δ tail given raw ZODB changes
// - ForgetPast(revCut) - forget changes past revCut
//
// An example for tracked set is a set of visited BTree paths.
// There is no requirement that tracked set belongs to only one single BTree.
......
......@@ -402,10 +402,10 @@ package main
// XXX notation
//
// δZ - changes in ZODB space
// δB - changes in BTree*s* space
// δF - changes in File*s* space
// δfile - changes in File(1) space
// δZ - change in ZODB space
// δB - change in BTree*s* space
// δF - change in File*s* space
// δfile - change in File(1) space
import (
"bufio"
......@@ -801,9 +801,9 @@ retry:
//fmt.Printf("\nbtreeChangev: %v\n", btreeChangev)
δf := bfdir.δFtail.Update(δZ)
//fmt.Printf("xfiles: %v\n", xfiles)
for _, δ := range δf.Changev {
file := δ.File
// XXX use δ.Blkv
for file, δfile := range δf.Change {
// XXX use δfile blocks
_ = δfile
finv, ok := toinvalidate[file]
if !ok {
finv = &fileInvalidate{} // XXX init blkmap?
......
......@@ -27,21 +27,39 @@ import (
"./internal/xbtree"
)
// ΔFTail is like btree.ΔTail but additionally tracks tree-root -> file relation and
// takes ZBlk history into account.
// ΔFtail represents tail of revisional changes to files.
//
// It semantically consists of
//
// []δF ; rev ∈ (tail, head]
//
// where δF represents a change in files space
//
// δF:
// .rev↑
// [](file, []blk)
//
// It provides the following operations:
//
// .Update(δZ) -> δF - update files δ tail given raw ZODB changes
// .ForgetPast(revCut) - forget changes past revCut
// .Track XXX
// .SliceByRev(lo, hi) -> []δF - query for all changes with rev ∈ (lo, hi]
// .SliceByFileRev(file, lo, hi) -> []δfile - query for changes of file with rev ∈ (lo, hi]
// .LastBlkRev(file, #blk, at) - query for what is last revision that
// changed file[#blk] as of @at database state.
//
//
// XXX only tracked blocks.
type ΔFTail struct {
*xbtree.ΔTail
fileIdx map[*btree.LOBTree]SetBigFile // root -> {} BigFile XXX root -> oid?
}
type ΔFentry struct {
// ΔF represents a change in files space.
type ΔF struct {
Rev zodb.Tid
Changev []ΔFile
}
type ΔFile struct {
File *BigFile
Blkv []int64
Change map[*BigFile]SetI64 // file -> δfile (= {}#blk)
}
func NewΔFTail(at0 zodb.Tid) *ΔFTail {
......@@ -65,33 +83,32 @@ func (δf *ΔFTail) Track(file *BigFile, path []btree.LONode) {
files.Add(file)
}
// XXX
func (δf *ΔFTail) Update(δZ *zodb.EventCommit) ΔFentry {
δB := δf.ΔTail.Update(δZ)
var changev []ΔFile // δB root -> file (via .fileIdx)
for _, δ := range δB {
files := δf.fileIdx[δ.Root]
// Update updates δFtail given raw ZODB changes.
//
// It returns corresponding change in files space.
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 {
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 {
var blkv []int64
for blk /*, zblk*/ := range δ.KV {
δfile, ok := δF.Change[file]
if !ok {
δfile = make(SetI64)
δF.Change[file] = δfile
}
for blk /*, zblk*/ := range δt.KV {
// FIXME stub - need to take both keys and zblk changes into account
// XXX document, and in particular how to include atTail
blkv = append(blkv, blk)
δfile.Add(blk)
}
changev = append(changev, ΔFile{
File: file,
Blkv: blkv,
})
}
}
return ΔFentry{
Rev: δZ.Tid,
Changev: changev,
}
return δF
}
// LastBlkRev returns last revision that changed file[blk] as of @at database state.
......
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