| 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 "encoding/base64" | 9 "encoding/base64" |
| 10 "errors" | 10 "errors" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 numComponents += v.Len() | 100 numComponents += v.Len() |
| 101 } | 101 } |
| 102 return numComponents | 102 return numComponents |
| 103 } | 103 } |
| 104 | 104 |
| 105 // GetBinaryBounds gets the binary encoding of the upper and lower bounds of | 105 // GetBinaryBounds gets the binary encoding of the upper and lower bounds of |
| 106 // the inequality filter on fq, if any is defined. If a bound does not exist, | 106 // the inequality filter on fq, if any is defined. If a bound does not exist, |
| 107 // it is nil. | 107 // it is nil. |
| 108 // | 108 // |
| 109 // NOTE: if fq specifies a descending sort order for the inequality, the bounds | 109 // NOTE: if fq specifies a descending sort order for the inequality, the bounds |
| 110 // will be inverted, incremented, and fliped. | 110 // will be inverted, incremented, and flipped. |
| 111 func GetBinaryBounds(fq *ds.FinalizedQuery) (lower, upper []byte) { | 111 func GetBinaryBounds(fq *ds.FinalizedQuery) (lower, upper []byte) { |
| 112 // Pick up the start/end range from the inequalities, if any. | 112 // Pick up the start/end range from the inequalities, if any. |
| 113 // | 113 // |
| 114 // start and end in the reducedQuery are normalized so that `start >= | 114 // start and end in the reducedQuery are normalized so that `start >= |
| 115 // X < end`. Because of that, we need to tweak the inequality filters | 115 // X < end`. Because of that, we need to tweak the inequality filters |
| 116 // contained in the query if they use the > or <= operators. | 116 // contained in the query if they use the > or <= operators. |
| 117 if ineqProp := fq.IneqFilterProp(); ineqProp != "" { | 117 if ineqProp := fq.IneqFilterProp(); ineqProp != "" { |
| 118 _, startOp, startV := fq.IneqFilterLow() | 118 _, startOp, startV := fq.IneqFilterLow() |
| 119 if startOp != "" { | 119 if startOp != "" { |
| 120 lower = serialize.ToBytes(startV) | 120 lower = serialize.ToBytes(startV) |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 // and the new value has overflowed this representation. | 270 // and the new value has overflowed this representation. |
| 271 // | 271 // |
| 272 // Fortunately, the first byte of a serialized index column entr
y is a | 272 // 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 | 273 // 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 | 274 // 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). | 275 // 0x8*, or 0x7*, depending on if it's inverted). |
| 276 impossible(fmt.Errorf("incrementing %v would require more sigfig
s", bstr)) | 276 impossible(fmt.Errorf("incrementing %v would require more sigfig
s", bstr)) |
| 277 } | 277 } |
| 278 return ret | 278 return ret |
| 279 } | 279 } |
| OLD | NEW |