Commit fecf1327 authored by Kirill Smelkov's avatar Kirill Smelkov

X Unexport SetXXX from packages API

parent bf9a7405
......@@ -21,10 +21,9 @@
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
PACKAGE=$1
KIND=$2
VALUE=$3
out=$4
KIND=$1
VALUE=$2
out=$3
input=$(dirname $0)/set.go.in
......@@ -32,7 +31,6 @@ echo "// Code generated by gen-set $KIND $VALUE; DO NOT EDIT." >$out
echo >>$out
sed \
-e "s/PACKAGE/$PACKAGE/g" \
-e "s/VALUE/$VALUE/g" \
-e "s/Set/Set${KIND}/g" \
-e "s/Set/${KIND}/g" \
$input >>$out
......@@ -19,10 +19,10 @@
package set
//go:generate ./gen-set set I64 int64 zset_i64.go
//go:generate ./gen-set set Str string zset_str.go
//go:generate ./gen-set set Oid _Oid zset_oid.go
//go:generate ./gen-set set Tid _Tid zset_tid.go
//go:generate ./gen-set I64 int64 zset_i64.go
//go:generate ./gen-set Str string zset_str.go
//go:generate ./gen-set Oid _Oid zset_oid.go
//go:generate ./gen-set Tid _Tid zset_tid.go
import (
"lab.nexedi.com/kirr/neo/go/zodb"
......
......@@ -17,7 +17,7 @@
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
package PACKAGE
package set
import (
"fmt"
......
......@@ -27,35 +27,35 @@ import (
"strings"
)
// SetI64 is a set of int64.
type SetI64 map[int64]struct{}
// I64 is a set of int64.
type I64 map[int64]struct{}
// Add adds v to the set.
func (s SetI64) Add(v int64) {
func (s I64) Add(v int64) {
s[v] = struct{}{}
}
// Del removes v from the set.
// it is noop if v was not in the set.
func (s SetI64) Del(v int64) {
func (s I64) Del(v int64) {
delete(s, v)
}
// Has checks whether the set contains v.
func (s SetI64) Has(v int64) bool {
func (s I64) Has(v int64) bool {
_, ok := s[v]
return ok
}
// Update adds t values to s.
func (s SetI64) Update(t SetI64) {
func (s I64) Update(t I64) {
for v := range t {
s.Add(v)
}
}
// Elements returns all elements of set as slice.
func (s SetI64) Elements() []int64 {
func (s I64) Elements() []int64 {
ev := make([]int64, len(s))
i := 0
for e := range s {
......@@ -66,14 +66,14 @@ func (s SetI64) Elements() []int64 {
}
// Union returns s ∪ t
func (s SetI64) Union(t SetI64) SetI64 {
func (s I64) Union(t I64) I64 {
// l = max(len(s), len(t))
l := len(s)
if lt := len(t); lt > l {
l = lt
}
u := make(SetI64, l)
u := make(I64, l)
for v := range s {
u.Add(v)
......@@ -85,8 +85,8 @@ func (s SetI64) Union(t SetI64) SetI64 {
}
// Intersection returns s ∩ t
func (s SetI64) Intersection(t SetI64) SetI64 {
i := SetI64{}
func (s I64) Intersection(t I64) I64 {
i := I64{}
for v := range s {
if t.Has(v) {
i.Add(v)
......@@ -96,8 +96,8 @@ func (s SetI64) Intersection(t SetI64) SetI64 {
}
// Difference returns s\t.
func (s SetI64) Difference(t SetI64) SetI64 {
d := SetI64{}
func (s I64) Difference(t I64) I64 {
d := I64{}
for v := range s {
if !t.Has(v) {
d.Add(v)
......@@ -107,8 +107,8 @@ func (s SetI64) Difference(t SetI64) SetI64 {
}
// SymmetricDifference returns s Δ t.
func (s SetI64) SymmetricDifference(t SetI64) SetI64 {
d := SetI64{}
func (s I64) SymmetricDifference(t I64) I64 {
d := I64{}
for v := range s {
if !t.Has(v) {
d.Add(v)
......@@ -123,7 +123,7 @@ func (s SetI64) SymmetricDifference(t SetI64) SetI64 {
}
// Equal returns whether a == b.
func (a SetI64) Equal(b SetI64) bool {
func (a I64) Equal(b I64) bool {
if len(a) != len(b) {
return false
}
......@@ -139,8 +139,8 @@ func (a SetI64) Equal(b SetI64) bool {
}
// Clone returns copy of the set.
func (orig SetI64) Clone() SetI64 {
klon := make(SetI64, len(orig))
func (orig I64) Clone() I64 {
klon := make(I64, len(orig))
for v := range orig {
klon.Add(v)
}
......@@ -149,7 +149,7 @@ func (orig SetI64) Clone() SetI64 {
// --------
func (s SetI64) SortedElements() []int64 {
func (s I64) SortedElements() []int64 {
ev := s.Elements()
sort.Slice(ev, func(i, j int) bool {
return ev[i] < ev[j]
......@@ -157,7 +157,7 @@ func (s SetI64) SortedElements() []int64 {
return ev
}
func (s SetI64) String() string {
func (s I64) String() string {
ev := s.SortedElements()
strv := make([]string, len(ev))
for i, v := range ev {
......
......@@ -27,35 +27,35 @@ import (
"strings"
)
// SetOid is a set of _Oid.
type SetOid map[_Oid]struct{}
// Oid is a set of _Oid.
type Oid map[_Oid]struct{}
// Add adds v to the set.
func (s SetOid) Add(v _Oid) {
func (s Oid) 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) {
func (s Oid) Del(v _Oid) {
delete(s, v)
}
// Has checks whether the set contains v.
func (s SetOid) Has(v _Oid) bool {
func (s Oid) Has(v _Oid) bool {
_, ok := s[v]
return ok
}
// Update adds t values to s.
func (s SetOid) Update(t SetOid) {
func (s Oid) Update(t Oid) {
for v := range t {
s.Add(v)
}
}
// Elements returns all elements of set as slice.
func (s SetOid) Elements() []_Oid {
func (s Oid) Elements() []_Oid {
ev := make([]_Oid, len(s))
i := 0
for e := range s {
......@@ -66,14 +66,14 @@ func (s SetOid) Elements() []_Oid {
}
// Union returns s ∪ t
func (s SetOid) Union(t SetOid) SetOid {
func (s Oid) Union(t Oid) Oid {
// l = max(len(s), len(t))
l := len(s)
if lt := len(t); lt > l {
l = lt
}
u := make(SetOid, l)
u := make(Oid, l)
for v := range s {
u.Add(v)
......@@ -85,8 +85,8 @@ func (s SetOid) Union(t SetOid) SetOid {
}
// Intersection returns s ∩ t
func (s SetOid) Intersection(t SetOid) SetOid {
i := SetOid{}
func (s Oid) Intersection(t Oid) Oid {
i := Oid{}
for v := range s {
if t.Has(v) {
i.Add(v)
......@@ -96,8 +96,8 @@ func (s SetOid) Intersection(t SetOid) SetOid {
}
// Difference returns s\t.
func (s SetOid) Difference(t SetOid) SetOid {
d := SetOid{}
func (s Oid) Difference(t Oid) Oid {
d := Oid{}
for v := range s {
if !t.Has(v) {
d.Add(v)
......@@ -107,8 +107,8 @@ func (s SetOid) Difference(t SetOid) SetOid {
}
// SymmetricDifference returns s Δ t.
func (s SetOid) SymmetricDifference(t SetOid) SetOid {
d := SetOid{}
func (s Oid) SymmetricDifference(t Oid) Oid {
d := Oid{}
for v := range s {
if !t.Has(v) {
d.Add(v)
......@@ -123,7 +123,7 @@ func (s SetOid) SymmetricDifference(t SetOid) SetOid {
}
// Equal returns whether a == b.
func (a SetOid) Equal(b SetOid) bool {
func (a Oid) Equal(b Oid) bool {
if len(a) != len(b) {
return false
}
......@@ -139,8 +139,8 @@ func (a SetOid) Equal(b SetOid) bool {
}
// Clone returns copy of the set.
func (orig SetOid) Clone() SetOid {
klon := make(SetOid, len(orig))
func (orig Oid) Clone() Oid {
klon := make(Oid, len(orig))
for v := range orig {
klon.Add(v)
}
......@@ -149,7 +149,7 @@ func (orig SetOid) Clone() SetOid {
// --------
func (s SetOid) SortedElements() []_Oid {
func (s Oid) SortedElements() []_Oid {
ev := s.Elements()
sort.Slice(ev, func(i, j int) bool {
return ev[i] < ev[j]
......@@ -157,7 +157,7 @@ func (s SetOid) SortedElements() []_Oid {
return ev
}
func (s SetOid) String() string {
func (s Oid) String() string {
ev := s.SortedElements()
strv := make([]string, len(ev))
for i, v := range ev {
......
......@@ -27,35 +27,35 @@ import (
"strings"
)
// SetStr is a set of string.
type SetStr map[string]struct{}
// Str is a set of string.
type Str map[string]struct{}
// Add adds v to the set.
func (s SetStr) Add(v string) {
func (s Str) Add(v string) {
s[v] = struct{}{}
}
// Del removes v from the set.
// it is noop if v was not in the set.
func (s SetStr) Del(v string) {
func (s Str) Del(v string) {
delete(s, v)
}
// Has checks whether the set contains v.
func (s SetStr) Has(v string) bool {
func (s Str) Has(v string) bool {
_, ok := s[v]
return ok
}
// Update adds t values to s.
func (s SetStr) Update(t SetStr) {
func (s Str) Update(t Str) {
for v := range t {
s.Add(v)
}
}
// Elements returns all elements of set as slice.
func (s SetStr) Elements() []string {
func (s Str) Elements() []string {
ev := make([]string, len(s))
i := 0
for e := range s {
......@@ -66,14 +66,14 @@ func (s SetStr) Elements() []string {
}
// Union returns s ∪ t
func (s SetStr) Union(t SetStr) SetStr {
func (s Str) Union(t Str) Str {
// l = max(len(s), len(t))
l := len(s)
if lt := len(t); lt > l {
l = lt
}
u := make(SetStr, l)
u := make(Str, l)
for v := range s {
u.Add(v)
......@@ -85,8 +85,8 @@ func (s SetStr) Union(t SetStr) SetStr {
}
// Intersection returns s ∩ t
func (s SetStr) Intersection(t SetStr) SetStr {
i := SetStr{}
func (s Str) Intersection(t Str) Str {
i := Str{}
for v := range s {
if t.Has(v) {
i.Add(v)
......@@ -96,8 +96,8 @@ func (s SetStr) Intersection(t SetStr) SetStr {
}
// Difference returns s\t.
func (s SetStr) Difference(t SetStr) SetStr {
d := SetStr{}
func (s Str) Difference(t Str) Str {
d := Str{}
for v := range s {
if !t.Has(v) {
d.Add(v)
......@@ -107,8 +107,8 @@ func (s SetStr) Difference(t SetStr) SetStr {
}
// SymmetricDifference returns s Δ t.
func (s SetStr) SymmetricDifference(t SetStr) SetStr {
d := SetStr{}
func (s Str) SymmetricDifference(t Str) Str {
d := Str{}
for v := range s {
if !t.Has(v) {
d.Add(v)
......@@ -123,7 +123,7 @@ func (s SetStr) SymmetricDifference(t SetStr) SetStr {
}
// Equal returns whether a == b.
func (a SetStr) Equal(b SetStr) bool {
func (a Str) Equal(b Str) bool {
if len(a) != len(b) {
return false
}
......@@ -139,8 +139,8 @@ func (a SetStr) Equal(b SetStr) bool {
}
// Clone returns copy of the set.
func (orig SetStr) Clone() SetStr {
klon := make(SetStr, len(orig))
func (orig Str) Clone() Str {
klon := make(Str, len(orig))
for v := range orig {
klon.Add(v)
}
......@@ -149,7 +149,7 @@ func (orig SetStr) Clone() SetStr {
// --------
func (s SetStr) SortedElements() []string {
func (s Str) SortedElements() []string {
ev := s.Elements()
sort.Slice(ev, func(i, j int) bool {
return ev[i] < ev[j]
......@@ -157,7 +157,7 @@ func (s SetStr) SortedElements() []string {
return ev
}
func (s SetStr) String() string {
func (s Str) String() string {
ev := s.SortedElements()
strv := make([]string, len(ev))
for i, v := range ev {
......
......@@ -27,35 +27,35 @@ import (
"strings"
)
// SetTid is a set of _Tid.
type SetTid map[_Tid]struct{}
// Tid is a set of _Tid.
type Tid map[_Tid]struct{}
// Add adds v to the set.
func (s SetTid) Add(v _Tid) {
func (s Tid) Add(v _Tid) {
s[v] = struct{}{}
}
// Del removes v from the set.
// it is noop if v was not in the set.
func (s SetTid) Del(v _Tid) {
func (s Tid) Del(v _Tid) {
delete(s, v)
}
// Has checks whether the set contains v.
func (s SetTid) Has(v _Tid) bool {
func (s Tid) Has(v _Tid) bool {
_, ok := s[v]
return ok
}
// Update adds t values to s.
func (s SetTid) Update(t SetTid) {
func (s Tid) Update(t Tid) {
for v := range t {
s.Add(v)
}
}
// Elements returns all elements of set as slice.
func (s SetTid) Elements() []_Tid {
func (s Tid) Elements() []_Tid {
ev := make([]_Tid, len(s))
i := 0
for e := range s {
......@@ -66,14 +66,14 @@ func (s SetTid) Elements() []_Tid {
}
// Union returns s ∪ t
func (s SetTid) Union(t SetTid) SetTid {
func (s Tid) Union(t Tid) Tid {
// l = max(len(s), len(t))
l := len(s)
if lt := len(t); lt > l {
l = lt
}
u := make(SetTid, l)
u := make(Tid, l)
for v := range s {
u.Add(v)
......@@ -85,8 +85,8 @@ func (s SetTid) Union(t SetTid) SetTid {
}
// Intersection returns s ∩ t
func (s SetTid) Intersection(t SetTid) SetTid {
i := SetTid{}
func (s Tid) Intersection(t Tid) Tid {
i := Tid{}
for v := range s {
if t.Has(v) {
i.Add(v)
......@@ -96,8 +96,8 @@ func (s SetTid) Intersection(t SetTid) SetTid {
}
// Difference returns s\t.
func (s SetTid) Difference(t SetTid) SetTid {
d := SetTid{}
func (s Tid) Difference(t Tid) Tid {
d := Tid{}
for v := range s {
if !t.Has(v) {
d.Add(v)
......@@ -107,8 +107,8 @@ func (s SetTid) Difference(t SetTid) SetTid {
}
// SymmetricDifference returns s Δ t.
func (s SetTid) SymmetricDifference(t SetTid) SetTid {
d := SetTid{}
func (s Tid) SymmetricDifference(t Tid) Tid {
d := Tid{}
for v := range s {
if !t.Has(v) {
d.Add(v)
......@@ -123,7 +123,7 @@ func (s SetTid) SymmetricDifference(t SetTid) SetTid {
}
// Equal returns whether a == b.
func (a SetTid) Equal(b SetTid) bool {
func (a Tid) Equal(b Tid) bool {
if len(a) != len(b) {
return false
}
......@@ -139,8 +139,8 @@ func (a SetTid) Equal(b SetTid) bool {
}
// Clone returns copy of the set.
func (orig SetTid) Clone() SetTid {
klon := make(SetTid, len(orig))
func (orig Tid) Clone() Tid {
klon := make(Tid, len(orig))
for v := range orig {
klon.Add(v)
}
......@@ -149,7 +149,7 @@ func (orig SetTid) Clone() SetTid {
// --------
func (s SetTid) SortedElements() []_Tid {
func (s Tid) SortedElements() []_Tid {
ev := s.Elements()
sort.Slice(ev, func(i, j int) bool {
return ev[i] < ev[j]
......@@ -157,7 +157,7 @@ func (s SetTid) SortedElements() []_Tid {
return ev
}
func (s SetTid) String() string {
func (s Tid) String() string {
ev := s.SortedElements()
strv := make([]string, len(ev))
for i, v := range ev {
......
......@@ -363,12 +363,12 @@ func (S PPTreeSubSet) verify() {
}()
// recompute {} oid -> children and verify .nchild against it
children := make(map[zodb.Oid]SetOid, len(S))
children := make(map[zodb.Oid]setOid, len(S))
for oid, t := range S {
if t.parent != zodb.InvalidOid {
cc, ok := children[t.parent]
if !ok {
cc = make(SetOid, 1)
cc = make(setOid, 1)
children[t.parent] = cc
}
cc.Add(oid)
......
......@@ -113,10 +113,10 @@ func (δv ΔValue) String() string {
// for example for e.g. t₀->t₁->b₂ if δZ/T={t₀ b₂} -> δZ/TC=δZ/T+{t₁}
//
// δtopsByRoot = {} root -> {top changed nodes in that tree}
func δZConnectTracked(δZv []zodb.Oid, T PPTreeSubSet) (δZTC SetOid, δtopsByRoot map[zodb.Oid]SetOid) {
δZ := SetOid{}; for _, δ := range δZv { δZ.Add(δ) }
δZTC = SetOid{}
δtopsByRoot = map[zodb.Oid]SetOid{}
func δZConnectTracked(δZv []zodb.Oid, T PPTreeSubSet) (δZTC setOid, δtopsByRoot map[zodb.Oid]setOid) {
δZ := setOid{}; for _, δ := range δZv { δZ.Add(δ) }
δZTC = setOid{}
δtopsByRoot = map[zodb.Oid]setOid{}
for δ := range δZ {
track, ok := T[δ]
......@@ -138,7 +138,7 @@ func δZConnectTracked(δZv []zodb.Oid, T PPTreeSubSet) (δZTC SetOid, δtopsByR
root := node
δtops, ok := δtopsByRoot[root]
if !ok {
δtops = SetOid{}
δtops = setOid{}
δtopsByRoot[root] = δtops
}
δtops.Add(δ)
......@@ -338,7 +338,7 @@ func (rs rangeSplit) String() string {
// δtops is set of top nodes for changed subtrees.
// δZTC is connected(δZ/T) - connected closure for subset of δZ(old..new) that
// touches tracked nodes of T.
func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, trackSet PPTreeSubSet, zconnOld, zconnNew *zodb.Connection) (δT map[Key]ΔValue, δtrack *ΔPPTreeSubSet, δtkeycov *RangedKeySet, err error) {
func treediff(ctx context.Context, root zodb.Oid, δtops setOid, δZTC setOid, trackSet PPTreeSubSet, zconnOld, zconnNew *zodb.Connection) (δT map[Key]ΔValue, δtrack *ΔPPTreeSubSet, δtkeycov *RangedKeySet, err error) {
defer xerr.Contextf(&err, "treediff %s..%s %s", zconnOld.At(), zconnNew.At(), root)
δT = map[Key]ΔValue{}
......@@ -401,7 +401,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
// consistent with b (= a + δ).
//
// δtkeycov represents how δtrack grows (always grows) tracking set key coverage.
func diffX(ctx context.Context, a, b Node, δZTC SetOid, trackSet PPTreeSubSet) (δ map[Key]ΔValue, δtrack *ΔPPTreeSubSet, δtkeycov *RangedKeySet, err error) {
func diffX(ctx context.Context, a, b Node, δZTC setOid, trackSet PPTreeSubSet) (δ map[Key]ΔValue, δtrack *ΔPPTreeSubSet, δtkeycov *RangedKeySet, err error) {
if a==nil && b==nil {
panic("BUG: both a & b == nil") // XXX -> not a bug e.g. for `ø ø T` sequence?
}
......@@ -452,7 +452,7 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid, trackSet PPTreeSubSet)
//
// a, b point to top of subtrees @old and @new revisions.
// δZTC is connected set of objects covering δZT (objects changed in this tree in old..new).
func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackSet PPTreeSubSet) (δ map[Key]ΔValue, δtrack *ΔPPTreeSubSet, δtkeycov *RangedKeySet, err error) {
func diffT(ctx context.Context, A, B *Tree, δZTC setOid, trackSet PPTreeSubSet) (δ map[Key]ΔValue, δtrack *ΔPPTreeSubSet, δtkeycov *RangedKeySet, err error) {
tracefDiff(" diffT %s %s\n", xidOf(A), xidOf(B))
defer xerr.Contextf(&err, "diffT %s %s", xidOf(A), xidOf(B))
......
......@@ -30,9 +30,9 @@ const KeyMin Key = math.MinInt64
type Value = zodb.Oid
const VDEL = zodb.InvalidOid
type SetKey = set.SetI64
type SetOid = set.SetOid
type SetTid = set.SetTid
type setKey = set.I64
type setOid = set.Oid
type setTid = set.Tid
......
......@@ -99,7 +99,7 @@ type ΔBtail struct {
trackSet PPTreeSubSet
// set of trees for which .trackNew is non-empty
trackNewRoots SetOid
trackNewRoots setOid
// handle to make connections to access database.
// TODO allow client to optionally provide zconnOld/zconnNew on e.g. Update()
......@@ -129,7 +129,7 @@ type ΔTtail struct {
// It describes which trees were changed, but does not provide δkv details for changed trees.
type ΔBroots struct {
Rev zodb.Tid
ΔRoots SetOid // which roots changed in this revision
ΔRoots setOid // which roots changed in this revision
}
// ΔB represents a change in BTrees space.
......@@ -159,7 +159,7 @@ func NewΔBtail(at0 zodb.Tid, db *zodb.DB) *ΔBtail {
vδBroots: nil,
vδTbyRoot: map[zodb.Oid]*ΔTtail{},
trackSet: PPTreeSubSet{},
trackNewRoots: SetOid{},
trackNewRoots: setOid{},
db: db,
}
}
......@@ -321,7 +321,7 @@ func (δBtail *ΔBtail) rebuildAll() (err error) {
δBtail.vδBroots_Update(root, δrevSet)
}
δBtail.trackNewRoots = SetOid{}
δBtail.trackNewRoots = setOid{}
return nil
}
......@@ -334,7 +334,7 @@ func (δBtail *ΔBtail) rebuildAll() (err error) {
// - set of revisions for which new entries in .vδT have been created.
//
// XXX place
func (δTtail *ΔTtail) rebuild(root zodb.Oid, δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet PPTreeSubSet, δrevSet SetTid, err error) {
func (δTtail *ΔTtail) rebuild(root zodb.Oid, δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet PPTreeSubSet, δrevSet setTid, err error) {
defer xerr.Context(&err, "ΔTtail rebuild")
// XXX locking
......@@ -348,7 +348,7 @@ func (δTtail *ΔTtail) rebuild(root zodb.Oid, δZtail *zodb.ΔTail, db *zodb.DB
return nil, nil, nil
}
δrevSet = SetTid{}
δrevSet = setTid{}
// go backwards and merge vδT <- treediff(lo..hi/trackNew)
vδZ := δZtail.Data()
......@@ -474,7 +474,7 @@ func (δTtail *ΔTtail) rebuild1(atPrev zodb.Tid, δZ zodb.ΔRevEntry, trackNew
panicf("BUG: δtopsByRoot has > 1 entries: %v\ntrackNew: %v\nδZ: %v", δtopsByRoot, trackNew, δZ)
}
var root zodb.Oid
var δtops SetOid
var δtops setOid
for root_, δtops_ := range δtopsByRoot {
root = root_
δtops = δtops_
......@@ -594,7 +594,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
}
// vδBroots += δB
δroots := SetOid{}
δroots := setOid{}
for root := range δB.ΔByRoot {
δroots.Add(root)
}
......@@ -681,7 +681,7 @@ func (δBtail *ΔBtail) _Update1(δZ *zodb.EventCommit) (δB1 _ΔBUpdate1, err e
// changed entries with δrevSet revisions.
//
// XXX place TODO δrevSet -> []rev↑
func (δBtail *ΔBtail) vδBroots_Update(root zodb.Oid, δrevSet SetTid) {
func (δBtail *ΔBtail) vδBroots_Update(root zodb.Oid, δrevSet setTid) {
// XXX locking
for rev := range δrevSet {
l := len(δBtail.vδBroots)
......@@ -689,7 +689,7 @@ func (δBtail *ΔBtail) vδBroots_Update(root zodb.Oid, δrevSet SetTid) {
return rev <= δBtail.vδBroots[k].Rev
})
if j == l || δBtail.vδBroots[j].Rev != rev {
δBroots := ΔBroots{Rev: rev, ΔRoots: SetOid{}}
δBroots := ΔBroots{Rev: rev, ΔRoots: setOid{}}
// insert(@j, δBroots)
δBtail.vδBroots = append(δBtail.vδBroots[:j],
append([]ΔBroots{δBroots},
......@@ -708,7 +708,7 @@ func (δBtail *ΔBtail) ForgetPast(revCut zodb.Tid) {
// go through vδBroots till revcut -> find which trees to trim -> trim ΔTtails.
totrim := SetOid{} // roots whose ΔTtail has changes ≤ revCut
totrim := setOid{} // roots whose ΔTtail has changes ≤ revCut
icut := 0
for ; icut < len(δBtail.vδBroots); icut++ {
δBroots := δBtail.vδBroots[icut]
......
This diff is collapsed.
......@@ -33,8 +33,8 @@ import (
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xzodb"
)
type SetI64 = set.SetI64
type SetOid = set.SetOid
type setI64 = set.I64
type setOid = set.Oid
// ΔFtail represents tail of revisional changes to files.
//
......@@ -75,9 +75,9 @@ type SetOid = set.SetOid
type ΔFtail struct {
// ΔFtail merges ΔBtail with history of ZBlk
δBtail *xbtree.ΔBtail
fileIdx map[zodb.Oid]SetOid // tree-root -> {} ZBigFile<oid> as of @head
fileIdx map[zodb.Oid]setOid // tree-root -> {} ZBigFile<oid> as of @head
trackSetZFile SetOid // set of tracked ZBigFiles as of @head
trackSetZFile setOid // set of tracked ZBigFiles as of @head
trackSetZBlk map[zodb.Oid]*zblkTrack // zblk -> {} root -> {}blk as of @head
// XXX kill
///*
......@@ -95,8 +95,8 @@ type ΔFtail struct {
// zblkTrack keeps information in which root/blocks ZBlk is present as of @head.
type zblkTrack struct {
// inroot map[zodb.Oid]SetI64 // {} root -> {}blk XXX later switch to this
infile map[zodb.Oid]SetI64 // {} foid -> {}blk
// inroot map[zodb.Oid]setI64 // {} root -> {}blk XXX later switch to this
infile map[zodb.Oid]setI64 // {} foid -> {}blk
}
// ΔF represents a change in files space.
......@@ -108,7 +108,7 @@ type ΔF struct {
// ΔFile represents a change to one file.
type ΔFile struct {
Rev zodb.Tid
Blocks SetI64 // changed blocks XXX -> ΔBlocks ?
Blocks setI64 // changed blocks XXX -> ΔBlocks ?
Size bool // whether file size changed XXX -> ΔSize?
}
......@@ -123,8 +123,8 @@ type ΔFile struct {
func NewΔFtail(at0 zodb.Tid, db *zodb.DB) *ΔFtail {
return &ΔFtail{
δBtail: xbtree.NewΔBtail(at0, db),
fileIdx: map[zodb.Oid]SetOid{},
trackSetZFile: SetOid{},
fileIdx: map[zodb.Oid]setOid{},
trackSetZFile: setOid{},
trackSetZBlk: map[zodb.Oid]*zblkTrack{},
trackNew: map[zodb.Oid]map[zodb.Oid]*zblkTrack{},
}
......@@ -163,7 +163,7 @@ func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, zb
root := path[0].(*btree.LOBTree)
files, ok := δFtail.fileIdx[root.POid()]
if !ok {
files = SetOid{}
files = setOid{}
δFtail.fileIdx[root.POid()] = files
}
files.Add(foid)
......@@ -181,9 +181,9 @@ func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, zb
blocks, ok := zt.infile[foid]
if !ok {
blocks = make(SetI64, 1)
blocks = make(setI64, 1)
if zt.infile == nil {
zt.infile = make(map[zodb.Oid]SetI64)
zt.infile = make(map[zodb.Oid]setI64)
}
zt.infile[foid] = blocks
}
......@@ -243,7 +243,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit, zhead *xzodb.ZConn) (_ ΔF
for file := range files {
δfile, ok := δF.ByFile[file]
if !ok {
δfile = &ΔFile{Rev: δF.Rev, Blocks: make(SetI64)}
δfile = &ΔFile{Rev: δF.Rev, Blocks: make(setI64)}
δF.ByFile[file] = δfile
}
for blk /*, zblk*/ := range δt {
......@@ -277,7 +277,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit, zhead *xzodb.ZConn) (_ ΔF
for foid, blocks := range zt.infile {
δfile, ok := δF.ByFile[foid]
if !ok {
δfile = &ΔFile{Rev: δF.Rev, Blocks: make(SetI64)}
δfile = &ΔFile{Rev: δF.Rev, Blocks: make(setI64)}
δF.ByFile[foid] = δfile
}
......@@ -328,7 +328,7 @@ func (δFtail *ΔFtail) update(file *ZBigFile) {
// XXX -> func δF.δfile(foid) ?
δfile, ok := δF.ByFile[foid]
if !ok {
δfile = &ΔFile{Rev: δF.Rev, Blocks: make(SetI64)}
δfile = &ΔFile{Rev: δF.Rev, Blocks: make(setI64)}
δF.ByFile[foid] = δfile
}
......
......@@ -27,12 +27,12 @@ import (
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/set"
)
type SetStr = set.SetStr
type setStr = set.Str
// ΔFTestEntry represents one entry in ΔFtail tests.
type ΔFTestEntry struct {
δblkTab map[int64]string // change in tree part {} #blk -> ZBlk<oid>
δblkData SetStr // change to ZBlk objects
δblkData setStr // change to ZBlk objects
}
func TestΔFtail(t *testing.T) {
......@@ -40,8 +40,8 @@ func TestΔFtail(t *testing.T) {
type δT = map[int64]string
// δD is shorthand to create δblkData.
δD := func(zblkv ...string) SetStr {
δ := SetStr{}
δD := func(zblkv ...string) setStr {
δ := setStr{}
for _, zblk := range zblkv {
δ.Add(zblk)
}
......@@ -58,9 +58,9 @@ func TestΔFtail(t *testing.T) {
vδf := []ΔFile{} // (rev↑, {}blk) XXX +.Size?
blkTab := map[int64]string{} // #blk -> ZBlk<oid>
Zinblk := map[string]SetI64{} // ZBlk<oid> -> which #blk refer to it
Zinblk := map[string]setI64{} // ZBlk<oid> -> which #blk refer to it
for _, test := range testv {
δf := SetI64{}
δf := setI64{}
for blk, zblk := range test.δblkTab {
// rebuild blkTab/Zinblk
......@@ -75,7 +75,7 @@ func TestΔFtail(t *testing.T) {
blkTab[blk] = zblk
inblk, ok := Zinblk[zblk]
if !ok {
inblk = SetI64{}
inblk = setI64{}
Zinblk[zblk] = inblk
}
inblk.Add(blk)
......
......@@ -525,7 +525,7 @@ type (
ZData = zdata.ZData
ZBigFile = zdata.ZBigFile
SetI64 = set.SetI64
setI64 = set.I64
)
// Root represents root of wcfs filesystem.
......@@ -632,7 +632,7 @@ type BigFile struct {
// blocks that were ever read-accessed (head/ only) XXX locking by bfdir.δFmu ?
// XXX = δFtail.Tracked(f) ?
accessed SetI64
accessed setI64
// inflight loadings of ZBigFile from ZODB.
// successful load results are kept here until blkdata is put into OS pagecache.
......@@ -2210,7 +2210,7 @@ func (head *Head) bigopen(ctx context.Context, oid zodb.Oid) (_ *BigFile, err er
// FIXME: scan zfile.blktab - so that we can detect all btree changes
// see "XXX building δFtail lazily ..." in notes.txt
f.accessed = make(SetI64)
f.accessed = make(setI64)
f.watchTab = make(map[*Watch]struct{})
}
......
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