| OLD | NEW |
| 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" |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 normalized[i] = idx.Normalize() | 233 normalized[i] = idx.Normalize() |
| 234 idxColl.Set(serialize.ToBytes(*normalized[i].PrepForIdxTable()),
[]byte{}) | 234 idxColl.Set(serialize.ToBytes(*normalized[i].PrepForIdxTable()),
[]byte{}) |
| 235 } | 235 } |
| 236 | 236 |
| 237 for _, ns := range namespaces(store) { | 237 for _, ns := range namespaces(store) { |
| 238 if allEnts := store.Snapshot().GetCollection("ents:" + ns); allE
nts != nil { | 238 if allEnts := store.Snapshot().GetCollection("ents:" + ns); allE
nts != nil { |
| 239 allEnts.VisitItemsAscend(nil, true, func(i *gkvlite.Item
) bool { | 239 allEnts.VisitItemsAscend(nil, true, func(i *gkvlite.Item
) bool { |
| 240 pm, err := rpm(i.Val) | 240 pm, err := rpm(i.Val) |
| 241 memoryCorruption(err) | 241 memoryCorruption(err) |
| 242 | 242 |
| 243 » » » » prop, err := serialize.ReadProperty(bytes.NewBuf
fer(i.Key), serialize.WithoutContext, aid, ns) | 243 » » » » prop, err := serialize.ReadProperty(bytes.NewBuf
fer(i.Key), serialize.WithoutContext, ds.KeyContext{aid, ns}) |
| 244 memoryCorruption(err) | 244 memoryCorruption(err) |
| 245 | 245 |
| 246 k := prop.Value().(*ds.Key) | 246 k := prop.Value().(*ds.Key) |
| 247 | 247 |
| 248 sip := serialize.PropertyMapPartially(k, pm) | 248 sip := serialize.PropertyMapPartially(k, pm) |
| 249 | 249 |
| 250 mergeIndexes(ns, store, | 250 mergeIndexes(ns, store, |
| 251 newMemStore(), | 251 newMemStore(), |
| 252 indexEntries(sip, ns, normalized)) | 252 indexEntries(sip, ns, normalized)) |
| 253 return true | 253 return true |
| 254 }) | 254 }) |
| 255 } | 255 } |
| 256 } | 256 } |
| 257 } | 257 } |
| 258 | 258 |
| 259 func updateIndexes(store memStore, key *ds.Key, oldEnt, newEnt ds.PropertyMap) { | 259 func updateIndexes(store memStore, key *ds.Key, oldEnt, newEnt ds.PropertyMap) { |
| 260 // load all current complex query index definitions. | 260 // load all current complex query index definitions. |
| 261 compIdx := []*ds.IndexDefinition{} | 261 compIdx := []*ds.IndexDefinition{} |
| 262 walkCompIdxs(store.Snapshot(), nil, func(i *ds.IndexDefinition) bool { | 262 walkCompIdxs(store.Snapshot(), nil, func(i *ds.IndexDefinition) bool { |
| 263 compIdx = append(compIdx, i) | 263 compIdx = append(compIdx, i) |
| 264 return true | 264 return true |
| 265 }) | 265 }) |
| 266 | 266 |
| 267 mergeIndexes(key.Namespace(), store, | 267 mergeIndexes(key.Namespace(), store, |
| 268 indexEntriesWithBuiltins(key, oldEnt, compIdx), | 268 indexEntriesWithBuiltins(key, oldEnt, compIdx), |
| 269 indexEntriesWithBuiltins(key, newEnt, compIdx)) | 269 indexEntriesWithBuiltins(key, newEnt, compIdx)) |
| 270 } | 270 } |
| OLD | NEW |