mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect/promql: refactor implementations for and
and unless
binary operations, so they are closer to or
implementation
This commit is contained in:
parent
2d9b3ad5b3
commit
256fd9a87e
1 changed files with 16 additions and 21 deletions
|
@ -290,12 +290,14 @@ func binaryOpAnd(bfa *binaryOpFuncArg) ([]*timeseries, error) {
|
|||
if tssLeft == nil {
|
||||
continue
|
||||
}
|
||||
for i := range tssLeft[0].Values {
|
||||
if !isAllNaNs(tssRight, i) {
|
||||
continue
|
||||
}
|
||||
// Add gaps to tssLeft if there are gaps at valuesRight.
|
||||
valuesRight := tssRight[0].Values
|
||||
for _, tsLeft := range tssLeft {
|
||||
tsLeft.Values[i] = nan
|
||||
valuesLeft := tsLeft.Values
|
||||
for i, v := range valuesRight {
|
||||
if math.IsNaN(v) {
|
||||
valuesLeft[i] = nan
|
||||
}
|
||||
}
|
||||
}
|
||||
tssLeft = removeNaNs(tssLeft)
|
||||
|
@ -340,12 +342,14 @@ func binaryOpUnless(bfa *binaryOpFuncArg) ([]*timeseries, error) {
|
|||
rvs = append(rvs, tssLeft...)
|
||||
continue
|
||||
}
|
||||
for i := range tssLeft[0].Values {
|
||||
if isAllNaNs(tssRight, i) {
|
||||
continue
|
||||
}
|
||||
// Add gaps to tssLeft if the are no gaps at valuesRight.
|
||||
valuesRight := tssRight[0].Values
|
||||
for _, tsLeft := range tssLeft {
|
||||
tsLeft.Values[i] = nan
|
||||
valuesLeft := tsLeft.Values
|
||||
for i, v := range valuesRight {
|
||||
if !math.IsNaN(v) {
|
||||
valuesLeft[i] = nan
|
||||
}
|
||||
}
|
||||
}
|
||||
tssLeft = removeNaNs(tssLeft)
|
||||
|
@ -354,15 +358,6 @@ func binaryOpUnless(bfa *binaryOpFuncArg) ([]*timeseries, error) {
|
|||
return rvs, nil
|
||||
}
|
||||
|
||||
func isAllNaNs(tss []*timeseries, idx int) bool {
|
||||
for _, ts := range tss {
|
||||
if !math.IsNaN(ts.Values[idx]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func createTimeseriesMapByTagSet(be *metricsql.BinaryOpExpr, left, right []*timeseries) (map[string][]*timeseries, map[string][]*timeseries) {
|
||||
groupTags := be.GroupModifier.Args
|
||||
groupOp := strings.ToLower(be.GroupModifier.Op)
|
||||
|
|
Loading…
Reference in a new issue