Commit 25a4723c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent dedcb356
......@@ -20,6 +20,10 @@
package δbtree
// XXX -> another package?
import (
"lab.nexedi.com/kirr/neo/go/zodb"
)
// ΔBTail reprsents tail of revisional changes to BTrees.
//
// It semantically consists of
......@@ -32,6 +36,7 @@ package δbtree
// that ∈ BTree subgraphs that were explicitly requested to be tracked by δB.
//
// XXX incremental; not full coverage
// XXX -> ΔBIndex ?
type ΔBTail struct {
//at // = head
δZtail *zodb.ΔTail
......@@ -57,6 +62,8 @@ 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.
//
// XXX text ...
// XXX -> Append? -> Invalidate?
// XXX -> DiffTo ?
......@@ -83,6 +90,12 @@ func (δB *ΔBTail) Update(δZ *zodb.EventCommit) {
diff(B, B')
...
XXX rebuild something?
-> [] of (root, []key)
*/
}
func (δB *ΔBTail) LastRevOf(root Tree, key Key, at zodb.Tid) zodb.Tid {
panic("TODO")
}
......@@ -24,14 +24,14 @@ package δbtree
//go:generate ../../gen-set δbtree Object interface{} zset_object.go
import (
"fmt"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb/btree"
)
type Tree = btree.LOBTree
type Bucket = btree.LOBucket
type Node = btree.LONode
type Key = int64
// PathSet is a collection of BTree paths.
//
......@@ -64,7 +64,7 @@ func NewPathSet() *PathSet {
// A root can be associated with several masters (each provided on different Add call)
//
// XXX catch cycles on add?
func (m *PathSet) Add(master interface{}, path []zodb.IPersistent) {
func (m *PathSet) Add(master interface{}, path []Node) {
//fmt.Printf("\n\nPathSet.Add %v %s\n", master, path)
l := len(path)
......@@ -75,9 +75,6 @@ func (m *PathSet) Add(master interface{}, path []zodb.IPersistent) {
var root *Tree
for i, node := range path {
switch node := node.(type) {
default:
panic(fmt.Sprintf("path elements must be Tree|Bucket, not %T", node))
case *Tree:
if i == 0 {
root = node
......
......@@ -1143,7 +1143,7 @@ func (f *BigFile) readBlk(ctx context.Context, blk int64, dest []byte) (err erro
// XXX do we really need to use/propagate caller contex here? ideally update
// watchers should be synchronous, and in practice we just use 30s timeout.
// Should a READ interrupt cause watch update failure?
func (f *BigFile) updateWatchers(ctx context.Context, blk int64, treepath []zodb.IPersistent, pathRevMax zodb.Tid) {
func (f *BigFile) updateWatchers(ctx context.Context, blk int64, treepath []btree.LONode, pathRevMax zodb.Tid) {
// only head/ is being watched for
if f.head.rev != 0 {
return
......
......@@ -445,7 +445,7 @@ func (bf *zBigFileState) PySetState(pystate interface{}) (err error) {
// - max(_.serial for _ in ZBlk(#blk), all BTree/Bucket that lead to ZBlk)
//
// XXX better load into user-provided buf? mem.Buf?
func (bf *ZBigFile) LoadBlk(ctx context.Context, blk int64) (_ []byte, treePath []zodb.IPersistent, pathRevMax zodb.Tid, err error) {
func (bf *ZBigFile) LoadBlk(ctx context.Context, blk int64) (_ []byte, treePath []btree.LONode, pathRevMax zodb.Tid, err error) {
defer xerr.Contextf(&err, "bigfile %s: loadblk %d", bf.POid(), blk)
err = bf.PActivate(ctx)
......@@ -455,7 +455,7 @@ func (bf *ZBigFile) LoadBlk(ctx context.Context, blk int64) (_ []byte, treePath
defer bf.PDeactivate()
pathRevMax = 0
xzblk, ok, err := bf.blktab.VGet(ctx, blk, func(node zodb.IPersistent) {
xzblk, ok, err := bf.blktab.VGet(ctx, blk, func(node btree.LONode) {
treePath = append(treePath, node)
pathRevMax = tidmax(pathRevMax, node.PSerial())
})
......@@ -498,7 +498,7 @@ func (bf *ZBigFile) LoadBlk(ctx context.Context, blk int64) (_ []byte, treePath
// Size returns whole file size.
//
// it also returns BTree path scaned to obtain size.
func (bf *ZBigFile) Size(ctx context.Context) (_ int64, treePath []zodb.IPersistent, err error) {
func (bf *ZBigFile) Size(ctx context.Context) (_ int64, treePath []btree.LONode, err error) {
defer xerr.Contextf(&err, "bigfile %s: size", bf.POid())
err = bf.PActivate(ctx)
......@@ -508,7 +508,7 @@ func (bf *ZBigFile) Size(ctx context.Context) (_ int64, treePath []zodb.IPersist
defer bf.PDeactivate()
//fmt.Printf("\n\n\nSize ...\n")
tailblk, ok, err := bf.blktab.VMaxKey(ctx, func(node zodb.IPersistent) {
tailblk, ok, err := bf.blktab.VMaxKey(ctx, func(node btree.LONode) {
//fmt.Printf("visit %v\n", node)
treePath = append(treePath, node)
})
......
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