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