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

Side by Side Diff: impl/memory/datastore_index.go

Issue 1286943002: impl/memory: Make queries self-validate (Closed) Base URL: https://github.com/luci/gae.git@add_datastore_testable
Patch Set: rebase Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « impl/memory/datastore.go ('k') | impl/memory/datastore_query.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package memory 5 package memory
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "fmt" 9 "fmt"
10 "sort" 10 "sort"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 buf indexRowGen 158 buf indexRowGen
159 } 159 }
160 160
161 // matcher.match checks to see if the mapped, serialized property values 161 // matcher.match checks to see if the mapped, serialized property values
162 // match the index. If they do, it returns a indexRowGen. Do not write or modify 162 // match the index. If they do, it returns a indexRowGen. Do not write or modify
163 // the data in the indexRowGen. 163 // the data in the indexRowGen.
164 func (m *matcher) match(idx *ds.IndexDefinition, sip serializedIndexablePmap) (i ndexRowGen, bool) { 164 func (m *matcher) match(idx *ds.IndexDefinition, sip serializedIndexablePmap) (i ndexRowGen, bool) {
165 m.buf.propVec = m.buf.propVec[:0] 165 m.buf.propVec = m.buf.propVec[:0]
166 m.buf.orders = m.buf.orders[:0] 166 m.buf.orders = m.buf.orders[:0]
167 for _, sb := range idx.SortBy { 167 for _, sb := range idx.SortBy {
168 if sb.Property == "__key__" {
169 panic("don't know how to build compound index on __key__ ")
170 }
168 if pv, ok := sip[sb.Property]; ok { 171 if pv, ok := sip[sb.Property]; ok {
169 m.buf.propVec = append(m.buf.propVec, pv) 172 m.buf.propVec = append(m.buf.propVec, pv)
170 m.buf.orders = append(m.buf.orders, sb.Direction) 173 m.buf.orders = append(m.buf.orders, sb.Direction)
171 } else { 174 } else {
172 return indexRowGen{}, false 175 return indexRowGen{}, false
173 } 176 }
174 } 177 }
175 return m.buf, true 178 return m.buf, true
176 } 179 }
177 180
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 } 315 }
313 316
314 func updateIndicies(store *memStore, key ds.Key, oldEnt, newEnt ds.PropertyMap) { 317 func updateIndicies(store *memStore, key ds.Key, oldEnt, newEnt ds.PropertyMap) {
315 // load all current complex query index definitions. 318 // load all current complex query index definitions.
316 compIdx := getCompIdxs(getIdxColl(store)) 319 compIdx := getCompIdxs(getIdxColl(store))
317 320
318 mergeIndexes(key.Namespace(), store, 321 mergeIndexes(key.Namespace(), store,
319 indexEntriesWithBuiltins(key, oldEnt, compIdx), 322 indexEntriesWithBuiltins(key, oldEnt, compIdx),
320 indexEntriesWithBuiltins(key, newEnt, compIdx)) 323 indexEntriesWithBuiltins(key, newEnt, compIdx))
321 } 324 }
OLDNEW
« no previous file with comments | « impl/memory/datastore.go ('k') | impl/memory/datastore_query.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698