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

Side by Side Diff: filter/txnBuf/state.go

Issue 1929423002: filter/txnBuf: Use fully-qualified App ID. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Go back to "dev~", too many things care. Created 4 years, 7 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 | « no previous file | impl/memory/context.go » ('j') | impl/memory/datastore_test.go » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package txnBuf 5 package txnBuf
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "sync" 9 "sync"
10 10
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // they're same groups affected by the parent transactions. So i nstead of 138 // they're same groups affected by the parent transactions. So i nstead of
139 // respecting opts.XG for inner transactions, we just dup everyt hing from 139 // respecting opts.XG for inner transactions, we just dup everyt hing from
140 // the parent transaction. 140 // the parent transaction.
141 roots = parentState.roots.Dup() 141 roots = parentState.roots.Dup()
142 rootLimit = parentState.rootLimit 142 rootLimit = parentState.rootLimit
143 143
144 sizeBudget = parentState.sizeBudget - parentState.entState.total 144 sizeBudget = parentState.sizeBudget - parentState.entState.total
145 writeCountBudget = parentState.writeCountBudget - parentState.en tState.numWrites() 145 writeCountBudget = parentState.writeCountBudget - parentState.en tState.numWrites()
146 } 146 }
147 147
148 bufDS, err := memory.NewDatastore(inf.FullyQualifiedAppID(), ns)
149 if err != nil {
150 return err
151 }
152
153 state := &txnBufState{ 148 state := &txnBufState{
154 entState: &sizeTracker{}, 149 entState: &sizeTracker{},
155 » » bufDS: bufDS.Raw(), 150 » » bufDS: memory.NewDatastore(inf).Raw(),
156 roots: roots, 151 roots: roots,
157 rootLimit: rootLimit, 152 rootLimit: rootLimit,
158 ns: ns, 153 ns: ns,
159 » » aid: inf.AppID(), 154 » » aid: inf.FullyQualifiedAppID(),
160 parentDS: datastore.Get(context.WithValue(ctx, dsTxnBufH aveLock, true)).Raw(), 155 parentDS: datastore.Get(context.WithValue(ctx, dsTxnBufH aveLock, true)).Raw(),
161 sizeBudget: sizeBudget, 156 sizeBudget: sizeBudget,
162 writeCountBudget: writeCountBudget, 157 writeCountBudget: writeCountBudget,
163 } 158 }
164 » if err = cb(context.WithValue(ctx, dsTxnBufParent, state)); err != nil { 159 » if err := cb(context.WithValue(ctx, dsTxnBufParent, state)); err != nil {
165 return err 160 return err
166 } 161 }
167 162
168 // no reason to unlock this ever. At this point it's toast. 163 // no reason to unlock this ever. At this point it's toast.
169 state.Lock() 164 state.Lock()
170 165
171 if parentState == nil { 166 if parentState == nil {
172 return commitToReal(state) 167 return commitToReal(state)
173 } 168 }
174 169
175 » if err = parentState.canApplyLocked(state); err != nil { 170 » if err := parentState.canApplyLocked(state); err != nil {
176 return err 171 return err
177 } 172 }
178 173
179 parentState.commitLocked(state) 174 parentState.commitLocked(state)
180 return nil 175 return nil
181 } 176 }
182 177
183 // item is a temporary object for representing key/entity pairs and their cache 178 // item is a temporary object for representing key/entity pairs and their cache
184 // state (e.g. if they exist in the in-memory datastore buffer or not). 179 // state (e.g. if they exist in the in-memory datastore buffer or not).
185 // Additionally item memoizes some common comparison strings. item objects 180 // Additionally item memoizes some common comparison strings. item objects
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 // plus a stringset of all the encoded root keys that `keys` represents. 542 // plus a stringset of all the encoded root keys that `keys` represents.
548 func toEncoded(keys []*datastore.Key) (full []string, roots stringset.Set) { 543 func toEncoded(keys []*datastore.Key) (full []string, roots stringset.Set) {
549 roots = stringset.New(len(keys)) 544 roots = stringset.New(len(keys))
550 full = make([]string, len(keys)) 545 full = make([]string, len(keys))
551 for i, k := range keys { 546 for i, k := range keys {
552 roots.Add(string(serialize.ToBytes(k.Root()))) 547 roots.Add(string(serialize.ToBytes(k.Root())))
553 full[i] = string(serialize.ToBytes(k)) 548 full[i] = string(serialize.ToBytes(k))
554 } 549 }
555 return 550 return
556 } 551 }
OLDNEW
« no previous file with comments | « no previous file | impl/memory/context.go » ('j') | impl/memory/datastore_test.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698