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 datastore | 5 package datastore |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "encoding/base64" | 9 "encoding/base64" |
10 "encoding/json" | 10 "encoding/json" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 t.Kind = knd | 131 t.Kind = knd |
132 switch x := elems[1].(type) { | 132 switch x := elems[1].(type) { |
133 case string: | 133 case string: |
134 t.StringID = x | 134 t.StringID = x |
135 case int: | 135 case int: |
136 t.IntID = int64(x) | 136 t.IntID = int64(x) |
137 case int32: | 137 case int32: |
138 t.IntID = int64(x) | 138 t.IntID = int64(x) |
139 case int64: | 139 case int64: |
140 t.IntID = int64(x) | 140 t.IntID = int64(x) |
| 141 case uint16: |
| 142 t.IntID = int64(x) |
| 143 case uint32: |
| 144 t.IntID = int64(x) |
141 default: | 145 default: |
142 panic(fmt.Errorf("datastore.MakeKey: bad id: %v", x)) | 146 panic(fmt.Errorf("datastore.MakeKey: bad id: %v", x)) |
143 } | 147 } |
144 } | 148 } |
145 | 149 |
146 return NewKeyToks(aid, ns, toks) | 150 return NewKeyToks(aid, ns, toks) |
147 } | 151 } |
148 | 152 |
149 // NewKeyEncoded decodes and returns a *Key | 153 // NewKeyEncoded decodes and returns a *Key |
150 func NewKeyEncoded(encoded string) (ret *Key, err error) { | 154 func NewKeyEncoded(encoded string) (ret *Key, err error) { |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 for _, t := range k.toks { | 456 for _, t := range k.toks { |
453 ret += int64(len(t.Kind)) | 457 ret += int64(len(t.Kind)) |
454 if t.StringID != "" { | 458 if t.StringID != "" { |
455 ret += int64(len(t.StringID)) | 459 ret += int64(len(t.StringID)) |
456 } else { | 460 } else { |
457 ret += 8 | 461 ret += 8 |
458 } | 462 } |
459 } | 463 } |
460 return ret | 464 return ret |
461 } | 465 } |
OLD | NEW |