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

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: symbollls 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
« no previous file with comments | « impl/memory/datastore_index.go ('k') | 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_selection.go
diff --git a/impl/memory/datastore_index_selection.go b/impl/memory/datastore_index_selection.go
index d1601ed9e5235ed873d99f4c14d18420a5400d3e..ad76bb7c04ddaa4f2bda4d4d7d9beb126e84e81c 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)
+}
+
// reducedQuery contains only the pieces of the query necessary to iterate for
// results.
// deduplication is applied externally
@@ -299,8 +315,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
« no previous file with comments | « impl/memory/datastore_index.go ('k') | impl/memory/datastore_query_execution_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698