Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: service/datastore/key.go

Issue 2036543003: Allow uint16 and uint32 in MakeKey. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@add_default_version_hostname
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698