Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
yyin-sc committed Sep 4, 2020
1 parent 36c0c65 commit a219d40
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/query/graphite/native/aggregation_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,24 @@ func aggregate(ctx *common.Context, series singlePathSpec, fname string) (ts.Ser
case Max, MaxSeries:
return maxSeries(ctx, multiplePathSpecs(series))
case Avg, Average, AverageSeries:
return averageSeries(ctx,multiplePathSpecs(series))
return averageSeries(ctx, multiplePathSpecs(series))
case Multiply, MultiplySeries:
return multiplySeries(ctx, multiplePathSpecs(series))
case Diff, DiffSeries:
return diffSeries(ctx, multiplePathSpecs(series))
case Count, CountSeries:
return countSeries(ctx, multiplePathSpecs(series))
case Range, RangeOf, RangeOfSeries:
return rangeOfSeries(ctx, series)
case Last, KeepLastValue:
return keepLastValue(ctx, series, -1) // using default value, same as graphite-web python implementation.
case Stdev, Stddev:
// default value for points in python implementation not clear, using an arbitrary 5 data points value should works fine.
// default value for null value ratio is same as graphite-web python implementation.
return stdev(ctx, series, 5, 0.1)
default:
// Median: the movingMedian() method already implemented is returning an series non compatible result. skip support for now.
// avg_zero is not implemented, skip support for now unless later identified actual use cases.
return ts.NewSeriesList(), errors.NewInvalidParamsError(fmt.Errorf("invalid func %s", fname))
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/query/graphite/native/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var (
funcMut sync.RWMutex
functions = map[string]*Function{}
)

// list of graphite function name strings. (not whole list, update on-demand)
const (
Average = "average"
Expand All @@ -49,12 +50,19 @@ const (
Diff = "diff"
DiffSeries = "diffSeries"
Empty = ""
Last = "last"
KeepLastValue = "keepLastValue"
Max = "max"
MaxSeries = "maxSeries"
Min = "min"
MinSeries = "minSeries"
Multiply = "multiply"
MultiplySeries = "multiplySeries"
Range = "range"
RangeOf = "rangeOf"
RangeOfSeries = "rangeOfSeries"
Stdev = "stdev"
Stddev = "stddev"
Sum = "sum"
SumSeries = "sumSeries"
Total = "total"
Expand Down

0 comments on commit a219d40

Please sign in to comment.