Commit ddec8cf5 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f0a60b56
......@@ -17,27 +17,39 @@
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
package δbtree
// XXX -> another package?
// Package xbtree complements package lab.nexedi.com/kirr/neo/go/zodb/btree.
//
// TODO move -> btree when ΔTail matures.
package xbtree
//go:generate ../../gen-set δbtree Tree *Tree zset_tree.go
//go:generate ../../gen-set δbtree Object interface{} zset_object.go
import (
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb/btree"
)
// ΔBTail reprsents tail of revisional changes to BTrees.
type Tree = btree.LOBTree
type Bucket = btree.LOBucket
type Node = btree.LONode
type Key = int64
// ΔTail reprsents tail of revisional changes to BTrees.
//
// It semantically consists of
//
// [](rev↑, (tree, []key)) ; rev ∈ (tail, head]
// [](rev↑, [](tree, []key)) ; rev ∈ (tail, head]
//
// and *partially* covers changes to BTrees.
// and covers changes to tracked subsets of BTrees. A tree subset becomes
// tracked via Track(path) request.
//
// XXX δB can convert δZ to btree changes, but only at least for δZ's objects
// that ∈ BTree subgraphs that were explicitly requested to be tracked by δB.
//
// XXX incremental; not full coverage
// XXX -> ΔBIndex ?
type ΔBTail struct {
// XXX concurency safety
type ΔTail struct {
//at // = head
δZtail *zodb.ΔTail
......@@ -49,10 +61,24 @@ type ΔBTail struct {
rootIdx map[zodb.Oid]SetTree // oid -> {} roots
}
// ΔRevEntry represents information about BTrees changes in one revision.
type ΔRevEntry struct {
Rev zodb.Tid
Changev []ΔTree
}
// ΔTree represents changes to one tree.
type ΔTree struct {
Root XXX
Keyv []Key
}
// Track adds tree path to tracked set.
//
// XXX path is at @at state.
// XXX objects in path must be with .PJar().At() == .head
// XXX path -> []oid ?
func (δb *ΔBTail) Track(path []zodb.IPersistent) { // XXX Tree|Bucket; path[0] = root
func (δb *ΔTail) Track(path []Node) { // XXX Tree|Bucket; path[0] = root
/*
root = path[0]
for obj in path:
......@@ -62,12 +88,12 @@ func (δb *ΔBTail) Track(path []zodb.IPersistent) { // XXX Tree|Bucket; path[0]
// Update updates δB with per-object level ZODB changes.
//
// XXX return -> [] of (root, []key) that are invalidated.
// Only those objects from δZ that belong to tracked set are guaranteed to be
// taken into account.
//
// XXX text ...
// XXX -> Append? -> Invalidate?
// XXX -> DiffTo ?
func (δB *ΔBTail) Update(δZ *zodb.EventCommit) {
// XXX return -> [] of (root, []key) that are invalidated.
// XXX -> + separate SliceByRev? or Data to get diff?
func (δB *ΔTail) Update(δZ *zodb.EventCommit) {
/*
.δZtail += δZ
δbZ = {}
......@@ -91,17 +117,16 @@ func (δB *ΔBTail) Update(δZ *zodb.EventCommit) {
diff(B, B')
...
XXX rebuild something?
-> [] of (root, []key)
.tailv <- [] of (root, []key)
*/
}
// XXX -> Get(root, key, at) -> (valueOid, rev) ?
func (δB *ΔBTail) LastRevOf(root Tree, key Key, at zodb.Tid) zodb.Tid {
func (δB *ΔTail) LastRevOf(root Tree, key Key, at zodb.Tid) zodb.Tid {
panic("TODO") // XXX return 0 as stub?
}
func (δB *ΔBTail) ForgetPast(revCut zodb.Tid) {
func (δB *ΔTail) ForgetPast(revCut zodb.Tid) {
panic("TODO")
}
......@@ -248,11 +248,15 @@ package main
// #blk ∈ OS file cache => ZBlk(#blk) + all BTree/Bucket that lead to it ∈ zhead cache(%)
// (ZBlk* in ghost state)
//
// => all BTree/Bucket that lead to blk are tracked (XXX)
//
// The invariant helps on invalidation: if we see a changed oid, and
// zhead.cache.lookup(oid) = ø -> we know we don't have to invalidate OS
// cache for any part of any file (even if oid relates to a file block - that
// block is not cached and will trigger ZODB load on file read).
//
// XXX explain why tracked
//
// Currently we maintain this invariant by simply never evicting ZBlk/LOBTree/LOBucket
// objects from ZODB Connection cache. In the future we may want to try to
// synchronize to kernel freeing its pagecache pages.
......
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