| 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 11 matching lines...) Expand all Loading... |
| 22 func (s qIndexSlice) Len() int { return len(s) } | 22 func (s qIndexSlice) Len() int { return len(s) } |
| 23 func (s qIndexSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } | 23 func (s qIndexSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } |
| 24 func (s qIndexSlice) Less(i, j int) bool { return s[i].Less(s[j]) } | 24 func (s qIndexSlice) Less(i, j int) bool { return s[i].Less(s[j]) } |
| 25 | 25 |
| 26 func defaultIndicies(kind string, pmap gae.DSPropertyMap) []*qIndex { | 26 func defaultIndicies(kind string, pmap gae.DSPropertyMap) []*qIndex { |
| 27 ret := make(qIndexSlice, 0, 2*len(pmap)+1) | 27 ret := make(qIndexSlice, 0, 2*len(pmap)+1) |
| 28 ret = append(ret, &qIndex{kind, false, nil}) | 28 ret = append(ret, &qIndex{kind, false, nil}) |
| 29 for name, pvals := range pmap { | 29 for name, pvals := range pmap { |
| 30 needsIndex := false | 30 needsIndex := false |
| 31 for _, v := range pvals { | 31 for _, v := range pvals { |
| 32 » » » if !v.NoIndex() { | 32 » » » if v.IndexSetting() == gae.ShouldIndex { |
| 33 needsIndex = true | 33 needsIndex = true |
| 34 break | 34 break |
| 35 } | 35 } |
| 36 } | 36 } |
| 37 if !needsIndex { | 37 if !needsIndex { |
| 38 continue | 38 continue |
| 39 } | 39 } |
| 40 ret = append(ret, &qIndex{kind, false, []qSortBy{{name, qASC}}}) | 40 ret = append(ret, &qIndex{kind, false, []qSortBy{{name, qASC}}}) |
| 41 ret = append(ret, &qIndex{kind, false, []qSortBy{{name, qDEC}}}) | 41 ret = append(ret, &qIndex{kind, false, []qSortBy{{name, qDEC}}}) |
| 42 } | 42 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 64 func partiallySerialize(pm gae.DSPropertyMap) (ret serializedIndexablePmap) { | 64 func partiallySerialize(pm gae.DSPropertyMap) (ret serializedIndexablePmap) { |
| 65 if len(pm) == 0 { | 65 if len(pm) == 0 { |
| 66 return | 66 return |
| 67 } | 67 } |
| 68 | 68 |
| 69 buf := &bytes.Buffer{} | 69 buf := &bytes.Buffer{} |
| 70 ret = make(serializedIndexablePmap, len(pm)) | 70 ret = make(serializedIndexablePmap, len(pm)) |
| 71 for k, vals := range pm { | 71 for k, vals := range pm { |
| 72 newVals := make(serializedPvals, 0, len(vals)) | 72 newVals := make(serializedPvals, 0, len(vals)) |
| 73 for _, v := range vals { | 73 for _, v := range vals { |
| 74 » » » if v.NoIndex() { | 74 » » » if v.IndexSetting() == gae.NoIndex { |
| 75 continue | 75 continue |
| 76 } | 76 } |
| 77 buf.Reset() | 77 buf.Reset() |
| 78 helper.WriteDSProperty(buf, v, helper.WithoutContext) | 78 helper.WriteDSProperty(buf, v, helper.WithoutContext) |
| 79 newVal := make([]byte, buf.Len()) | 79 newVal := make([]byte, buf.Len()) |
| 80 copy(newVal, buf.Bytes()) | 80 copy(newVal, buf.Bytes()) |
| 81 newVals = append(newVals, newVal) | 81 newVals = append(newVals, newVal) |
| 82 } | 82 } |
| 83 if len(newVals) > 0 { | 83 if len(newVals) > 0 { |
| 84 sort.Sort(newVals) | 84 sort.Sort(newVals) |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 }) | 289 }) |
| 290 default: | 290 default: |
| 291 panic("impossible") | 291 panic("impossible") |
| 292 } | 292 } |
| 293 // TODO(riannucci): remove entries from idxColl and remove index
collections | 293 // TODO(riannucci): remove entries from idxColl and remove index
collections |
| 294 // when there are no index entries for that index any more. | 294 // when there are no index entries for that index any more. |
| 295 }) | 295 }) |
| 296 | 296 |
| 297 return nil | 297 return nil |
| 298 } | 298 } |
| OLD | NEW |