Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(469)

Side by Side Diff: filter/dscache/support.go

Issue 2007123002: datastore: Update AllocateIDs to take keys. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Rebase, comments. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « filter/dscache/ds_txn.go ('k') | filter/featureBreaker/rds.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package dscache 5 package dscache
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "math/rand" 9 "math/rand"
10 "time" 10 "time"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 ret[i] = MakeMemcacheKey(s.mr.Intn(shards), key) 57 ret[i] = MakeMemcacheKey(s.mr.Intn(shards), key)
58 } 58 }
59 return ret 59 return ret
60 } 60 }
61 61
62 func (s *supportContext) mkAllKeys(keys []*ds.Key) []string { 62 func (s *supportContext) mkAllKeys(keys []*ds.Key) []string {
63 size := 0 63 size := 0
64 nums := make([]int, len(keys)) 64 nums := make([]int, len(keys))
65 for i, key := range keys { 65 for i, key := range keys {
66 » » if !key.Incomplete() { 66 » » if !key.IsIncomplete() {
67 shards := s.numShards(key) 67 shards := s.numShards(key)
68 nums[i] = shards 68 nums[i] = shards
69 size += shards 69 size += shards
70 } 70 }
71 } 71 }
72 if size == 0 { 72 if size == 0 {
73 return nil 73 return nil
74 } 74 }
75 ret := make([]string, 0, size) 75 ret := make([]string, 0, size)
76 for i, key := range keys { 76 for i, key := range keys {
77 » » if !key.Incomplete() { 77 » » if !key.IsIncomplete() {
78 keySuffix := HashKey(key) 78 keySuffix := HashKey(key)
79 for shard := 0; shard < nums[i]; shard++ { 79 for shard := 0; shard < nums[i]; shard++ {
80 ret = append(ret, fmt.Sprintf(KeyFormat, shard, keySuffix)) 80 ret = append(ret, fmt.Sprintf(KeyFormat, shard, keySuffix))
81 } 81 }
82 } 82 }
83 } 83 }
84 return ret 84 return ret
85 } 85 }
86 86
87 // crappyNonce creates a really crappy nonce using math/rand. This is generally 87 // crappyNonce creates a really crappy nonce using math/rand. This is generally
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return nil, nil 151 return nil, nil
152 } 152 }
153 ret := make([]memcache.Item, len(mcKeys)) 153 ret := make([]memcache.Item, len(mcKeys))
154 for i := range ret { 154 for i := range ret {
155 ret[i] = (s.mc.NewItem(mcKeys[i]). 155 ret[i] = (s.mc.NewItem(mcKeys[i]).
156 SetFlags(uint32(ItemHasLock)). 156 SetFlags(uint32(ItemHasLock)).
157 SetExpiration(time.Second * time.Duration(LockTimeSecond s))) 157 SetExpiration(time.Second * time.Duration(LockTimeSecond s)))
158 } 158 }
159 return ret, mcKeys 159 return ret, mcKeys
160 } 160 }
OLDNEW
« no previous file with comments | « filter/dscache/ds_txn.go ('k') | filter/featureBreaker/rds.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698