mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-25 20:00:06 +01:00
0881e5fd5c
Empty fields are treated as non-existing fields by VictoriaLogs data model.
So there is no sense in returning empty fields in query results, since they may mislead and confuse users.
(cherry picked from commit bac193e50b
)
202 lines
6.5 KiB
Go
202 lines
6.5 KiB
Go
// Code generated by qtc from "query_response.qtpl". DO NOT EDIT.
|
|
// See https://github.com/valyala/quicktemplate for details.
|
|
|
|
//line app/vlselect/logsql/query_response.qtpl:1
|
|
package logsql
|
|
|
|
//line app/vlselect/logsql/query_response.qtpl:1
|
|
import (
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logstorage"
|
|
)
|
|
|
|
// JSONRow creates JSON row from the given fields.
|
|
|
|
//line app/vlselect/logsql/query_response.qtpl:8
|
|
import (
|
|
qtio422016 "io"
|
|
|
|
qt422016 "github.com/valyala/quicktemplate"
|
|
)
|
|
|
|
//line app/vlselect/logsql/query_response.qtpl:8
|
|
var (
|
|
_ = qtio422016.Copy
|
|
_ = qt422016.AcquireByteBuffer
|
|
)
|
|
|
|
//line app/vlselect/logsql/query_response.qtpl:8
|
|
func StreamJSONRow(qw422016 *qt422016.Writer, columns []logstorage.BlockColumn, rowIdx int) {
|
|
//line app/vlselect/logsql/query_response.qtpl:10
|
|
i := 0
|
|
for i < len(columns) && columns[i].Values[rowIdx] == "" {
|
|
i++
|
|
}
|
|
columns = columns[i:]
|
|
|
|
//line app/vlselect/logsql/query_response.qtpl:16
|
|
if len(columns) == 0 {
|
|
//line app/vlselect/logsql/query_response.qtpl:17
|
|
return
|
|
//line app/vlselect/logsql/query_response.qtpl:18
|
|
}
|
|
//line app/vlselect/logsql/query_response.qtpl:18
|
|
qw422016.N().S(`{`)
|
|
//line app/vlselect/logsql/query_response.qtpl:20
|
|
c := &columns[0]
|
|
|
|
//line app/vlselect/logsql/query_response.qtpl:21
|
|
qw422016.N().Q(c.Name)
|
|
//line app/vlselect/logsql/query_response.qtpl:21
|
|
qw422016.N().S(`:`)
|
|
//line app/vlselect/logsql/query_response.qtpl:21
|
|
qw422016.N().Q(c.Values[rowIdx])
|
|
//line app/vlselect/logsql/query_response.qtpl:22
|
|
columns = columns[1:]
|
|
|
|
//line app/vlselect/logsql/query_response.qtpl:23
|
|
for colIdx := range columns {
|
|
//line app/vlselect/logsql/query_response.qtpl:25
|
|
c := &columns[colIdx]
|
|
v := c.Values[rowIdx]
|
|
|
|
//line app/vlselect/logsql/query_response.qtpl:28
|
|
if v == "" {
|
|
//line app/vlselect/logsql/query_response.qtpl:29
|
|
continue
|
|
//line app/vlselect/logsql/query_response.qtpl:30
|
|
}
|
|
//line app/vlselect/logsql/query_response.qtpl:30
|
|
qw422016.N().S(`,`)
|
|
//line app/vlselect/logsql/query_response.qtpl:31
|
|
qw422016.N().Q(c.Name)
|
|
//line app/vlselect/logsql/query_response.qtpl:31
|
|
qw422016.N().S(`:`)
|
|
//line app/vlselect/logsql/query_response.qtpl:31
|
|
qw422016.N().Q(c.Values[rowIdx])
|
|
//line app/vlselect/logsql/query_response.qtpl:32
|
|
}
|
|
//line app/vlselect/logsql/query_response.qtpl:32
|
|
qw422016.N().S(`}`)
|
|
//line app/vlselect/logsql/query_response.qtpl:33
|
|
qw422016.N().S(`
|
|
`)
|
|
//line app/vlselect/logsql/query_response.qtpl:34
|
|
}
|
|
|
|
//line app/vlselect/logsql/query_response.qtpl:34
|
|
func WriteJSONRow(qq422016 qtio422016.Writer, columns []logstorage.BlockColumn, rowIdx int) {
|
|
//line app/vlselect/logsql/query_response.qtpl:34
|
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
|
//line app/vlselect/logsql/query_response.qtpl:34
|
|
StreamJSONRow(qw422016, columns, rowIdx)
|
|
//line app/vlselect/logsql/query_response.qtpl:34
|
|
qt422016.ReleaseWriter(qw422016)
|
|
//line app/vlselect/logsql/query_response.qtpl:34
|
|
}
|
|
|
|
//line app/vlselect/logsql/query_response.qtpl:34
|
|
func JSONRow(columns []logstorage.BlockColumn, rowIdx int) string {
|
|
//line app/vlselect/logsql/query_response.qtpl:34
|
|
qb422016 := qt422016.AcquireByteBuffer()
|
|
//line app/vlselect/logsql/query_response.qtpl:34
|
|
WriteJSONRow(qb422016, columns, rowIdx)
|
|
//line app/vlselect/logsql/query_response.qtpl:34
|
|
qs422016 := string(qb422016.B)
|
|
//line app/vlselect/logsql/query_response.qtpl:34
|
|
qt422016.ReleaseByteBuffer(qb422016)
|
|
//line app/vlselect/logsql/query_response.qtpl:34
|
|
return qs422016
|
|
//line app/vlselect/logsql/query_response.qtpl:34
|
|
}
|
|
|
|
// JSONRows prints formatted rows
|
|
|
|
//line app/vlselect/logsql/query_response.qtpl:37
|
|
func StreamJSONRows(qw422016 *qt422016.Writer, rows [][]logstorage.Field) {
|
|
//line app/vlselect/logsql/query_response.qtpl:38
|
|
if len(rows) == 0 {
|
|
//line app/vlselect/logsql/query_response.qtpl:39
|
|
return
|
|
//line app/vlselect/logsql/query_response.qtpl:40
|
|
}
|
|
//line app/vlselect/logsql/query_response.qtpl:41
|
|
for _, fields := range rows {
|
|
//line app/vlselect/logsql/query_response.qtpl:42
|
|
fields = logstorage.SkipLeadingFieldsWithoutValues(fields)
|
|
|
|
//line app/vlselect/logsql/query_response.qtpl:43
|
|
if len(fields) == 0 {
|
|
//line app/vlselect/logsql/query_response.qtpl:44
|
|
continue
|
|
//line app/vlselect/logsql/query_response.qtpl:45
|
|
}
|
|
//line app/vlselect/logsql/query_response.qtpl:45
|
|
qw422016.N().S(`{`)
|
|
//line app/vlselect/logsql/query_response.qtpl:47
|
|
if len(fields) > 0 {
|
|
//line app/vlselect/logsql/query_response.qtpl:49
|
|
f := fields[0]
|
|
fields = fields[1:]
|
|
|
|
//line app/vlselect/logsql/query_response.qtpl:52
|
|
qw422016.N().Q(f.Name)
|
|
//line app/vlselect/logsql/query_response.qtpl:52
|
|
qw422016.N().S(`:`)
|
|
//line app/vlselect/logsql/query_response.qtpl:52
|
|
qw422016.N().Q(f.Value)
|
|
//line app/vlselect/logsql/query_response.qtpl:53
|
|
for _, f := range fields {
|
|
//line app/vlselect/logsql/query_response.qtpl:54
|
|
if f.Value == "" {
|
|
//line app/vlselect/logsql/query_response.qtpl:55
|
|
continue
|
|
//line app/vlselect/logsql/query_response.qtpl:56
|
|
}
|
|
//line app/vlselect/logsql/query_response.qtpl:56
|
|
qw422016.N().S(`,`)
|
|
//line app/vlselect/logsql/query_response.qtpl:57
|
|
qw422016.N().Q(f.Name)
|
|
//line app/vlselect/logsql/query_response.qtpl:57
|
|
qw422016.N().S(`:`)
|
|
//line app/vlselect/logsql/query_response.qtpl:57
|
|
qw422016.N().Q(f.Value)
|
|
//line app/vlselect/logsql/query_response.qtpl:58
|
|
}
|
|
//line app/vlselect/logsql/query_response.qtpl:59
|
|
}
|
|
//line app/vlselect/logsql/query_response.qtpl:59
|
|
qw422016.N().S(`}`)
|
|
//line app/vlselect/logsql/query_response.qtpl:60
|
|
qw422016.N().S(`
|
|
`)
|
|
//line app/vlselect/logsql/query_response.qtpl:61
|
|
}
|
|
//line app/vlselect/logsql/query_response.qtpl:62
|
|
}
|
|
|
|
//line app/vlselect/logsql/query_response.qtpl:62
|
|
func WriteJSONRows(qq422016 qtio422016.Writer, rows [][]logstorage.Field) {
|
|
//line app/vlselect/logsql/query_response.qtpl:62
|
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
|
//line app/vlselect/logsql/query_response.qtpl:62
|
|
StreamJSONRows(qw422016, rows)
|
|
//line app/vlselect/logsql/query_response.qtpl:62
|
|
qt422016.ReleaseWriter(qw422016)
|
|
//line app/vlselect/logsql/query_response.qtpl:62
|
|
}
|
|
|
|
//line app/vlselect/logsql/query_response.qtpl:62
|
|
func JSONRows(rows [][]logstorage.Field) string {
|
|
//line app/vlselect/logsql/query_response.qtpl:62
|
|
qb422016 := qt422016.AcquireByteBuffer()
|
|
//line app/vlselect/logsql/query_response.qtpl:62
|
|
WriteJSONRows(qb422016, rows)
|
|
//line app/vlselect/logsql/query_response.qtpl:62
|
|
qs422016 := string(qb422016.B)
|
|
//line app/vlselect/logsql/query_response.qtpl:62
|
|
qt422016.ReleaseByteBuffer(qb422016)
|
|
//line app/vlselect/logsql/query_response.qtpl:62
|
|
return qs422016
|
|
//line app/vlselect/logsql/query_response.qtpl:62
|
|
}
|