Index: service/datastore/properties.go |
diff --git a/service/datastore/properties.go b/service/datastore/properties.go |
index dfa91515cca6432f38b102d2a119ca230e3655b5..b614920f84494f8cee4bea389b55049d25576fb9 100644 |
--- a/service/datastore/properties.go |
+++ b/service/datastore/properties.go |
@@ -414,7 +414,7 @@ func (pm PropertyMap) Save(withMeta bool) (PropertyMap, error) { |
} |
ret := make(PropertyMap, len(pm)) |
for k, v := range pm { |
- if withMeta || len(k) == 0 || k[0] != '$' { |
+ if withMeta || !isMetaKey(k) { |
ret[k] = append(ret[k], v...) |
} |
} |
@@ -450,3 +450,21 @@ func (pm PropertyMap) SetMeta(key string, val interface{}) error { |
func (pm PropertyMap) Problem() error { |
return nil |
} |
+ |
+// DataLen returns the number of non-metadata rows in this PropertyMap. |
+func (pm PropertyMap) DataLen() int { |
+ ret := 0 |
+ for k := range pm { |
+ if isMetaKey(k) { |
+ continue |
+ } |
+ ret++ |
+ } |
+ return ret |
+} |
+ |
+func isMetaKey(k string) bool { |
+ // empty counts as a metakey since it's not a valid data key, but it's |
+ // not really a valid metakey either. |
+ return k == "" || k[0] == '$' |
+} |