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

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

Issue 2342063003: Differentiate between single- and multi- props. (Closed)
Patch Set: Slice is now always a clone. This is marginally worse performance, but a much safer UI. Created 4 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 unified diff | Download patch
« no previous file with comments | « impl/memory/datastore_data.go ('k') | impl/memory/datastore_index_test.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 LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be 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"
11 11
12 ds "github.com/luci/gae/service/datastore" 12 ds "github.com/luci/gae/service/datastore"
13 "github.com/luci/gae/service/datastore/serialize" 13 "github.com/luci/gae/service/datastore/serialize"
14 "github.com/luci/gkvlite" 14 "github.com/luci/gkvlite"
15 ) 15 )
16 16
17 type qIndexSlice []*ds.IndexDefinition 17 type qIndexSlice []*ds.IndexDefinition
18 18
19 func (s qIndexSlice) Len() int { return len(s) } 19 func (s qIndexSlice) Len() int { return len(s) }
20 func (s qIndexSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } 20 func (s qIndexSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
21 func (s qIndexSlice) Less(i, j int) bool { return s[i].Less(s[j]) } 21 func (s qIndexSlice) Less(i, j int) bool { return s[i].Less(s[j]) }
22 22
23 func defaultIndexes(kind string, pmap ds.PropertyMap) []*ds.IndexDefinition { 23 func defaultIndexes(kind string, pmap ds.PropertyMap) []*ds.IndexDefinition {
24 ret := make(qIndexSlice, 0, 2*len(pmap)+1) 24 ret := make(qIndexSlice, 0, 2*len(pmap)+1)
25 ret = append(ret, &ds.IndexDefinition{Kind: kind}) 25 ret = append(ret, &ds.IndexDefinition{Kind: kind})
26 » for name, pvals := range pmap { 26 » for name := range pmap {
27 » » pvals := pmap.Slice(name)
27 needsIndex := false 28 needsIndex := false
28 for _, v := range pvals { 29 for _, v := range pvals {
29 if v.IndexSetting() == ds.ShouldIndex { 30 if v.IndexSetting() == ds.ShouldIndex {
30 needsIndex = true 31 needsIndex = true
31 break 32 break
32 } 33 }
33 } 34 }
34 if !needsIndex { 35 if !needsIndex {
35 continue 36 continue
36 } 37 }
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 compIdx := []*ds.IndexDefinition{} 261 compIdx := []*ds.IndexDefinition{}
261 walkCompIdxs(store.Snapshot(), nil, func(i *ds.IndexDefinition) bool { 262 walkCompIdxs(store.Snapshot(), nil, func(i *ds.IndexDefinition) bool {
262 compIdx = append(compIdx, i) 263 compIdx = append(compIdx, i)
263 return true 264 return true
264 }) 265 })
265 266
266 mergeIndexes(key.Namespace(), store, 267 mergeIndexes(key.Namespace(), store,
267 indexEntriesWithBuiltins(key, oldEnt, compIdx), 268 indexEntriesWithBuiltins(key, oldEnt, compIdx),
268 indexEntriesWithBuiltins(key, newEnt, compIdx)) 269 indexEntriesWithBuiltins(key, newEnt, compIdx))
269 } 270 }
OLDNEW
« no previous file with comments | « impl/memory/datastore_data.go ('k') | impl/memory/datastore_index_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698