Skip to content

Commit

Permalink
*: use new adt.IntervalTree interface
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
  • Loading branch information
gyuho committed Aug 1, 2019
1 parent 3cc3aff commit 6a0811a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions auth/range_perm_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions auth/range_perm_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{})
}
Expand Down Expand Up @@ -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{}{})
}
Expand Down
2 changes: 1 addition & 1 deletion etcdserver/api/v3rpc/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions mvcc/watcher_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ type watcherGroup struct {
func newWatcherGroup() watcherGroup {
return watcherGroup{
keyWatchers: make(watcherSetByKey),
ranges: adt.NewIntervalTree(),
watchers: make(watcherSet),
}
}
Expand Down
1 change: 1 addition & 0 deletions proxy/grpcproxy/cache/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down

0 comments on commit 6a0811a

Please sign in to comment.