From 6a0811a949dc947323b4229501099ac0ba382623 Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Wed, 31 Jul 2019 22:23:13 -0700 Subject: [PATCH] *: use new adt.IntervalTree interface Signed-off-by: Gyuho Lee --- auth/range_perm_cache.go | 8 ++++---- auth/range_perm_cache_test.go | 4 ++-- etcdserver/api/v3rpc/key.go | 2 +- mvcc/watcher_group.go | 1 + proxy/grpcproxy/cache/store.go | 1 + 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/auth/range_perm_cache.go b/auth/range_perm_cache.go index 8de2d175c25..7b6c182409c 100644 --- a/auth/range_perm_cache.go +++ b/auth/range_perm_cache.go @@ -28,8 +28,8 @@ func getMergedPerms(lg *zap.Logger, tx backend.BatchTx, userName string) *unifie return nil } - readPerms := &adt.IntervalTree{} - writePerms := &adt.IntervalTree{} + readPerms := adt.NewIntervalTree() + writePerms := adt.NewIntervalTree() for _, roleName := range user.Roles { role := getRole(tx, roleName) @@ -148,6 +148,6 @@ func (as *authStore) invalidateCachedPerm(userName string) { } type unifiedRangePermissions struct { - readPerms *adt.IntervalTree - writePerms *adt.IntervalTree + readPerms adt.IntervalTree + writePerms adt.IntervalTree } diff --git a/auth/range_perm_cache_test.go b/auth/range_perm_cache_test.go index e5baa86b40c..fae488b6c5b 100644 --- a/auth/range_perm_cache_test.go +++ b/auth/range_perm_cache_test.go @@ -48,7 +48,7 @@ func TestRangePermission(t *testing.T) { } for i, tt := range tests { - readPerms := &adt.IntervalTree{} + readPerms := adt.NewIntervalTree() for _, p := range tt.perms { readPerms.Insert(p, struct{}{}) } @@ -89,7 +89,7 @@ func TestKeyPermission(t *testing.T) { } for i, tt := range tests { - readPerms := &adt.IntervalTree{} + readPerms := adt.NewIntervalTree() for _, p := range tt.perms { readPerms.Insert(p, struct{}{}) } diff --git a/etcdserver/api/v3rpc/key.go b/etcdserver/api/v3rpc/key.go index fdb002e0dd8..ff59bac346e 100644 --- a/etcdserver/api/v3rpc/key.go +++ b/etcdserver/api/v3rpc/key.go @@ -179,7 +179,7 @@ func checkTxnRequest(r *pb.TxnRequest, maxTxnOps int) error { // there is an overlap, returns an error. If no overlap, return put and delete // sets for recursive evaluation. func checkIntervals(reqs []*pb.RequestOp) (map[string]struct{}, adt.IntervalTree, error) { - var dels adt.IntervalTree + dels := adt.NewIntervalTree() // collect deletes from this level; build first to check lower level overlapped puts for _, req := range reqs { diff --git a/mvcc/watcher_group.go b/mvcc/watcher_group.go index 07029335a85..151f0de7185 100644 --- a/mvcc/watcher_group.go +++ b/mvcc/watcher_group.go @@ -156,6 +156,7 @@ type watcherGroup struct { func newWatcherGroup() watcherGroup { return watcherGroup{ keyWatchers: make(watcherSetByKey), + ranges: adt.NewIntervalTree(), watchers: make(watcherSet), } } diff --git a/proxy/grpcproxy/cache/store.go b/proxy/grpcproxy/cache/store.go index 1f9688b895f..19a36046c8c 100644 --- a/proxy/grpcproxy/cache/store.go +++ b/proxy/grpcproxy/cache/store.go @@ -53,6 +53,7 @@ func keyFunc(req *pb.RangeRequest) string { func NewCache(maxCacheEntries int) Cache { return &cache{ lru: lru.New(maxCacheEntries), + cachedRanges: adt.NewIntervalTree(), compactedRev: -1, } }