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

Unified Diff: impl/memory/datastore_index.go

Issue 1894403002: datastore: Fix AddIndexes with existing namespaces (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « impl/memory/datastore_data.go ('k') | impl/memory/datastore_query_execution.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/datastore_index.go
diff --git a/impl/memory/datastore_index.go b/impl/memory/datastore_index.go
index 0126034d2bd2d610633528d16782e0f5742783a6..cbd1f36a69b5e328a4582e0e959b3269a02ba9fb 100644
--- a/impl/memory/datastore_index.go
+++ b/impl/memory/datastore_index.go
@@ -224,7 +224,7 @@ func mergeIndexes(ns string, store, oldIdx, newIdx *memStore) {
})
}
-func addIndexes(store *memStore, aid, ns string, compIdx []*ds.IndexDefinition) {
+func addIndexes(store *memStore, aid string, compIdx []*ds.IndexDefinition) {
normalized := make([]*ds.IndexDefinition, len(compIdx))
idxColl := store.SetCollection("idx", nil)
for i, idx := range compIdx {
@@ -232,23 +232,25 @@ func addIndexes(store *memStore, aid, ns string, compIdx []*ds.IndexDefinition)
idxColl.Set(serialize.ToBytes(*normalized[i].PrepForIdxTable()), []byte{})
}
- if allEnts := store.GetCollection("ents:" + ns); allEnts != nil {
- allEnts.VisitItemsAscend(nil, true, func(i *gkvlite.Item) bool {
- pm, err := rpm(i.Val)
- memoryCorruption(err)
+ for _, ns := range namespaces(store) {
+ if allEnts := store.GetCollection("ents:" + ns); allEnts != nil {
+ allEnts.VisitItemsAscend(nil, true, func(i *gkvlite.Item) bool {
+ pm, err := rpm(i.Val)
+ memoryCorruption(err)
- prop, err := serialize.ReadProperty(bytes.NewBuffer(i.Key), serialize.WithoutContext, aid, ns)
- memoryCorruption(err)
+ prop, err := serialize.ReadProperty(bytes.NewBuffer(i.Key), serialize.WithoutContext, aid, ns)
+ memoryCorruption(err)
- k := prop.Value().(*ds.Key)
+ k := prop.Value().(*ds.Key)
- sip := serialize.PropertyMapPartially(k, pm)
+ sip := serialize.PropertyMapPartially(k, pm)
- mergeIndexes(ns, store,
- newMemStore(),
- indexEntries(sip, ns, normalized))
- return true
- })
+ mergeIndexes(ns, store,
+ newMemStore(),
+ indexEntries(sip, ns, normalized))
+ return true
+ })
+ }
}
}
« no previous file with comments | « impl/memory/datastore_data.go ('k') | impl/memory/datastore_query_execution.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698