do not include empty tags in hash

pull/4308/head
Paris Holley 2015-10-04 11:40:14 -07:00 committed by Paul Dix
parent d9f94bdeeb
commit 36898f9451
2 changed files with 20 additions and 1 deletions

View File

@ -1021,6 +1021,10 @@ func (p *point) Tags() Tags {
i, key = scanTo(p.key, i, '=')
i, value = scanTagValue(p.key, i+1)
if len(value) == 0 {
continue
}
tags[string(unescapeTag(key))] = string(unescapeTag(value))
i += 1
@ -1141,7 +1145,10 @@ func (t Tags) HashKey() []byte {
for k, v := range t {
ek := escapeTag([]byte(k))
ev := escapeTag([]byte(v))
escaped[string(ek)] = string(ev)
if len(string(ev)) > 0 {
escaped[string(ek)] = string(ev)
}
}
// Extract keys and determine final size.

View File

@ -605,6 +605,18 @@ func TestParsePointUnescape(t *testing.T) {
},
time.Unix(0, 0)))
// tag with no value
test(t, `cpu,regions=east value="1"`,
models.NewPoint("cpu",
models.Tags{
"regions": "east",
"foobar": "",
},
models.Fields{
"value": "1",
},
time.Unix(0, 0)))
// commas in field values
test(t, `cpu,regions=east value="1,0"`,
models.NewPoint("cpu",