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

Unified Diff: impl/memory/datastore_index.go

Issue 2517833002: Fix #66. (Closed)
Patch Set: 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_index_test.go » ('j') | impl/memory/datastore_test.go » ('J')
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 bab22af29f80de9172c8bb5593360ccd2231a429..0854d1a29abee29213c91af21ea8ab64795847ad 100644
--- a/impl/memory/datastore_index.go
+++ b/impl/memory/datastore_index.go
@@ -55,7 +55,7 @@ func indexEntriesWithBuiltins(k *ds.Key, pm ds.PropertyMap, complexIdxs []*ds.In
return newMemStore()
}
sip = serialize.PropertyMapPartially(k, pm)
- return indexEntries(sip, k.Namespace(), append(defaultIndexes(k.Kind(), pm), complexIdxs...))
+ return indexEntries(k, sip, append(defaultIndexes(k.Kind(), pm), complexIdxs...))
}
// indexRowGen contains enough information to generate all of the index rows which
@@ -144,17 +144,21 @@ func (m *matcher) match(sortBy []ds.IndexColumn, sip serialize.SerializedPmap) (
// 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 {
+func indexEntries(key *ds.Key, sip serialize.SerializedPmap, idxs []*ds.IndexDefinition) memStore {
ret := newMemStore()
idxColl := ret.GetOrCreateCollection("idx")
mtch := matcher{}
for _, idx := range idxs {
idx = idx.Normalize()
+ if idx.Kind != "" && idx.Kind != key.Kind() {
+ continue
+ }
if irg, ok := mtch.match(idx.GetFullSortOrder(), sip); ok {
idxBin := serialize.ToBytes(*idx.PrepForIdxTable())
idxColl.Set(idxBin, []byte{})
- coll := ret.GetOrCreateCollection(fmt.Sprintf("idx:%s:%s", ns, idxBin))
+ coll := ret.GetOrCreateCollection(
+ fmt.Sprintf("idx:%s:%s", key.Namespace(), idxBin))
irg.permute(coll.Set)
}
}
@@ -260,7 +264,7 @@ func addIndexes(store memStore, aid string, compIdx []*ds.IndexDefinition) {
mergeIndexes(ns, store,
newMemStore(),
- indexEntries(sip, ns, normalized))
+ indexEntries(k, sip, normalized))
return true
})
}
« no previous file with comments | « no previous file | impl/memory/datastore_index_test.go » ('j') | impl/memory/datastore_test.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698