Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency whether percentile iterators should return time #7634

Closed
andyfeller opened this issue Nov 17, 2016 · 2 comments
Closed

Inconsistency whether percentile iterators should return time #7634

andyfeller opened this issue Nov 17, 2016 · 2 comments
Assignees
Milestone

Comments

@andyfeller
Copy link

Bug report

System info: InfluxDB 1.1

Additional info:

Unsure whether this is actually a bug or not, however I noticed the inconsistency when I was trying to see how percentile() handles null or missing data. I thought it better to ask whether an issue than ignore it. Forgive for being unable to develop a process to confirm if an actual bug or not.

  1. float percentile iterator returning time
/ NewFloatPercentileReduceSliceFunc returns the percentile value within a window.
func NewFloatPercentileReduceSliceFunc(percentile float64) FloatReduceSliceFunc {
	return func(a []FloatPoint) []FloatPoint {
		length := len(a)
		i := int(math.Floor(float64(length)*percentile/100.0+0.5)) - 1

		if i < 0 || i >= length {
			return nil
		}

		sort.Sort(floatPointsByValue(a))
		return []FloatPoint{{Time: a[i].Time, Value: a[i].Value, Aux: a[i].Aux}}
	}
}
  1. integer percentile iterator returning ZeroTime
// NewIntegerPercentileReduceSliceFunc returns the percentile value within a window.
func NewIntegerPercentileReduceSliceFunc(percentile float64) IntegerReduceSliceFunc {
	return func(a []IntegerPoint) []IntegerPoint {
		length := len(a)
		i := int(math.Floor(float64(length)*percentile/100.0+0.5)) - 1

		if i < 0 || i >= length {
			return nil
		}

		sort.Sort(integerPointsByValue(a))
		return []IntegerPoint{{Time: ZeroTime, Value: a[i].Value, Aux: a[i].Aux}}
	}
}
@andyfeller
Copy link
Author

Seems like this relates to #6292 commit hash 66a599825b7afaa031604b1ef5bfca5ef7a4c0e5 as only floats were update. @jsternberg thoughts?

@jsternberg
Copy link
Contributor

That definitely looks like a bug. Percentile should be a selector for all types.

@jwilder should this fix target 1.1 or 1.2?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants