forked from caict-benchmark/BDC-TS
-
Notifications
You must be signed in to change notification settings - Fork 1
/
serializer_bcetsdb_bulk.go
47 lines (35 loc) · 939 Bytes
/
serializer_bcetsdb_bulk.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package common
import (
"io"
)
type serializerBceTSDBBulk struct {
}
func NewSerializerBceTSDBBulk() *serializerBceTSDBBulk {
return &serializerBceTSDBBulk{}
}
func (s *serializerBceTSDBBulk) SerializePoint(w io.Writer, p *Point) (err error) {
buf := scratchBufPool.Get().([]byte)
for i := 0; i < len(p.TagKeys); i++ {
buf = append(buf, p.TagValues[i]...)
}
if len(p.FieldKeys) > 0 {
buf = append(buf, ',')
}
for i := 0; i < len(p.FieldKeys); i++ {
v := p.FieldValues[i]
buf = fastFormatAppend(v, buf, false)
if i+1 < len(p.FieldKeys) {
buf = append(buf, ',')
}
}
buf = append(buf, ',')
buf = fastFormatAppend(p.Timestamp.UTC().UnixNano()/1e6, buf, true)
buf = append(buf, '\n')
_, err = w.Write(buf)
buf = buf[:0]
scratchBufPool.Put(buf)
return err
}
func (s *serializerBceTSDBBulk) SerializeSize(w io.Writer, points int64, values int64) error {
return serializeSizeInText(w, points, values)
}