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

Unified Diff: service/datastore/properties.go

Issue 1358743002: Make Get operations only serialize the bare minimum. (Closed) Base URL: https://github.com/luci/gae.git@fix_time
Patch Set: PropertyMap should always copy on save-out functions to avoid external mutation 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « service/datastore/pls_test.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/datastore/properties.go
diff --git a/service/datastore/properties.go b/service/datastore/properties.go
index d42c098b0ff4c618fe2e271f2e9ba39775b4b861..473269fc92dce5b7400f9a582590c9ef345a89ee 100644
--- a/service/datastore/properties.go
+++ b/service/datastore/properties.go
@@ -680,6 +680,11 @@ type PropertyLoadSaver interface {
MetaGetter
+ // GetAllMeta returns a PropertyMap with all of the metadata in this
+ // PropertyLoadSaver. If a metadata field has an error during serialization,
+ // it is skipped.
+ GetAllMeta() PropertyMap
+
// SetMeta allows you to set the current value of the meta-keyed field.
SetMeta(key string, val interface{}) error
@@ -753,6 +758,19 @@ func (pm PropertyMap) GetMeta(key string) (interface{}, error) {
return v[0].Value(), nil
}
+// GetAllMeta implements PropertyLoadSaver.GetAllMeta.
+func (pm PropertyMap) GetAllMeta() PropertyMap {
+ ret := make(PropertyMap, 8)
+ for k, v := range pm {
+ if isMetaKey(k) {
+ newV := make([]Property, len(v))
+ copy(newV, v)
+ ret[k] = newV
+ }
+ }
+ return ret
+}
+
// GetMetaDefault is the implementation of PropertyLoadSaver.GetMetaDefault.
func (pm PropertyMap) GetMetaDefault(key string, dflt interface{}) interface{} {
return GetMetaDefaultImpl(pm.GetMeta, key, dflt)
« no previous file with comments | « service/datastore/pls_test.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698