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

Unified Diff: impl/memory/datastore_index_selection.go

Issue 1309803004: Add transaction buffer filter. (Closed) Base URL: https://github.com/luci/gae.git@add_query_support
Patch Set: make data flow clearer, implement Count 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 ad76bb7c04ddaa4f2bda4d4d7d9beb126e84e81c..9ee0e9a58cf5a19b53ab35a719946eb11c3844ad 100644
--- a/impl/memory/datastore_index_selection.go
+++ b/impl/memory/datastore_index_selection.go
@@ -36,6 +36,7 @@ func (e *ErrMissingIndex) Error() string {
// deduplication is applied externally
// projection / keysonly / entity retrieval is done externally
type reducedQuery struct {
+ aid string
ns string
kind string
@@ -167,6 +168,9 @@ func (idxs *indexDefinitionSortableSlice) maybeAddDefinition(q *reducedQuery, s
if len(q.eqFilters) > 1 || (len(q.eqFilters) == 1 && q.eqFilters["__ancestor__"] == nil) {
return false
}
+ if len(sortBy) > 1 && q.eqFilters["__ancestor__"] != nil {
+ return false
+ }
}
// Make sure the equalities section doesn't contain any properties we don't
@@ -374,33 +378,25 @@ func generate(q *reducedQuery, idx *indexDefinitionSortable, c *constraints) *it
def.prefix = serialize.Join(def.prefix, chopped)
// Update start and end, since we know that if they contain anything, they
- // contain values for the __key__ field.
+ // contain values for the __key__ field. This is necessary because bytes
+ // are shifting from the suffix to the prefix, and start/end should only
+ // contain suffix (variable) bytes.
if def.start != nil {
- offset := 0
- if len(q.suffixFormat) > 1 {
- chunks, _ := parseSuffix(q.ns, q.suffixFormat, def.start, 1)
- offset = len(chunks[0])
- }
iannucci 2015/09/29 04:43:27 So it turned out that these were just wrong. These
- if !bytes.HasPrefix(def.start[offset:], chopped) {
+ if !bytes.HasPrefix(def.start, chopped) {
// again, shouldn't happen, but if it does, we want to know about it.
impossible(fmt.Errorf(
"start suffix for implied ancestor doesn't start with ancestor! start:%v ancestor:%v",
def.start, chopped))
}
- def.start = def.start[:offset+len(chopped)]
+ def.start = def.start[len(chopped):]
}
if def.end != nil {
- offset := 0
- if len(q.suffixFormat) > 1 {
- chunks, _ := parseSuffix(q.ns, q.suffixFormat, def.end, 1)
- offset = len(chunks[0])
- }
- if !bytes.HasPrefix(def.end[offset:], chopped) {
+ if !bytes.HasPrefix(def.end, chopped) {
impossible(fmt.Errorf(
"end suffix for implied ancestor doesn't start with ancestor! end:%v ancestor:%v",
def.end, chopped))
}
- def.end = def.end[:offset+len(chopped)]
+ def.end = def.end[len(chopped):]
}
}

Powered by Google App Engine
This is Rietveld 408576698