feat(storage): Add ParseTagsWithTags API

This API is a benefit when the caller is only interested in parsing
tags and reusing an existing Tags buffer. It will be used by the
storage schema APIs.
pull/13527/head
Stuart Carnie 2019-04-19 16:22:17 -07:00
parent 35e137e1f6
commit 87bfa06a1e
No known key found for this signature in database
GPG Key ID: 848D9C9718D78B4F
2 changed files with 30 additions and 3 deletions

View File

@ -334,6 +334,10 @@ func ParseTags(buf []byte) Tags {
return parseTags(buf, nil)
}
func ParseTagsWithTags(buf []byte, tags Tags) Tags {
return parseTags(buf, tags)
}
func ParseName(buf []byte) []byte {
// Ignore the error because scanMeasurement returns "missing fields" which we ignore
// when just parsing a key

View File

@ -2648,10 +2648,33 @@ func BenchmarkEscapeString_QuotesAndBackslashes(b *testing.B) {
}
}
func BenchmarkParseTags(b *testing.B) {
tags := []byte("cpu,tag0=value0,tag1=value1,tag2=value2,tag3=value3,tag4=value4,tag5=value5")
func BenchmarkParseKeyBytes(b *testing.B) {
buf := []byte("cpu,tag0=value0,tag1=value1,tag2=value2,tag3=value3,tag4=value4,tag5=value5")
for i := 0; i < b.N; i++ {
models.ParseTags(tags)
models.ParseKeyBytes(buf)
}
}
func BenchmarkParseKeyBytesWithTags(b *testing.B) {
var tags models.Tags
buf := []byte("cpu,tag0=value0,tag1=value1,tag2=value2,tag3=value3,tag4=value4,tag5=value5")
for i := 0; i < b.N; i++ {
_, tags = models.ParseKeyBytesWithTags(buf, tags[:0])
}
}
func BenchmarkParseTags(b *testing.B) {
buf := []byte("cpu,tag0=value0,tag1=value1,tag2=value2,tag3=value3,tag4=value4,tag5=value5")
for i := 0; i < b.N; i++ {
models.ParseTags(buf)
}
}
func BenchmarkParseTagsWithTags(b *testing.B) {
var tags models.Tags
buf := []byte("cpu,tag0=value0,tag1=value1,tag2=value2,tag3=value3,tag4=value4,tag5=value5")
for i := 0; i < b.N; i++ {
tags = models.ParseTagsWithTags(buf, tags[:0])
}
}