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

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

Issue 1358063003: Add Kind/StringID/IntID back to Key. (Closed) Base URL: https://github.com/luci/gae.git@add_allocate_ids
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 unified diff | Download patch
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 28 matching lines...) Expand all
39 ret = append(ret, &ds.IndexDefinition{Kind: kind, SortBy: []ds.I ndexColumn{{Property: name, Descending: true}}}) 39 ret = append(ret, &ds.IndexDefinition{Kind: kind, SortBy: []ds.I ndexColumn{{Property: name, Descending: true}}})
40 } 40 }
41 if serializationDeterministic { 41 if serializationDeterministic {
42 sort.Sort(ret) 42 sort.Sort(ret)
43 } 43 }
44 return ret 44 return ret
45 } 45 }
46 46
47 func indexEntriesWithBuiltins(k *ds.Key, pm ds.PropertyMap, complexIdxs []*ds.In dexDefinition) *memStore { 47 func indexEntriesWithBuiltins(k *ds.Key, pm ds.PropertyMap, complexIdxs []*ds.In dexDefinition) *memStore {
48 sip := partiallySerialize(k, pm) 48 sip := partiallySerialize(k, pm)
49 » return sip.indexEntries(k.Namespace(), append(defaultIndexes(k.Last().Ki nd, pm), complexIdxs...)) 49 » return sip.indexEntries(k.Namespace(), append(defaultIndexes(k.Kind(), p m), complexIdxs...))
50 } 50 }
51 51
52 // serializedPvals is all of the serialized DSProperty values in qASC order. 52 // serializedPvals is all of the serialized DSProperty values in qASC order.
53 type serializedPvals [][]byte 53 type serializedPvals [][]byte
54 54
55 func (s serializedPvals) Len() int { return len(s) } 55 func (s serializedPvals) Len() int { return len(s) }
56 func (s serializedPvals) Swap(i, j int) { s[i], s[j] = s[j], s[i] } 56 func (s serializedPvals) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
57 func (s serializedPvals) Less(i, j int) bool { return bytes.Compare(s[i], s[j]) < 0 } 57 func (s serializedPvals) Less(i, j int) bool { return bytes.Compare(s[i], s[j]) < 0 }
58 58
59 // prop name -> [<serialized DSProperty>, ...] 59 // prop name -> [<serialized DSProperty>, ...]
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 compIdx := []*ds.IndexDefinition{} 306 compIdx := []*ds.IndexDefinition{}
307 walkCompIdxs(store, nil, func(i *ds.IndexDefinition) bool { 307 walkCompIdxs(store, nil, func(i *ds.IndexDefinition) bool {
308 compIdx = append(compIdx, i) 308 compIdx = append(compIdx, i)
309 return true 309 return true
310 }) 310 })
311 311
312 mergeIndexes(key.Namespace(), store, 312 mergeIndexes(key.Namespace(), store,
313 indexEntriesWithBuiltins(key, oldEnt, compIdx), 313 indexEntriesWithBuiltins(key, oldEnt, compIdx),
314 indexEntriesWithBuiltins(key, newEnt, compIdx)) 314 indexEntriesWithBuiltins(key, newEnt, compIdx))
315 } 315 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698