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

.

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