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

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

Issue 1364333002: Add AutoIndex (Closed) Base URL: https://github.com/luci/gae.git@add_full_consistency
Patch Set: symbollls Created 5 years, 2 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_selection.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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 217 }
218 }) 218 })
219 default: 219 default:
220 impossible(fmt.Errorf("both values from gkvCollide were nil?")) 220 impossible(fmt.Errorf("both values from gkvCollide were nil?"))
221 } 221 }
222 // TODO(riannucci): remove entries from idxColl and remove index collections 222 // TODO(riannucci): remove entries from idxColl and remove index collections
223 // when there are no index entries for that index any more. 223 // when there are no index entries for that index any more.
224 }) 224 })
225 } 225 }
226 226
227 func addIndex(store *memStore, ns string, compIdx []*ds.IndexDefinition) { 227 func addIndexes(store *memStore, ns string, compIdx []*ds.IndexDefinition) {
228 normalized := make([]*ds.IndexDefinition, len(compIdx)) 228 normalized := make([]*ds.IndexDefinition, len(compIdx))
229 idxColl := store.SetCollection("idx", nil) 229 idxColl := store.SetCollection("idx", nil)
230 for i, idx := range compIdx { 230 for i, idx := range compIdx {
231 normalized[i] = idx.Normalize() 231 normalized[i] = idx.Normalize()
232 idxColl.Set(serialize.ToBytes(*normalized[i].PrepForIdxTable()), []byte{}) 232 idxColl.Set(serialize.ToBytes(*normalized[i].PrepForIdxTable()), []byte{})
233 } 233 }
234 234
235 if allEnts := store.GetCollection("ents:" + ns); allEnts != nil { 235 if allEnts := store.GetCollection("ents:" + ns); allEnts != nil {
236 allEnts.VisitItemsAscend(nil, true, func(i *gkvlite.Item) bool { 236 allEnts.VisitItemsAscend(nil, true, func(i *gkvlite.Item) bool {
237 pm, err := rpmWoCtx(i.Val, ns) 237 pm, err := rpmWoCtx(i.Val, ns)
(...skipping 19 matching lines...) Expand all
257 compIdx := []*ds.IndexDefinition{} 257 compIdx := []*ds.IndexDefinition{}
258 walkCompIdxs(store, nil, func(i *ds.IndexDefinition) bool { 258 walkCompIdxs(store, nil, func(i *ds.IndexDefinition) bool {
259 compIdx = append(compIdx, i) 259 compIdx = append(compIdx, i)
260 return true 260 return true
261 }) 261 })
262 262
263 mergeIndexes(key.Namespace(), store, 263 mergeIndexes(key.Namespace(), store,
264 indexEntriesWithBuiltins(key, oldEnt, compIdx), 264 indexEntriesWithBuiltins(key, oldEnt, compIdx),
265 indexEntriesWithBuiltins(key, newEnt, compIdx)) 265 indexEntriesWithBuiltins(key, newEnt, compIdx))
266 } 266 }
OLDNEW
« no previous file with comments | « impl/memory/datastore_data.go ('k') | impl/memory/datastore_index_selection.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698