| 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 "encoding/base64" | 9 "encoding/base64" |
| 10 "errors" | 10 "errors" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 } | 147 } |
| 148 if len(upper) > 0 { | 148 if len(upper) > 0 { |
| 149 hi = increment(serialize.Invert(upper)) | 149 hi = increment(serialize.Invert(upper)) |
| 150 } | 150 } |
| 151 upper, lower = lo, hi | 151 upper, lower = lo, hi |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 return | 154 return |
| 155 } | 155 } |
| 156 | 156 |
| 157 func reduce(fq *ds.FinalizedQuery, aid, ns string, isTxn bool) (*reducedQuery, e
rror) { | 157 func reduce(fq *ds.FinalizedQuery, kc ds.KeyContext, isTxn bool) (*reducedQuery,
error) { |
| 158 » if err := fq.Valid(aid, ns); err != nil { | 158 » if err := fq.Valid(kc); err != nil { |
| 159 return nil, err | 159 return nil, err |
| 160 } | 160 } |
| 161 if isTxn && fq.Ancestor() == nil { | 161 if isTxn && fq.Ancestor() == nil { |
| 162 return nil, fmt.Errorf("queries within a transaction must includ
e an Ancestor filter") | 162 return nil, fmt.Errorf("queries within a transaction must includ
e an Ancestor filter") |
| 163 } | 163 } |
| 164 if num := numComponents(fq); num > MaxQueryComponents { | 164 if num := numComponents(fq); num > MaxQueryComponents { |
| 165 return nil, fmt.Errorf( | 165 return nil, fmt.Errorf( |
| 166 "gae/memory: query is too large. may not have more than
"+ | 166 "gae/memory: query is too large. may not have more than
"+ |
| 167 "%d filters + sort orders + ancestor total: had
%d", | 167 "%d filters + sort orders + ancestor total: had
%d", |
| 168 MaxQueryComponents, num) | 168 MaxQueryComponents, num) |
| 169 } | 169 } |
| 170 | 170 |
| 171 ret := &reducedQuery{ | 171 ret := &reducedQuery{ |
| 172 » » aid: aid, | 172 » » kc: kc, |
| 173 » » ns: ns, | |
| 174 kind: fq.Kind(), | 173 kind: fq.Kind(), |
| 175 suffixFormat: fq.Orders(), | 174 suffixFormat: fq.Orders(), |
| 176 } | 175 } |
| 177 | 176 |
| 178 eqFilts := fq.EqFilters() | 177 eqFilts := fq.EqFilters() |
| 179 ret.eqFilters = make(map[string]stringset.Set, len(eqFilts)) | 178 ret.eqFilters = make(map[string]stringset.Set, len(eqFilts)) |
| 180 for prop, vals := range eqFilts { | 179 for prop, vals := range eqFilts { |
| 181 sVals := stringset.New(len(vals)) | 180 sVals := stringset.New(len(vals)) |
| 182 for _, v := range vals { | 181 for _, v := range vals { |
| 183 sVals.Add(string(serialize.ToBytes(v))) | 182 sVals.Add(string(serialize.ToBytes(v))) |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 // and the new value has overflowed this representation. | 269 // and the new value has overflowed this representation. |
| 271 // | 270 // |
| 272 // Fortunately, the first byte of a serialized index column entr
y is a | 271 // Fortunately, the first byte of a serialized index column entr
y is a |
| 273 // PropertyType byte, and the only valid values that we'll be in
crementing | 272 // PropertyType byte, and the only valid values that we'll be in
crementing |
| 274 // are never equal to 0xFF, since they have the high bit set (so
either they're | 273 // are never equal to 0xFF, since they have the high bit set (so
either they're |
| 275 // 0x8*, or 0x7*, depending on if it's inverted). | 274 // 0x8*, or 0x7*, depending on if it's inverted). |
| 276 impossible(fmt.Errorf("incrementing %v would require more sigfig
s", bstr)) | 275 impossible(fmt.Errorf("incrementing %v would require more sigfig
s", bstr)) |
| 277 } | 276 } |
| 278 return ret | 277 return ret |
| 279 } | 278 } |
| OLD | NEW |