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

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

Issue 1363063002: Add ability to estimate the size of a PropertyMap (Closed) Base URL: https://github.com/luci/gae.git@minor_tweak
Patch Set: fix errcheck madness Created 5 years, 3 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 | service/datastore/properties.go » ('j') | 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 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 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 // 403 //
404 // toks is guaranteed to be empty if and only if k is nil. If k is non-nil then 404 // toks is guaranteed to be empty if and only if k is nil. If k is non-nil then
405 // it contains at least one token. 405 // it contains at least one token.
406 func (k *Key) Split() (appID, namespace string, toks []KeyTok) { 406 func (k *Key) Split() (appID, namespace string, toks []KeyTok) {
407 appID = k.appID 407 appID = k.appID
408 namespace = k.namespace 408 namespace = k.namespace
409 toks = make([]KeyTok, len(k.toks)) 409 toks = make([]KeyTok, len(k.toks))
410 copy(toks, k.toks) 410 copy(toks, k.toks)
411 return 411 return
412 } 412 }
413
414 // EstimateSize estimates the size of a Key.
415 //
416 // It uses https://cloud.google.com/appengine/articles/storage_breakdown?csw=1
417 // as a guide for these values.
418 func (k *Key) EstimateSize() int64 {
419 ret := int64(len(k.appID))
420 ret += int64(len(k.namespace))
421 for _, t := range k.toks {
422 ret += int64(len(t.Kind))
423 if t.StringID != "" {
424 ret += int64(len(t.StringID))
425 } else {
426 ret += 8
427 }
428 }
429 return ret
430 }
OLDNEW
« no previous file with comments | « no previous file | service/datastore/properties.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698