Commit 8cdedf83 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent dddfa56d
// Code generated by gen-set Oid Oid; DO NOT EDIT.
// Copyright (C) 2015-2020 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 main
// SetOid is a set of Oid.
type SetOid map[Oid]struct{}
// Add adds v to the set.
func (s SetOid) Add(v Oid) {
s[v] = struct{}{}
}
// Del removes v from the set.
// it is noop if v was not in the set.
func (s SetOid) Del(v Oid) {
delete(s, v)
}
// Has checks whether the set contains v.
func (s SetOid) Has(v Oid) bool {
_, ok := s[v]
return ok
}
// Update adds t values to s.
func (s SetOid) Update(t SetOid) {
for v := range t {
s.Add(v)
}
}
// Elements returns all elements of set as slice.
func (s SetOid) Elements() []Oid {
ev := make([]Oid, len(s))
i := 0
for e := range s {
ev[i] = e
i++
}
return ev
}
......@@ -23,6 +23,7 @@ package main
//go:generate ./gen-set main Tree *Tree zset_tree.go
////go:generate ./gen-set main Value Value zset_value.go
//go:generate ./gen-set main Oid Oid zset_oid.go
import (
"context"
......@@ -40,6 +41,7 @@ type Node = btree.LONode
type Key = int64
type Value = zodb.Oid // assumes key points to IPersistent
// deletion is represented as InvalidOid
type Oid = zodb.Oid
type SetKey = SetI64
......
......@@ -573,19 +573,22 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
δB := δbtail.Update(δZ)
assert.Equal(δB.Rev, δZ.Tid)
//if len(d12) == 0 && len(initialTrackedKeys) == 0 {
if len(initialTrackedKeys) == 0 {
//if len(inδTOK) == 0 { XXX <- should be correct
assert.Equal(len(δB.ByRoot), 0)
return
}
// δB.ByRoot.keys() == [treeRoot]
roots := []zodb.Oid{}
// assert δB.ByRoot == {treeRoot -> ...} if inδTOK != ø
// == ø if inδTOK == ø
rootsOK := SetOid{}
if len(inδTOK) > 0 {
rootsOK.Add(treeRoot)
}
roots := SetOid{}
for root := range δB.ByRoot {
roots = append(roots, root)
roots.Add(root)
}
assert.Equal(roots, []zodb.Oid{treeRoot})
if !reflect.DeepEqual(roots, rootsOK) {
badf("δB: roots != rootsOK ; inδTOK=%v roots=%v rootsOK=%v", inδTOK, roots, rootsOK)
return
}
δToid := δB.ByRoot[treeRoot] // {} k -> oid
δT = XGetKV(db, at2, δToid) // {} k -> ZBlk(oid).data
......
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