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

Side by Side Diff: impl/memory/datastore_index.go

Issue 2302743002: Interface update, per-method Contexts. (Closed)
Patch Set: Created 4 years, 3 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
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 memory 5 package memory
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "fmt" 9 "fmt"
10 "sort" 10 "sort"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 normalized[i] = idx.Normalize() 232 normalized[i] = idx.Normalize()
233 idxColl.Set(serialize.ToBytes(*normalized[i].PrepForIdxTable()), []byte{}) 233 idxColl.Set(serialize.ToBytes(*normalized[i].PrepForIdxTable()), []byte{})
234 } 234 }
235 235
236 for _, ns := range namespaces(store) { 236 for _, ns := range namespaces(store) {
237 if allEnts := store.Snapshot().GetCollection("ents:" + ns); allE nts != nil { 237 if allEnts := store.Snapshot().GetCollection("ents:" + ns); allE nts != nil {
238 allEnts.VisitItemsAscend(nil, true, func(i *gkvlite.Item ) bool { 238 allEnts.VisitItemsAscend(nil, true, func(i *gkvlite.Item ) bool {
239 pm, err := rpm(i.Val) 239 pm, err := rpm(i.Val)
240 memoryCorruption(err) 240 memoryCorruption(err)
241 241
242 » » » » prop, err := serialize.ReadProperty(bytes.NewBuf fer(i.Key), serialize.WithoutContext, aid, ns) 242 » » » » prop, err := serialize.ReadProperty(bytes.NewBuf fer(i.Key), serialize.WithoutContext, ds.KeyContext{aid, ns})
243 memoryCorruption(err) 243 memoryCorruption(err)
244 244
245 k := prop.Value().(*ds.Key) 245 k := prop.Value().(*ds.Key)
246 246
247 sip := serialize.PropertyMapPartially(k, pm) 247 sip := serialize.PropertyMapPartially(k, pm)
248 248
249 mergeIndexes(ns, store, 249 mergeIndexes(ns, store,
250 newMemStore(), 250 newMemStore(),
251 indexEntries(sip, ns, normalized)) 251 indexEntries(sip, ns, normalized))
252 return true 252 return true
253 }) 253 })
254 } 254 }
255 } 255 }
256 } 256 }
257 257
258 func updateIndexes(store memStore, key *ds.Key, oldEnt, newEnt ds.PropertyMap) { 258 func updateIndexes(store memStore, key *ds.Key, oldEnt, newEnt ds.PropertyMap) {
259 // load all current complex query index definitions. 259 // load all current complex query index definitions.
260 compIdx := []*ds.IndexDefinition{} 260 compIdx := []*ds.IndexDefinition{}
261 walkCompIdxs(store.Snapshot(), nil, func(i *ds.IndexDefinition) bool { 261 walkCompIdxs(store.Snapshot(), nil, func(i *ds.IndexDefinition) bool {
262 compIdx = append(compIdx, i) 262 compIdx = append(compIdx, i)
263 return true 263 return true
264 }) 264 })
265 265
266 mergeIndexes(key.Namespace(), store, 266 mergeIndexes(key.Namespace(), store,
267 indexEntriesWithBuiltins(key, oldEnt, compIdx), 267 indexEntriesWithBuiltins(key, oldEnt, compIdx),
268 indexEntriesWithBuiltins(key, newEnt, compIdx)) 268 indexEntriesWithBuiltins(key, newEnt, compIdx))
269 } 269 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698