Commit 00b1a6ab authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 35245f42
......@@ -19,7 +19,7 @@
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
package xbtree
package main
// SetObject is a set of interface{}.
type SetObject map[interface{}]struct{}
......
......@@ -19,7 +19,7 @@
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
package xbtree
package main
// SetTree is a set of *Tree.
type SetTree map[*Tree]struct{}
......
// Code generated by gen-δtail I64 int64; DO NOT EDIT.
// (from lab.nexedi.com/kirr/neo/go/zodb @ v1.9-2242-g1b838adf)
// (from lab.nexedi.com/kirr/neo/go/zodb @ v1.9-2243-g8708ccde)
// Copyright (C) 2018-2019 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
......
......@@ -17,14 +17,12 @@
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// Package xbtree complements package lab.nexedi.com/kirr/neo/go/zodb/btree.
//
package main
// XXX -> Package xbtree complements package lab.nexedi.com/kirr/neo/go/zodb/btree.
// TODO move -> btree when ΔTail matures.
package xbtree
//go:generate ../../gen-set xbtree Tree *Tree zset_tree.go
// //go:generate ../../gen-set xbtree Oid zodb.Oid zset_oid.go
//go:generate ../../gen-set xbtree Object interface{} zset_object.go
//go:generate ./gen-set main Tree *Tree zset_tree.go
//go:generate ./gen-set main Object interface{} zset_object.go
import (
"context"
......@@ -42,7 +40,7 @@ type Key = int64
type Value = zodb.Oid // XXX assumes key points to IPersistent
// XXX how to represent deletion? InvalidOid?
// ΔTail represents tail of revisional changes to BTrees.
// ΔBTail represents tail of revisional changes to BTrees.
//
// It semantically consists of
//
......@@ -64,7 +62,7 @@ type Value = zodb.Oid // XXX assumes key points to IPersistent
// In particular a key that was not explicitly requested to be tracked, even if
// it was changes in δZ, is not guaranted to be present in δB.
//
// ΔTail provides the following operations:
// ΔBTail provides the following operations:
//
// .Track(path) - start tracking tree nodes and keys; root=path[0], keys=path[-1].keys
//
......@@ -81,11 +79,10 @@ type Value = zodb.Oid // XXX assumes key points to IPersistent
// XXX incremental; not full coverage
// XXX see also zodb.ΔTail .
//
// ΔTail is not safe for concurrent access.
// ΔBTail is not safe for concurrent access.
// XXX -> multiple readers / single writer?
type ΔTail struct {
// XXX -> δZtail
ΔZtail *zodb.ΔTail // raw ZODB changes; Kept to rebuild δBtail/byRoot after new Track
type ΔBtail struct {
δZtail *zodb.ΔTail // raw ZODB changes; Kept to rebuild δBtail/byRoot after new Track
δRtail []ΔRoots // which BTree were changed; Noted only by keys ∈ tracket subset
byRoot map[*Tree]*ΔTreeTail // root -> k/v change history; only for keys ∈ tracket subset
......@@ -114,7 +111,9 @@ type ΔRoots struct {
// ΔTreeTail represent tail of revisional changes to one BTree.
//
// See ΔTail documentation for details.
// See ΔBTail documentation for details.
//
// XXX -> ΔTtail
type ΔTreeTail struct {
vδT []ΔTree // changes to tree keys; rev↑. covers keys ∈ tracket subset
......@@ -132,27 +131,27 @@ type ΔTree struct {
KV map[Key]Value
}
// NewΔTail creats new empty ΔTail object.
// NewΔBtail creats new empty ΔBTail object.
//
// Initial tracked set is empty.
// Initial coverage is (at₀, at₀].
func NewΔTail(at0 zodb.Tid) *ΔTail {
return &ΔTail{
ΔZtail: zodb.NewΔTail(at0),
func NewΔBtail(at0 zodb.Tid) *ΔBtail {
return &ΔBtail{
δZtail: zodb.NewΔTail(at0),
byRoot: make(map[*Tree]*ΔTreeTail),
trackIdx: make(map[zodb.Oid]SetTree),
}
}
// Head is similar to zodb.ΔTail.Head . XXX ok?
func (δb *ΔTail) Head() zodb.Tid {
func (δBtail *ΔBtail) Head() zodb.Tid {
//return δb.head
return δb.ΔZtail.Head()
return δBtail.δZtail.Head()
}
// Tail is similar to zodb.ΔTail.Tail . XXX ok?
func (δb *ΔTail) Tail() zodb.Tid {
return δb.ΔZtail.Tail()
func (δBtail *ΔBtail) Tail() zodb.Tid {
return δBtail.δZtail.Tail()
}
// XXX SliceByRev?
......@@ -169,7 +168,7 @@ func (δb *ΔTail) Tail() zodb.Tid {
// XXX path -> []oid ?
//
// XXX catch cycles on add?
func (δb *ΔTail) Track(path []Node) { // XXX Tree|Bucket; path[0] = root
func (δBtail *ΔBtail) Track(path []Node) { // XXX Tree|Bucket; path[0] = root
l := len(path)
if l == 0 {
panic("empty path")
......@@ -179,10 +178,10 @@ func (δb *ΔTail) Track(path []Node) { // XXX Tree|Bucket; path[0] = root
for _, node := range path {
oid := node.POid()
nodeRoots, ok := δb.trackIdx[oid]
nodeRoots, ok := δBtail.trackIdx[oid]
if !ok {
nodeRoots = make(SetTree)
δb.trackIdx[oid] = nodeRoots
δBtail.trackIdx[oid] = nodeRoots
// XXX .trackNew += oid
}
nodeRoots.Add(root)
......@@ -197,13 +196,13 @@ 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.
func (btail *ΔTail) Update(δZ *zodb.EventCommit) Δ {
btail.ΔZtail.Append(δZ.Tid, δZ.Changev)
func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) Δ {
δBtail.δZtail.Append(δZ.Tid, δZ.Changev)
// {} root -> []oid changed under that root
δZByRoot := map[*Tree][]zodb.Oid{} // XXX -> map[*Tree]SetOid ?
for _, δ := range δZ.Changev {
roots, ok := btail.trackIdx[δ]
roots, ok := δBtail.trackIdx[δ]
if !ok {
continue
}
......@@ -249,14 +248,14 @@ func (btail *ΔTail) Update(δZ *zodb.EventCommit) Δ {
*/
}
func (btail *ΔTail) ForgetPast(revCut zodb.Tid) {
btail.ΔZtail.ForgetPast(revCut) // XXX stub
func (δBtail *ΔBtail) ForgetPast(revCut zodb.Tid) {
δBtail.δZtail.ForgetPast(revCut) // XXX stub
}
// update brings .δBtail up to date by recomputing diff XXX and taking new
// entries in .δZtail into account.
// func (btail *ΔTail) update()
// func (δBtail *ΔBtail) update()
// Get returns root[key] as of @at database state plus revision that changed it.
//
......@@ -264,8 +263,8 @@ func (btail *ΔTail) ForgetPast(revCut zodb.Tid) {
//
// XXX at must ∈ (tail, head] XXX [tail ?
// XXX key must be tracked
func (δΒtail *ΔTail) Get(ctx context.Context, root *Tree, key Key, at zodb.Tid) (value Value, ok bool, rev zodb.Tid, revExact bool, err error) {
defer xerr.Contextf(&err, "δBtail: root<%s>: get %s @%s", root.POid(), key, at)
func (δΒtail *ΔBtail) Get(ctx context.Context, root *Tree, key Key, at zodb.Tid) (value Value, ok bool, rev zodb.Tid, revExact bool, err error) {
defer xerr.Contextf(&err, "δBtail: root<%s>: get %d @%s", root.POid(), key, at)
// XXX key not tracked -> panic
// XXX at not ∈ (tail, head] -> panic
......
......@@ -24,8 +24,6 @@ import (
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb/btree"
"./internal/xbtree"
)
// ΔFtail represents tail of revisional changes to files.
......@@ -64,7 +62,7 @@ import (
// XXX see also zodb.ΔTail
type ΔFtail struct {
// ΔFtail merge btree.ΔTail with history of ZBlk
δBtail *xbtree.ΔTail
δBtail *ΔBtail
fileIdx map[*btree.LOBTree]SetBigFile // root -> {} BigFile XXX root -> oid?
}
......@@ -80,7 +78,7 @@ type ΔF struct {
// Initial coverage of created ΔFtail is (at₀, at₀].
func NewΔFtail(at0 zodb.Tid) *ΔFtail {
return &ΔFtail{
δBtail: xbtree.NewΔTail(at0),
δBtail: NewΔBtail(at0),
fileIdx: make(map[*btree.LOBTree]SetBigFile),
}
}
......@@ -179,7 +177,7 @@ func (f *BigFile) LastBlkRev(ctx context.Context, blk int64, at zodb.Tid) (_ zod
// blk revision is max rev and when zblk changed last in (rev, at] range.
//
// XXX need to use full δZ, not only connected to tracked subset?
zblkRev, zblkRevExact := δFtail.δBtail.ΔZtail.LastRevOf(zblkOid, at)
zblkRev, zblkRevExact := δFtail.δBtail.δZtail.LastRevOf(zblkOid, at)
if zblkRev > tabRev {
return zblkRev, zblkRevExact
} else {
......
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