mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
wip
This commit is contained in:
parent
c856b528a8
commit
67f0b887fa
1 changed files with 10 additions and 10 deletions
|
@ -18,7 +18,7 @@ import (
|
||||||
// See https://docs.victoriametrics.com/victorialogs/logsql/#stats-pipe
|
// See https://docs.victoriametrics.com/victorialogs/logsql/#stats-pipe
|
||||||
type pipeStats struct {
|
type pipeStats struct {
|
||||||
// byFields contains field names with optional buckets from 'by(...)' clause.
|
// byFields contains field names with optional buckets from 'by(...)' clause.
|
||||||
byFields []*byField
|
byFields []*byStatsField
|
||||||
|
|
||||||
// resultNames contains names of output results generated by funcs.
|
// resultNames contains names of output results generated by funcs.
|
||||||
resultNames []string
|
resultNames []string
|
||||||
|
@ -407,7 +407,7 @@ func parsePipeStats(lex *lexer) (*pipeStats, error) {
|
||||||
var ps pipeStats
|
var ps pipeStats
|
||||||
if lex.isKeyword("by") {
|
if lex.isKeyword("by") {
|
||||||
lex.nextToken()
|
lex.nextToken()
|
||||||
bfs, err := parseByFields(lex)
|
bfs, err := parseByStatsFields(lex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot parse 'by' clause: %w", err)
|
return nil, fmt.Errorf("cannot parse 'by' clause: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -508,12 +508,12 @@ func parseResultName(lex *lexer) (string, error) {
|
||||||
return resultName, nil
|
return resultName, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// byField represents by(...) field.
|
// byStatsField represents 'by (...)' part of the pipeStats.
|
||||||
//
|
//
|
||||||
// It can have either `name` representation of `name:bucket` representation,
|
// It can have either 'name' representation or 'name:bucket' or 'name:buket offset off' representation,
|
||||||
// where `bucket` can contain duration, size or numeric value for creating different buckets
|
// where `bucket` and `off` can contain duration, size or numeric value for creating different buckets
|
||||||
// for 'value/bucket'.
|
// for 'value/bucket'.
|
||||||
type byField struct {
|
type byStatsField struct {
|
||||||
name string
|
name string
|
||||||
|
|
||||||
// bucketSizeStr is string representation of the bucket size
|
// bucketSizeStr is string representation of the bucket size
|
||||||
|
@ -529,7 +529,7 @@ type byField struct {
|
||||||
bucketOffset float64
|
bucketOffset float64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bf *byField) String() string {
|
func (bf *byStatsField) String() string {
|
||||||
s := quoteTokenIfNeeded(bf.name)
|
s := quoteTokenIfNeeded(bf.name)
|
||||||
if bf.bucketSizeStr != "" {
|
if bf.bucketSizeStr != "" {
|
||||||
s += ":" + bf.bucketSizeStr
|
s += ":" + bf.bucketSizeStr
|
||||||
|
@ -540,11 +540,11 @@ func (bf *byField) String() string {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseByFields(lex *lexer) ([]*byField, error) {
|
func parseByStatsFields(lex *lexer) ([]*byStatsField, error) {
|
||||||
if !lex.isKeyword("(") {
|
if !lex.isKeyword("(") {
|
||||||
return nil, fmt.Errorf("missing `(`")
|
return nil, fmt.Errorf("missing `(`")
|
||||||
}
|
}
|
||||||
var bfs []*byField
|
var bfs []*byStatsField
|
||||||
for {
|
for {
|
||||||
lex.nextToken()
|
lex.nextToken()
|
||||||
if lex.isKeyword(")") {
|
if lex.isKeyword(")") {
|
||||||
|
@ -555,7 +555,7 @@ func parseByFields(lex *lexer) ([]*byField, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot parse field name: %w", err)
|
return nil, fmt.Errorf("cannot parse field name: %w", err)
|
||||||
}
|
}
|
||||||
bf := &byField{
|
bf := &byStatsField{
|
||||||
name: fieldName,
|
name: fieldName,
|
||||||
}
|
}
|
||||||
if lex.isKeyword(":") {
|
if lex.isKeyword(":") {
|
||||||
|
|
Loading…
Reference in a new issue