Commit 7b46e68b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 7bd1ae31
......@@ -87,18 +87,21 @@ type Key = int64
//
// It semantically consists of
//
// [](rev↑, [](tree, []key)) ; rev ∈ (tail, head]
// [](rev↑, [](root, []key)) ; rev ∈ (tail, head]
//
// and covers changes to tracked subsets of BTrees. A tree subset becomes
// tracked via Track(path) request.
//
// 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.
//
// 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 concurrency safety
//
// XXX see also zodb.ΔTail .
//
// ΔTail is not safe for concurrent access.
type ΔTail struct {
δBtail []ΔRevEntry // BTree changes; Covers keys ∈ tracket subset
δZtail *zodb.ΔTail // raw ZODB changes; Kept to rebuild δBtail after new Track
......@@ -129,7 +132,7 @@ type ΔTree struct {
Keyv []Key
}
// NewΔTail creats new ΔTail object.
// NewΔTail creats new empty ΔTail object.
//
// Initial tracked set is empty.
// Initial coverage is (at₀, at₀].
......
// Code generated by gen-set Object interface{}; DO NOT EDIT.
// Copyright (C) 2015-2019 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
package δbtree
// SetObject is a set of interface{}.
type SetObject map[interface{}]struct{}
// Add adds v to the set.
func (s SetObject) Add(v interface{}) {
s[v] = struct{}{}
}
// XXX + Del(v) ?
// Has checks whether the set contains v.
func (s SetObject) Has(v interface{}) bool {
_, ok := s[v]
return ok
}
// Update adds t values to s.
func (s SetObject) Update(t SetObject) {
for v := range t {
s.Add(v)
}
}
// Elements returns all elements of set as slice.
func (s SetObject) Elements() []interface{} {
ev := make([]interface{}, len(s))
i := 0
for e := range s {
ev[i] = e
i++
}
return ev
}
// Code generated by gen-set Tree *Tree; DO NOT EDIT.
// Copyright (C) 2015-2019 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
package δbtree
// SetTree is a set of *Tree.
type SetTree map[*Tree]struct{}
// Add adds v to the set.
func (s SetTree) Add(v *Tree) {
s[v] = struct{}{}
}
// XXX + Del(v) ?
// Has checks whether the set contains v.
func (s SetTree) Has(v *Tree) bool {
_, ok := s[v]
return ok
}
// Update adds t values to s.
func (s SetTree) Update(t SetTree) {
for v := range t {
s.Add(v)
}
}
// Elements returns all elements of set as slice.
func (s SetTree) Elements() []*Tree {
ev := make([]*Tree, len(s))
i := 0
for e := range s {
ev[i] = e
i++
}
return ev
}
// Copyright (C) 2019 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// Package δbtree provides BTree diffing.
package δbtree
//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"
)
type Tree = btree.LOBTree
type Bucket = btree.LOBucket
type Node = btree.LONode
type Key = int64
// PathSet is a collection of BTree paths.
//
// For example it can be a set of visited BTree paths.
// There is no requirement that paths belong to only one single BTree.
//
// PathSet is not safe for concurrent access.
type PathSet struct {
// residency index: BTree|Bucket -> top tree element.
// XXX -> rootIdx ?
residencyIdx map[zodb.Oid]SetTree // oid -> {} roots
// master index: tree root -> {} masters
// XXX master -> user?
masterIdx map[*Tree]SetObject
}
/*
// NewPathSet creates new empty PathSet.
func NewPathSet() *PathSet {
return &PathSet{
residencyIdx: make(map[zodb.Oid]SetTree),
masterIdx: make(map[*Tree]SetObject),
}
}
*/
/*
// Add adds path to collection and associates path root with master.
//
// path[0] signifies a root.
// All path elemens must be Tree except last one which must be Bucket.
// 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 []Node) {
//fmt.Printf("\n\nPathSet.Add %v %s\n", master, path)
l := len(path)
if l == 0 {
panic("empty path")
}
var root *Tree
for i, node := range path {
switch node := node.(type) {
case *Tree:
if i == 0 {
root = node
}
// XXX check only not last
case *Bucket:
// XXX check only last
}
}
for _, node := range path {
nodeRoots, ok := m.residencyIdx[node.POid()]
if !ok {
nodeRoots = make(SetTree)
m.residencyIdx[node.POid()] = nodeRoots
}
nodeRoots.Add(root)
}
masterSet, ok := m.masterIdx[root]
if !ok {
masterSet = SetObject{}
m.masterIdx[root] = masterSet
}
masterSet.Add(master)
}
*/
// Invalidates returns which masters are invalidated by changed objects.
//
// returned are: roots of changed trees.
//
// XXX stub.
//
// TODO toposort changev wrt nodes ordering (defined by traversed paths) and do δbtree top-down.
func (m *PathSet) Invalidates(changev []zodb.Oid) (masters SetObject) {
masters = SetObject{}
for _, oid := range changev {
roots, ok := m.residencyIdx[oid]
if !ok {
continue // we don't know this oid
}
for root := range roots {
masters.Update(m.masterIdx[root])
}
}
return masters
}
......@@ -693,6 +693,9 @@ func NewΔFTail(at0 zodb.Tid) *ΔFTail {
}
}
// Track adds tree path to tracked set and associates path root with file.
//
// A root can be associated with several files (each provided on different Track call).
func (δf *ΔFTail) Track(file *BigFile, path []btree.LONode) {
δf.ΔTail.Track(path)
root := path[0].(*btree.LOBTree)
......
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