Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Fix series length on binary series op series operations #38

Closed
kylebrandt opened this issue Oct 30, 2019 · 0 comments · Fixed by #42
Closed

Fix series length on binary series op series operations #38

kylebrandt opened this issue Oct 30, 2019 · 0 comments · Fixed by #42
Assignees
Labels
bug Something isn't working
Projects

Comments

@kylebrandt
Copy link
Contributor

in biSeriesSeries the length of the resulting series is the result of A when A + B. However, only points where there time matches for both A and B are added to the result. This results in a series with a bunch of null points and the Grafana displaying (datapoints outside timerange) in the graph.

func biSeriesSeries(name string, labels dataframe.Labels, op string, aSeries, bSeries Series) (Series, error) {
	newSeries := NewSeries(name, labels, aSeries.Len())
	for aIdx := 0; aIdx < aSeries.Len(); aIdx++ {
		aTime, aF := aSeries.GetPoint(aIdx)
		for bIdx := 0; bIdx < bSeries.Len(); bIdx++ {
			bTime := bSeries.GetTime(bIdx)
			if *aTime == *bTime {
				bF := bSeries.GetValue(bIdx)
				if aF == nil || bF == nil {
					newSeries.SetPoint(aIdx, aTime, nil)
					break
				}
				nF, err := binaryOp(op, *aF, *bF)
				if err != nil {
					return newSeries, err
				}
				newSeries.SetPoint(aIdx, aTime, &nF)
				break
			}
		}
	}
	return newSeries, nil
}
@kylebrandt kylebrandt added the bug Something isn't working label Oct 30, 2019
@aknuds1 aknuds1 self-assigned this Oct 31, 2019
@aknuds1 aknuds1 added this to In progress in GEL TODOs Oct 31, 2019
kylebrandt added a commit that referenced this issue Oct 31, 2019
aknuds1 pushed a commit that referenced this issue Nov 4, 2019
aknuds1 added a commit that referenced this issue Nov 4, 2019
* create failing test for #38
* pkg/mathexp: Use cmp.Diff for diffing obtained and expected results
* pkg/mathexp: When e.g. summing two series, only use corresponding points
@aknuds1 aknuds1 moved this from In progress to Done in GEL TODOs Nov 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
GEL TODOs
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants