promql: undo accidental exports

This commit is contained in:
Fabian Reinartz 2016-12-24 11:37:16 +01:00
parent 6dedf89cc3
commit ff504af2aa
3 changed files with 31 additions and 31 deletions

View File

@ -722,7 +722,7 @@ func (ev *evaluator) eval(expr Expr) Value {
switch lt, rt := lhs.Type(), rhs.Type(); { switch lt, rt := lhs.Type(), rhs.Type(); {
case lt == ValueTypeScalar && rt == ValueTypeScalar: case lt == ValueTypeScalar && rt == ValueTypeScalar:
return Scalar{ return Scalar{
V: ScalarBinop(e.Op, lhs.(Scalar).V, rhs.(Scalar).V), V: scalarBinop(e.Op, lhs.(Scalar).V, rhs.(Scalar).V),
T: ev.Timestamp, T: ev.Timestamp,
} }
@ -738,10 +738,10 @@ func (ev *evaluator) eval(expr Expr) Value {
return ev.VectorBinop(e.Op, lhs.(Vector), rhs.(Vector), e.VectorMatching, e.ReturnBool) return ev.VectorBinop(e.Op, lhs.(Vector), rhs.(Vector), e.VectorMatching, e.ReturnBool)
} }
case lt == ValueTypeVector && rt == ValueTypeScalar: case lt == ValueTypeVector && rt == ValueTypeScalar:
return ev.VectorScalarBinop(e.Op, lhs.(Vector), rhs.(Scalar), false, e.ReturnBool) return ev.VectorscalarBinop(e.Op, lhs.(Vector), rhs.(Scalar), false, e.ReturnBool)
case lt == ValueTypeScalar && rt == ValueTypeVector: case lt == ValueTypeScalar && rt == ValueTypeVector:
return ev.VectorScalarBinop(e.Op, rhs.(Vector), lhs.(Scalar), true, e.ReturnBool) return ev.VectorscalarBinop(e.Op, rhs.(Vector), lhs.(Scalar), true, e.ReturnBool)
} }
case *Call: case *Call:
@ -969,7 +969,7 @@ func (ev *evaluator) VectorBinop(op itemType, lhs, rhs Vector, matching *VectorM
if matching.Card == CardOneToMany { if matching.Card == CardOneToMany {
vl, vr = vr, vl vl, vr = vr, vl
} }
value, keep := VectorElemBinop(op, vl, vr) value, keep := vectorElemBinop(op, vl, vr)
if returnBool { if returnBool {
if keep { if keep {
value = 1.0 value = 1.0
@ -1112,8 +1112,8 @@ Outer:
return res return res
} }
// VectorScalarBinop evaluates a binary operation between a Vector and a Scalar. // VectorscalarBinop evaluates a binary operation between a Vector and a Scalar.
func (ev *evaluator) VectorScalarBinop(op itemType, lhs Vector, rhs Scalar, swap, returnBool bool) Vector { func (ev *evaluator) VectorscalarBinop(op itemType, lhs Vector, rhs Scalar, swap, returnBool bool) Vector {
vec := make(Vector, 0, len(lhs)) vec := make(Vector, 0, len(lhs))
for _, lhsSample := range lhs { for _, lhsSample := range lhs {
@ -1123,7 +1123,7 @@ func (ev *evaluator) VectorScalarBinop(op itemType, lhs Vector, rhs Scalar, swap
if swap { if swap {
lv, rv = rv, lv lv, rv = rv, lv
} }
value, keep := VectorElemBinop(op, lv, rv) value, keep := vectorElemBinop(op, lv, rv)
if returnBool { if returnBool {
if keep { if keep {
value = 1.0 value = 1.0
@ -1157,8 +1157,8 @@ func copyLabels(metric labels.Labels, withName bool) labels.Labels {
return cm return cm
} }
// ScalarBinop evaluates a binary operation between two Scalars. // scalarBinop evaluates a binary operation between two Scalars.
func ScalarBinop(op itemType, lhs, rhs float64) float64 { func scalarBinop(op itemType, lhs, rhs float64) float64 {
switch op { switch op {
case itemADD: case itemADD:
return lhs + rhs return lhs + rhs
@ -1188,8 +1188,8 @@ func ScalarBinop(op itemType, lhs, rhs float64) float64 {
panic(fmt.Errorf("operator %q not allowed for Scalar operations", op)) panic(fmt.Errorf("operator %q not allowed for Scalar operations", op))
} }
// VectorElemBinop evaluates a binary operation between two Vector elements. // vectorElemBinop evaluates a binary operation between two Vector elements.
func VectorElemBinop(op itemType, lhs, rhs float64) (float64, bool) { func vectorElemBinop(op itemType, lhs, rhs float64) (float64, bool) {
switch op { switch op {
case itemADD: case itemADD:
return lhs + rhs, true return lhs + rhs, true
@ -1239,8 +1239,8 @@ type groupedAggregation struct {
value float64 value float64
valuesSquaredSum float64 valuesSquaredSum float64
groupCount int groupCount int
heap VectorByValueHeap heap vectorByValueHeap
reverseHeap VectorByReverseValueHeap reverseHeap vectorByReverseValueHeap
} }
// aggregation evaluates an aggregation operation on a Vector. // aggregation evaluates an aggregation operation on a Vector.
@ -1309,13 +1309,13 @@ func (ev *evaluator) aggregation(op itemType, grouping []string, without bool, k
groupCount: 1, groupCount: 1,
} }
if op == itemTopK || op == itemQuantile { if op == itemTopK || op == itemQuantile {
result[groupingKey].heap = make(VectorByValueHeap, 0, k) result[groupingKey].heap = make(vectorByValueHeap, 0, k)
heap.Push(&result[groupingKey].heap, &Sample{ heap.Push(&result[groupingKey].heap, &Sample{
Point: Point{V: s.V}, Point: Point{V: s.V},
Metric: s.Metric, Metric: s.Metric,
}) })
} else if op == itemBottomK { } else if op == itemBottomK {
result[groupingKey].reverseHeap = make(VectorByReverseValueHeap, 0, k) result[groupingKey].reverseHeap = make(vectorByReverseValueHeap, 0, k)
heap.Push(&result[groupingKey].reverseHeap, &Sample{ heap.Push(&result[groupingKey].reverseHeap, &Sample{
Point: Point{V: s.V}, Point: Point{V: s.V},
Metric: s.Metric, Metric: s.Metric,

View File

@ -285,7 +285,7 @@ func funcHoltWinters(ev *evaluator, args Expressions) Value {
func funcSort(ev *evaluator, args Expressions) Value { func funcSort(ev *evaluator, args Expressions) Value {
// NaN should sort to the bottom, so take descending sort with NaN first and // NaN should sort to the bottom, so take descending sort with NaN first and
// reverse it. // reverse it.
byValueSorter := VectorByReverseValueHeap(ev.evalVector(args[0])) byValueSorter := vectorByReverseValueHeap(ev.evalVector(args[0]))
sort.Sort(sort.Reverse(byValueSorter)) sort.Sort(sort.Reverse(byValueSorter))
return Vector(byValueSorter) return Vector(byValueSorter)
} }
@ -294,7 +294,7 @@ func funcSort(ev *evaluator, args Expressions) Value {
func funcSortDesc(ev *evaluator, args Expressions) Value { func funcSortDesc(ev *evaluator, args Expressions) Value {
// NaN should sort to the bottom, so take ascending sort with NaN first and // NaN should sort to the bottom, so take ascending sort with NaN first and
// reverse it. // reverse it.
byValueSorter := VectorByValueHeap(ev.evalVector(args[0])) byValueSorter := vectorByValueHeap(ev.evalVector(args[0]))
sort.Sort(sort.Reverse(byValueSorter)) sort.Sort(sort.Reverse(byValueSorter))
return Vector(byValueSorter) return Vector(byValueSorter)
} }
@ -494,7 +494,7 @@ func funcQuantileOverTime(ev *evaluator, args Expressions) Value {
} }
el.Metric = copyLabels(el.Metric, false) el.Metric = copyLabels(el.Metric, false)
values := make(VectorByValueHeap, 0, len(el.Points)) values := make(vectorByValueHeap, 0, len(el.Points))
for _, v := range el.Points { for _, v := range el.Points {
values = append(values, Sample{Point: Point{V: v.V}}) values = append(values, Sample{Point: Point{V: v.V}})
} }
@ -1202,28 +1202,28 @@ func getFunction(name string) (*Function, bool) {
return function, ok return function, ok
} }
type VectorByValueHeap Vector type vectorByValueHeap Vector
func (s VectorByValueHeap) Len() int { func (s vectorByValueHeap) Len() int {
return len(s) return len(s)
} }
func (s VectorByValueHeap) Less(i, j int) bool { func (s vectorByValueHeap) Less(i, j int) bool {
if math.IsNaN(float64(s[i].V)) { if math.IsNaN(float64(s[i].V)) {
return true return true
} }
return s[i].V < s[j].V return s[i].V < s[j].V
} }
func (s VectorByValueHeap) Swap(i, j int) { func (s vectorByValueHeap) Swap(i, j int) {
s[i], s[j] = s[j], s[i] s[i], s[j] = s[j], s[i]
} }
func (s *VectorByValueHeap) Push(x interface{}) { func (s *vectorByValueHeap) Push(x interface{}) {
*s = append(*s, x.(Sample)) *s = append(*s, x.(Sample))
} }
func (s *VectorByValueHeap) Pop() interface{} { func (s *vectorByValueHeap) Pop() interface{} {
old := *s old := *s
n := len(old) n := len(old)
el := old[n-1] el := old[n-1]
@ -1231,28 +1231,28 @@ func (s *VectorByValueHeap) Pop() interface{} {
return el return el
} }
type VectorByReverseValueHeap Vector type vectorByReverseValueHeap Vector
func (s VectorByReverseValueHeap) Len() int { func (s vectorByReverseValueHeap) Len() int {
return len(s) return len(s)
} }
func (s VectorByReverseValueHeap) Less(i, j int) bool { func (s vectorByReverseValueHeap) Less(i, j int) bool {
if math.IsNaN(float64(s[i].V)) { if math.IsNaN(float64(s[i].V)) {
return true return true
} }
return s[i].V > s[j].V return s[i].V > s[j].V
} }
func (s VectorByReverseValueHeap) Swap(i, j int) { func (s vectorByReverseValueHeap) Swap(i, j int) {
s[i], s[j] = s[j], s[i] s[i], s[j] = s[j], s[i]
} }
func (s *VectorByReverseValueHeap) Push(x interface{}) { func (s *vectorByReverseValueHeap) Push(x interface{}) {
*s = append(*s, x.(Sample)) *s = append(*s, x.(Sample))
} }
func (s *VectorByReverseValueHeap) Pop() interface{} { func (s *vectorByReverseValueHeap) Pop() interface{} {
old := *s old := *s
n := len(old) n := len(old)
el := old[n-1] el := old[n-1]

View File

@ -112,7 +112,7 @@ func bucketQuantile(q float64, buckets buckets) float64 {
// If 'values' has zero elements, NaN is returned. // If 'values' has zero elements, NaN is returned.
// If q<0, -Inf is returned. // If q<0, -Inf is returned.
// If q>1, +Inf is returned. // If q>1, +Inf is returned.
func quantile(q float64, values VectorByValueHeap) float64 { func quantile(q float64, values vectorByValueHeap) float64 {
if len(values) == 0 { if len(values) == 0 {
return math.NaN() return math.NaN()
} }