Chromium Code Reviews| Index: impl/memory/datastore_query.go |
| diff --git a/impl/memory/datastore_query.go b/impl/memory/datastore_query.go |
| index ba19717682a206b16e3c35d5eea9019543722307..35ec24945e9827a94961133cf4569fe718d1df7e 100644 |
| --- a/impl/memory/datastore_query.go |
| +++ b/impl/memory/datastore_query.go |
| @@ -245,3 +245,27 @@ func reduce(fq *ds.FinalizedQuery, ns string, isTxn bool) (*reducedQuery, error) |
| return ret, nil |
| } |
| + |
| +var invert = serialize.Invert |
|
Vadim Sh.
2015/09/24 19:06:14
same here. why?
iannucci
2015/09/24 19:43:41
same :)
|
| + |
| +func increment(bstr []byte) []byte { |
| + ret, overflow := serialize.Increment(bstr) |
| + if overflow { |
| + // This byte string was ALL 0xFF's. The only safe incrementation to do here |
| + // would be to add a new byte to the beginning of bstr with the value 0x01, |
| + // and a byte to the beginning OF ALL OTHER []byte's which bstr may be |
| + // compared with. This is obviously impossible to do here, so panic. If we |
| + // hit this, then we would need to add a spare 0 byte before every index |
| + // column. |
| + // |
| + // Another way to think about this is that we just accumulated a 'carry' bit, |
| + // and the new value has overflowed this representation. |
| + // |
| + // Fortunately, the first byte of a serialized index column entry is a |
| + // PropertyType byte, and the only valid values that we'll be incrementing |
| + // are never equal to 0xFF, since they have the high bit set (so either they're |
| + // 0x8*, or 0x7*, depending on if it's inverted). |
| + impossible(fmt.Errorf("incrementing %v would require more sigfigs", bstr)) |
| + } |
| + return ret |
| +} |