Commit 6df31f29 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 1a4b5673
......@@ -217,10 +217,18 @@ type ΔTree struct {
}
// XXX is a set of PP(leafs) nodes XXX -> PTreeSubSet ? TreePSubSet ? TreePPSet ? PPSubSet ?
// XXX PPNodeSet? TreePPSubSet ?
//
// where PP maps a leaf to {leaf, leaf.parent, leaf.parent.parent, ...} up to
// top root node from where the leaf is reached.
//
// Every node in the set also has .parent pointer.
//
// XXX place
type trackIndex map[zodb.Oid]*nodeTrack
// XXX place
// XXX place XXX PTreeSubSetNode ?
// nodeTrack represents tracking information about a node.
type nodeTrack struct {
parent zodb.Oid // parent node | InvalidOid for root
......@@ -314,20 +322,37 @@ func (tidx trackIndex) verify() {
}
}
// Update tidx with trees subsets from tidx2.
func (tidx trackIndex) Update(tidx2 trackIndex) {
//fmt.Printf("\n\nUpdate:\n")
//fmt.Printf("tidx: %s\n", tidx)
//fmt.Printf("tidx2: %s\n", tidx2)
// DifferenceInplace sets A = PP(A.leafs \ B.leafs)
//
// In other words it removes B nodes from A while still maintaining A as P-connected.
func (A trackIndex) DifferenceInplace(B trackIndex) {
//fmt.Printf("\n\nDifferenceInplace:\n")
//fmt.Printf("A: %s\n", A)
//fmt.Printf("B: %s\n", B)
tidx.verify()
tidx2.verify()
A.verify()
B.verify()
defer A.verify()
panic("TODO")
}
for oid, t2 := range tidx2 {
t, already := tidx[oid]
// UnionInplace sets A = PP(A.leafs | B.leafs)
//
// In other words it adds B nodes to A.
func (A trackIndex) UnionInplace(B trackIndex) {
//fmt.Printf("\n\nUnionInplace:\n")
//fmt.Printf("A: %s\n", A)
//fmt.Printf("B: %s\n", B)
A.verify()
B.verify()
defer A.verify()
for oid, t2 := range B {
t, already := A[oid]
if !already {
t = &nodeTrack{parent: t2.parent, nchild: t2.nchild}
tidx[oid] = t
A[oid] = t
} else {
if t2.parent != t.parent {
// XXX or verify this at Track time and require
......@@ -343,12 +368,10 @@ func (tidx trackIndex) Update(tidx2 trackIndex) {
if t.parent != zodb.InvalidOid {
// this node is already present in both trees
// compensate for that in its parent (which must be present)
tidx[t.parent].nchild--
A[t.parent].nchild--
}
}
}
tidx.verify()
}
// ApplyΔ applies δ to trackIdx. XXX
......@@ -743,7 +766,7 @@ func (δBtail *ΔBtail) rebuild() (err error) {
//
// XXX -> teach diffT to return not only δtrack, but also δtrack*
// (conjugate) that would describe how track index changes if going A<-B ?
δBtail.trackIdx.Update(trackNew)
δBtail.trackIdx.UnionInplace(trackNew)
return nil
}
......
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