OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |