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

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

Issue 2987513002: [datastore] improve docs around auto-generated *Keys on Put. (Closed)
Patch Set: Created 3 years, 5 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 | « service/datastore/interface.go ('k') | 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. 1 // Copyright 2015 The LUCI Authors.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 for _, t := range k.toks { 243 for _, t := range k.toks {
244 if t.StringID != "" { 244 if t.StringID != "" {
245 fmt.Fprintf(b, "/%s,%q", t.Kind, t.StringID) 245 fmt.Fprintf(b, "/%s,%q", t.Kind, t.StringID)
246 } else { 246 } else {
247 fmt.Fprintf(b, "/%s,%d", t.Kind, t.IntID) 247 fmt.Fprintf(b, "/%s,%d", t.Kind, t.IntID)
248 } 248 }
249 } 249 }
250 return b.String() 250 return b.String()
251 } 251 }
252 252
253 // IsIncomplete returns true iff k doesn't have an id yet. 253 // IsIncomplete returns true iff the last token of this Key doesn't define
254 // either a StringID or an IntID.
254 func (k *Key) IsIncomplete() bool { 255 func (k *Key) IsIncomplete() bool {
255 return k.LastTok().IsIncomplete() 256 return k.LastTok().IsIncomplete()
256 } 257 }
257 258
258 // Valid determines if a key is valid, according to a couple of rules: 259 // Valid determines if a key is valid, according to a couple of rules:
259 // - k is not nil 260 // - k is not nil
260 // - every token of k: 261 // - every token of k:
261 // - (if !allowSpecial) token's kind doesn't start with '__' 262 // - (if !allowSpecial) token's kind doesn't start with '__'
262 // - token's kind and appid are non-blank 263 // - token's kind and appid are non-blank
263 // - token is not incomplete 264 // - token is not incomplete
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 for _, t := range k.toks { 531 for _, t := range k.toks {
531 ret += int64(len(t.Kind)) 532 ret += int64(len(t.Kind))
532 if t.StringID != "" { 533 if t.StringID != "" {
533 ret += int64(len(t.StringID)) 534 ret += int64(len(t.StringID))
534 } else { 535 } else {
535 ret += 8 536 ret += 8
536 } 537 }
537 } 538 }
538 return ret 539 return ret
539 } 540 }
OLDNEW
« no previous file with comments | « service/datastore/interface.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698