| 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 "errors" | 9 "errors" |
| 10 "fmt" | 10 "fmt" |
| 11 "math" | 11 "math" |
| 12 "strings" | 12 "strings" |
| 13 | 13 |
| 14 "appengine/datastore" | 14 "appengine/datastore" |
| 15 pb "appengine_internal/datastore" | 15 pb "appengine_internal/datastore" |
| 16 | 16 |
| 17 "github.com/luci/gkvlite" | 17 "github.com/luci/gkvlite" |
| 18 » "github.com/luci/luci-go/common/funnybase" | 18 » "github.com/luci/luci-go/common/cmpbin" |
| 19 | 19 |
| 20 "infra/gae/libs/wrapper" | 20 "infra/gae/libs/wrapper" |
| 21 ) | 21 ) |
| 22 | 22 |
| 23 type qDirection bool | 23 type qDirection bool |
| 24 | 24 |
| 25 const ( | 25 const ( |
| 26 qASC qDirection = true | 26 qASC qDirection = true |
| 27 qDEC = false | 27 qDEC = false |
| 28 ) | 28 ) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 buf.Write(builtinQueryPrefix) | 82 buf.Write(builtinQueryPrefix) |
| 83 } else { | 83 } else { |
| 84 buf.Write(complexQueryPrefix) | 84 buf.Write(complexQueryPrefix) |
| 85 } | 85 } |
| 86 writeString(buf, i.kind) | 86 writeString(buf, i.kind) |
| 87 if i.ancestor { | 87 if i.ancestor { |
| 88 buf.WriteByte(0) | 88 buf.WriteByte(0) |
| 89 } else { | 89 } else { |
| 90 buf.WriteByte(1) | 90 buf.WriteByte(1) |
| 91 } | 91 } |
| 92 » funnybase.WriteUint(buf, uint64(len(i.sortby))) | 92 » cmpbin.WriteUint(buf, uint64(len(i.sortby))) |
| 93 for _, sb := range i.sortby { | 93 for _, sb := range i.sortby { |
| 94 sb.WriteBinary(buf) | 94 sb.WriteBinary(buf) |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| 98 func (i *qIndex) String() string { | 98 func (i *qIndex) String() string { |
| 99 ret := &bytes.Buffer{} | 99 ret := &bytes.Buffer{} |
| 100 if i.Builtin() { | 100 if i.Builtin() { |
| 101 ret.WriteRune('B') | 101 ret.WriteRune('B') |
| 102 } else { | 102 } else { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 127 i.kind, err = readString(buf) | 127 i.kind, err = readString(buf) |
| 128 if err != nil { | 128 if err != nil { |
| 129 return err | 129 return err |
| 130 } | 130 } |
| 131 anc, err := buf.ReadByte() | 131 anc, err := buf.ReadByte() |
| 132 if err != nil { | 132 if err != nil { |
| 133 return err | 133 return err |
| 134 } | 134 } |
| 135 i.ancestor = anc == 1 | 135 i.ancestor = anc == 1 |
| 136 | 136 |
| 137 » numSorts, err := funnybase.ReadUint(buf) | 137 » numSorts, _, err := cmpbin.ReadUint(buf) |
| 138 if err != nil { | 138 if err != nil { |
| 139 return err | 139 return err |
| 140 } | 140 } |
| 141 if numSorts > 64 { | 141 if numSorts > 64 { |
| 142 return fmt.Errorf("qIndex.ReadBinary: Got over 64 sort orders: %
d", numSorts) | 142 return fmt.Errorf("qIndex.ReadBinary: Got over 64 sort orders: %
d", numSorts) |
| 143 } | 143 } |
| 144 i.sortby = make([]qSortBy, numSorts) | 144 i.sortby = make([]qSortBy, numSorts) |
| 145 for idx := range i.sortby { | 145 for idx := range i.sortby { |
| 146 err = (&i.sortby[idx]).ReadBinary(buf) | 146 err = (&i.sortby[idx]).ReadBinary(buf) |
| 147 if err != nil { | 147 if err != nil { |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 func (q *queryImpl) End(c wrapper.DSCursor) wrapper.DSQuery { | 558 func (q *queryImpl) End(c wrapper.DSCursor) wrapper.DSQuery { |
| 559 q = q.clone() | 559 q = q.clone() |
| 560 curs := c.(queryCursor) | 560 curs := c.(queryCursor) |
| 561 if !curs.Valid() { | 561 if !curs.Valid() { |
| 562 q.err = errors.New("datastore: invalid cursor") | 562 q.err = errors.New("datastore: invalid cursor") |
| 563 return q | 563 return q |
| 564 } | 564 } |
| 565 q.end = curs | 565 q.end = curs |
| 566 return q | 566 return q |
| 567 } | 567 } |
| OLD | NEW |