mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
wip
This commit is contained in:
parent
c4b68956fe
commit
46bfdf6796
4 changed files with 30 additions and 14 deletions
|
@ -27,8 +27,12 @@ func (sm *statsFieldsMax) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *statsFieldsMax) updateNeededFields(neededFields fieldsSet) {
|
func (sm *statsFieldsMax) updateNeededFields(neededFields fieldsSet) {
|
||||||
|
if len(sm.resultFields) == 0 {
|
||||||
|
neededFields.add("*")
|
||||||
|
} else {
|
||||||
|
neededFields.addFields(sm.resultFields)
|
||||||
|
}
|
||||||
neededFields.add(sm.srcField)
|
neededFields.add(sm.srcField)
|
||||||
neededFields.addFields(sm.resultFields)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *statsFieldsMax) newStatsProcessor() (statsProcessor, int) {
|
func (sm *statsFieldsMax) newStatsProcessor() (statsProcessor, int) {
|
||||||
|
|
|
@ -27,8 +27,12 @@ func (sm *statsFieldsMin) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *statsFieldsMin) updateNeededFields(neededFields fieldsSet) {
|
func (sm *statsFieldsMin) updateNeededFields(neededFields fieldsSet) {
|
||||||
|
if len(sm.resultFields) == 0 {
|
||||||
|
neededFields.add("*")
|
||||||
|
} else {
|
||||||
|
neededFields.addFields(sm.resultFields)
|
||||||
|
}
|
||||||
neededFields.add(sm.srcField)
|
neededFields.add(sm.srcField)
|
||||||
neededFields.addFields(sm.resultFields)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *statsFieldsMin) newStatsProcessor() (statsProcessor, int) {
|
func (sm *statsFieldsMin) newStatsProcessor() (statsProcessor, int) {
|
||||||
|
|
|
@ -11,11 +11,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type statsMax struct {
|
type statsMax struct {
|
||||||
fields []string
|
fields []string
|
||||||
containsStar bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *statsMax) String() string {
|
func (sm *statsMax) String() string {
|
||||||
|
if len(sm.fields) == 0 {
|
||||||
|
return "max(*)"
|
||||||
|
}
|
||||||
return "max(" + fieldNamesString(sm.fields) + ")"
|
return "max(" + fieldNamesString(sm.fields) + ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +41,7 @@ type statsMaxProcessor struct {
|
||||||
func (smp *statsMaxProcessor) updateStatsForAllRows(br *blockResult) int {
|
func (smp *statsMaxProcessor) updateStatsForAllRows(br *blockResult) int {
|
||||||
maxLen := len(smp.max)
|
maxLen := len(smp.max)
|
||||||
|
|
||||||
if smp.sm.containsStar {
|
if len(smp.sm.fields) == 0 {
|
||||||
// Find the minimum value across all the columns
|
// Find the minimum value across all the columns
|
||||||
for _, c := range br.getColumns() {
|
for _, c := range br.getColumns() {
|
||||||
smp.updateStateForColumn(br, c)
|
smp.updateStateForColumn(br, c)
|
||||||
|
@ -58,7 +60,7 @@ func (smp *statsMaxProcessor) updateStatsForAllRows(br *blockResult) int {
|
||||||
func (smp *statsMaxProcessor) updateStatsForRow(br *blockResult, rowIdx int) int {
|
func (smp *statsMaxProcessor) updateStatsForRow(br *blockResult, rowIdx int) int {
|
||||||
maxLen := len(smp.max)
|
maxLen := len(smp.max)
|
||||||
|
|
||||||
if smp.sm.containsStar {
|
if len(smp.sm.fields) == 0 {
|
||||||
// Find the minimum value across all the fields for the given row
|
// Find the minimum value across all the fields for the given row
|
||||||
for _, c := range br.getColumns() {
|
for _, c := range br.getColumns() {
|
||||||
v := c.getValueAtRow(br, rowIdx)
|
v := c.getValueAtRow(br, rowIdx)
|
||||||
|
@ -170,9 +172,11 @@ func parseStatsMax(lex *lexer) (*statsMax, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if slices.Contains(fields, "*") {
|
||||||
|
fields = nil
|
||||||
|
}
|
||||||
sm := &statsMax{
|
sm := &statsMax{
|
||||||
fields: fields,
|
fields: fields,
|
||||||
containsStar: slices.Contains(fields, "*"),
|
|
||||||
}
|
}
|
||||||
return sm, nil
|
return sm, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type statsMin struct {
|
type statsMin struct {
|
||||||
fields []string
|
fields []string
|
||||||
containsStar bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *statsMin) String() string {
|
func (sm *statsMin) String() string {
|
||||||
|
if len(sm.fields) == 0 {
|
||||||
|
return "min(*)"
|
||||||
|
}
|
||||||
return "min(" + fieldNamesString(sm.fields) + ")"
|
return "min(" + fieldNamesString(sm.fields) + ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +41,7 @@ type statsMinProcessor struct {
|
||||||
func (smp *statsMinProcessor) updateStatsForAllRows(br *blockResult) int {
|
func (smp *statsMinProcessor) updateStatsForAllRows(br *blockResult) int {
|
||||||
minLen := len(smp.min)
|
minLen := len(smp.min)
|
||||||
|
|
||||||
if smp.sm.containsStar {
|
if len(smp.sm.fields) == 0 {
|
||||||
// Find the minimum value across all the columns
|
// Find the minimum value across all the columns
|
||||||
for _, c := range br.getColumns() {
|
for _, c := range br.getColumns() {
|
||||||
smp.updateStateForColumn(br, c)
|
smp.updateStateForColumn(br, c)
|
||||||
|
@ -58,7 +60,7 @@ func (smp *statsMinProcessor) updateStatsForAllRows(br *blockResult) int {
|
||||||
func (smp *statsMinProcessor) updateStatsForRow(br *blockResult, rowIdx int) int {
|
func (smp *statsMinProcessor) updateStatsForRow(br *blockResult, rowIdx int) int {
|
||||||
minLen := len(smp.min)
|
minLen := len(smp.min)
|
||||||
|
|
||||||
if smp.sm.containsStar {
|
if len(smp.sm.fields) == 0 {
|
||||||
// Find the minimum value across all the fields for the given row
|
// Find the minimum value across all the fields for the given row
|
||||||
for _, c := range br.getColumns() {
|
for _, c := range br.getColumns() {
|
||||||
v := c.getValueAtRow(br, rowIdx)
|
v := c.getValueAtRow(br, rowIdx)
|
||||||
|
@ -170,9 +172,11 @@ func parseStatsMin(lex *lexer) (*statsMin, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if slices.Contains(fields, "*") {
|
||||||
|
fields = nil
|
||||||
|
}
|
||||||
sm := &statsMin{
|
sm := &statsMin{
|
||||||
fields: fields,
|
fields: fields,
|
||||||
containsStar: slices.Contains(fields, "*"),
|
|
||||||
}
|
}
|
||||||
return sm, nil
|
return sm, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue