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

Unified Diff: impl/memory/datastore_index.go

Issue 2498463003: Fix a bug where deletions weren't updating the raw Kind index. (Closed)
Patch Set: Comments, review. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | impl/memory/datastore_query_execution_test.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 db3a83c77a4852da0a0817da58e7e035123af04a..bab22af29f80de9172c8bb5593360ccd2231a429 100644
--- a/impl/memory/datastore_index.go
+++ b/impl/memory/datastore_index.go
@@ -44,8 +44,17 @@ func defaultIndexes(kind string, pmap ds.PropertyMap) []*ds.IndexDefinition {
return ret
}
+// indexEntriesWithBuiltins generates a new memStore containing the default
+// indexes for (k, pm) combined with complexIdxs.
+//
+// If "pm" is nil, this indicates an absence of a value. This is used
+// specifically for deletion.
func indexEntriesWithBuiltins(k *ds.Key, pm ds.PropertyMap, complexIdxs []*ds.IndexDefinition) memStore {
- sip := serialize.PropertyMapPartially(k, pm)
+ var sip serialize.SerializedPmap
+ if pm == nil {
+ return newMemStore()
+ }
+ sip = serialize.PropertyMapPartially(k, pm)
return indexEntries(sip, k.Namespace(), append(defaultIndexes(k.Kind(), pm), complexIdxs...))
}
@@ -133,6 +142,8 @@ func (m *matcher) match(sortBy []ds.IndexColumn, sip serialize.SerializedPmap) (
return m.buf, true
}
+// indexEntries generates a new memStore containing index entries for sip for
+// the supplied index definitions.
func indexEntries(sip serialize.SerializedPmap, ns string, idxs []*ds.IndexDefinition) memStore {
ret := newMemStore()
idxColl := ret.GetOrCreateCollection("idx")
@@ -256,9 +267,14 @@ func addIndexes(store memStore, aid string, compIdx []*ds.IndexDefinition) {
}
}
+// updateIndexes updates the indexes in store to accommodate a change in entity
+// value.
+//
+// oldEnt is the previous entity value, and newEnt is the new entity value. If
+// newEnt is nil, that signifies deletion.
func updateIndexes(store memStore, key *ds.Key, oldEnt, newEnt ds.PropertyMap) {
// load all current complex query index definitions.
- compIdx := []*ds.IndexDefinition{}
+ var compIdx []*ds.IndexDefinition
walkCompIdxs(store.Snapshot(), nil, func(i *ds.IndexDefinition) bool {
compIdx = append(compIdx, i)
return true
« no previous file with comments | « no previous file | impl/memory/datastore_query_execution_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698