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

Unified Diff: impl/memory/datastore_index_selection.go

Issue 1364333002: Add AutoIndex (Closed) Base URL: https://github.com/luci/gae.git@add_full_consistency
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: impl/memory/datastore_index_selection.go
diff --git a/impl/memory/datastore_index_selection.go b/impl/memory/datastore_index_selection.go
index 06516d39ff98e841b94725a69042a78772c7bc19..fc4b2b66199aeecf3f5ba7cdf639a06a313d0ab0 100644
--- a/impl/memory/datastore_index_selection.go
+++ b/impl/memory/datastore_index_selection.go
@@ -15,6 +15,22 @@ import (
"github.com/luci/luci-go/common/stringset"
)
+// ErrMissingIndex is returned when the current indexes are not sufficient
+// for the current query.
+type ErrMissingIndex struct {
+ ns string
+ Missing *ds.IndexDefinition
+}
+
+func (e *ErrMissingIndex) Error() string {
+ yaml, err := e.Missing.YAMLString()
+ if err != nil {
+ panic(err)
+ }
+ return fmt.Sprintf(
+ "Insufficient indexes. Consider adding:\n%s", yaml)
+}
+
var bjoin = serialize.Join
// reducedQuery contains only the pieces of the query necessary to iterate for
@@ -301,8 +317,7 @@ func getRelevantIndexes(q *reducedQuery, s *memStore) (indexDefinitionSortableSl
impossible(
fmt.Errorf("recommended missing index would be a builtin: %s", remains))
}
- return nil, fmt.Errorf(
- "Your indexes are insufficient! Try adding:\n %s", remains)
+ return nil, &ErrMissingIndex{q.ns, remains}
}
return idxs, nil

Powered by Google App Engine
This is Rietveld 408576698