Commit 82fd3e37 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 115a4866
......@@ -542,7 +542,7 @@ func (rs rangeSplit) Get_(k Key) (rnode *nodeInRange, ok bool) {
// rnode.node must be tree.
// rnode.node must be aleady activated.
//
// inserted children is also return for convenience.
// inserted children is also returned for convenience.
func (prs *rangeSplit) Expand(rnode *nodeInRange) (children rangeSplit) {
rs := *prs
i := sort.Search(len(rs), func(i int) bool {
......@@ -577,6 +577,33 @@ func (prs *rangeSplit) Expand(rnode *nodeInRange) (children rangeSplit) {
return children
}
// GetToBucket returns bucket corresponding to key k.
// While reaching to that bucket, it expands step-by-step trees that are leading to that bucket.
// XXX also return path?
func (prs *rangeSplit) GetToBucket(ctx, k) (rbucket *nodeInRange, bool ok, err error) {
rnode, ok := prs.Get_(k)
if !ok {
return nil, false, nil // key not covered
}
for {
switch rnode.node.(type) {
case *Bucket:
return rnode, true, nil
}
// it's tree
err = rnode.node.PActivate(ctx)
if err != nil {
return nil, false, err
}
defer rnode.node.PDeactivate()
children := prs.Expand(rnode)
rnode = children.Get(k) // k must be there
}
}
func (rs rangeSplit) String() string {
s := ""
for _, rn := range rs {
......@@ -749,21 +776,21 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
btop := &nodeInRange{lo: KeyMin, hi_: KeyMax, node: b} // [-∞, ∞)
bv = rangeSplit{btop}
}
bq := []*nodeInRange{...}
for k := range Bkeysq {
bnode, ok := bv.Get_(k)
bbucket, ok, err := bv.GetToBucket(ctx, k)
if !ok {
continue // key not covered
}
for {
switch bnode.node.(type) {
case *Tree:
err := bnode.node.PActivate(ctx); X(err)
defer bnode.node.PDeactivate()
bbucket.node.(*Bucket)
δB, err := diffB(ctx, nil, bbucket.node.(*Bucket))
if err != nil {
return nil, err
}
case *Bucket:
btree, ok := bnode.node.(*Tree
// XXX δ <- δB
for k, δv := range δ {
//
}
}
......
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