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) { ...@@ -542,7 +542,7 @@ func (rs rangeSplit) Get_(k Key) (rnode *nodeInRange, ok bool) {
// rnode.node must be tree. // rnode.node must be tree.
// rnode.node must be aleady activated. // 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) { func (prs *rangeSplit) Expand(rnode *nodeInRange) (children rangeSplit) {
rs := *prs rs := *prs
i := sort.Search(len(rs), func(i int) bool { i := sort.Search(len(rs), func(i int) bool {
...@@ -577,6 +577,33 @@ func (prs *rangeSplit) Expand(rnode *nodeInRange) (children rangeSplit) { ...@@ -577,6 +577,33 @@ func (prs *rangeSplit) Expand(rnode *nodeInRange) (children rangeSplit) {
return children 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 { func (rs rangeSplit) String() string {
s := "" s := ""
for _, rn := range rs { for _, rn := range rs {
...@@ -749,21 +776,21 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid] ...@@ -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} // [-∞, ∞) btop := &nodeInRange{lo: KeyMin, hi_: KeyMax, node: b} // [-∞, ∞)
bv = rangeSplit{btop} bv = rangeSplit{btop}
} }
bq := []*nodeInRange{...}
for k := range Bkeysq { for k := range Bkeysq {
bnode, ok := bv.Get_(k) bbucket, ok, err := bv.GetToBucket(ctx, k)
if !ok { if !ok {
continue // key not covered continue // key not covered
} }
for { bbucket.node.(*Bucket)
switch bnode.node.(type) { δB, err := diffB(ctx, nil, bbucket.node.(*Bucket))
case *Tree: if err != nil {
err := bnode.node.PActivate(ctx); X(err) return nil, err
defer bnode.node.PDeactivate() }
case *Bucket: // XXX δ <- δB
btree, ok := bnode.node.(*Tree 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