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 datastore | 5 package datastore |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 ) | 9 ) |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 } | 32 } |
33 return cmpString(i.Property, o.Property)() | 33 return cmpString(i.Property, o.Property)() |
34 } | 34 } |
35 | 35 |
36 type IndexDefinition struct { | 36 type IndexDefinition struct { |
37 Kind string | 37 Kind string |
38 Ancestor bool | 38 Ancestor bool |
39 SortBy []IndexColumn | 39 SortBy []IndexColumn |
40 } | 40 } |
41 | 41 |
| 42 func (id *IndexDefinition) Equal(o *IndexDefinition) bool { |
| 43 if id.Kind != o.Kind || id.Ancestor != o.Ancestor || len(id.SortBy) != l
en(o.SortBy) { |
| 44 return false |
| 45 } |
| 46 for i, col := range id.SortBy { |
| 47 if col != o.SortBy[i] { |
| 48 return false |
| 49 } |
| 50 } |
| 51 return true |
| 52 } |
| 53 |
42 // Yeah who needs templates, right? | 54 // Yeah who needs templates, right? |
43 // <flames>This is fine.</flames> | 55 // <flames>This is fine.</flames> |
44 | 56 |
45 func cmpBool(a, b bool) func() int { | 57 func cmpBool(a, b bool) func() int { |
46 return func() int { | 58 return func() int { |
47 if a == b { | 59 if a == b { |
48 return 0 | 60 return 0 |
49 } | 61 } |
50 if a && !b { // > | 62 if a && !b { // > |
51 return 1 | 63 return 1 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 return ret.String() | 160 return ret.String() |
149 } | 161 } |
150 | 162 |
151 func IndexBuiltinQueryPrefix() []byte { | 163 func IndexBuiltinQueryPrefix() []byte { |
152 return []byte{0} | 164 return []byte{0} |
153 } | 165 } |
154 | 166 |
155 func IndexComplexQueryPrefix() []byte { | 167 func IndexComplexQueryPrefix() []byte { |
156 return []byte{1} | 168 return []byte{1} |
157 } | 169 } |
OLD | NEW |