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

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

Issue 2498463003: Fix a bug where deletions weren't updating the raw Kind index. (Closed)
Patch Set: Fix Created 4 years, 1 month 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 27 matching lines...) Expand all
38 ret = append(ret, &ds.IndexDefinition{Kind: kind, SortBy: []ds.I ndexColumn{{Property: name}}}) 38 ret = append(ret, &ds.IndexDefinition{Kind: kind, SortBy: []ds.I ndexColumn{{Property: name}}})
39 ret = append(ret, &ds.IndexDefinition{Kind: kind, SortBy: []ds.I ndexColumn{{Property: name, Descending: true}}}) 39 ret = append(ret, &ds.IndexDefinition{Kind: kind, SortBy: []ds.I ndexColumn{{Property: name, Descending: true}}})
40 } 40 }
41 if serializationDeterministic { 41 if serializationDeterministic {
42 sort.Sort(ret) 42 sort.Sort(ret)
43 } 43 }
44 return ret 44 return ret
45 } 45 }
46 46
47 func indexEntriesWithBuiltins(k *ds.Key, pm ds.PropertyMap, complexIdxs []*ds.In dexDefinition) memStore { 47 func indexEntriesWithBuiltins(k *ds.Key, pm ds.PropertyMap, complexIdxs []*ds.In dexDefinition) memStore {
48 » sip := serialize.PropertyMapPartially(k, pm) 48 » var sip serialize.SerializedPmap
49 » if pm != nil {
50 » » sip = serialize.PropertyMapPartially(k, pm)
51 » }
49 return indexEntries(sip, k.Namespace(), append(defaultIndexes(k.Kind(), pm), complexIdxs...)) 52 return indexEntries(sip, k.Namespace(), append(defaultIndexes(k.Kind(), pm), complexIdxs...))
50 } 53 }
51 54
52 // indexRowGen contains enough information to generate all of the index rows whi ch 55 // indexRowGen contains enough information to generate all of the index rows whi ch
53 // correspond with a propertyList and a ds.IndexDefinition. 56 // correspond with a propertyList and a ds.IndexDefinition.
54 type indexRowGen struct { 57 type indexRowGen struct {
55 propVec []serialize.SerializedPslice 58 propVec []serialize.SerializedPslice
56 decending []bool 59 decending []bool
57 } 60 }
58 61
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 252
250 mergeIndexes(ns, store, 253 mergeIndexes(ns, store,
251 newMemStore(), 254 newMemStore(),
252 indexEntries(sip, ns, normalized)) 255 indexEntries(sip, ns, normalized))
253 return true 256 return true
254 }) 257 })
255 } 258 }
256 } 259 }
257 } 260 }
258 261
259 func updateIndexes(store memStore, key *ds.Key, oldEnt, newEnt ds.PropertyMap) { 262 func updateIndexes(store memStore, key *ds.Key, oldEnt, newEnt ds.PropertyMap) {
iannucci 2016/11/12 00:05:47 add comment mentioning that nil has special meanin
260 // load all current complex query index definitions. 263 // load all current complex query index definitions.
261 » compIdx := []*ds.IndexDefinition{} 264 » var compIdx []*ds.IndexDefinition
262 walkCompIdxs(store.Snapshot(), nil, func(i *ds.IndexDefinition) bool { 265 walkCompIdxs(store.Snapshot(), nil, func(i *ds.IndexDefinition) bool {
263 compIdx = append(compIdx, i) 266 compIdx = append(compIdx, i)
264 return true 267 return true
265 }) 268 })
266 269
267 mergeIndexes(key.Namespace(), store, 270 mergeIndexes(key.Namespace(), store,
268 indexEntriesWithBuiltins(key, oldEnt, compIdx), 271 indexEntriesWithBuiltins(key, oldEnt, compIdx),
269 indexEntriesWithBuiltins(key, newEnt, compIdx)) 272 indexEntriesWithBuiltins(key, newEnt, compIdx))
270 } 273 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698