reduce arguments to MapTopBottom

pull/4202/head
Cory LaNou 2015-09-23 15:44:36 -05:00
parent ab84d3eb00
commit b2474c9abf
2 changed files with 6 additions and 8 deletions

View File

@ -91,11 +91,10 @@ func initializeMapFunc(c *influxql.Call) (mapFunc, error) {
// Capture information from the call that the Map function will require
lit, _ := c.Args[len(c.Args)-1].(*influxql.NumberLiteral)
limit := int(lit.Val)
args := topCallArgs(c)
fields := c.Fields()
fields := topCallArgs(c)
return func(itr Iterator) interface{} {
return MapTopBottom(itr, limit, args, fields, len(c.Args), c.Name)
return MapTopBottom(itr, limit, fields, len(c.Args), c.Name)
}, nil
case "percentile":
return MapEcho, nil
@ -1451,8 +1450,8 @@ func (m *mapIter) Next() (time int64, value interface{}) {
}
// MapTopBottom emits the top/bottom data points for each group by interval
func MapTopBottom(itr Iterator, limit int, callArgs, fields []string, argCount int, callName string) interface{} {
out := positionOut{callArgs: callArgs}
func MapTopBottom(itr Iterator, limit int, fields []string, argCount int, callName string) interface{} {
out := positionOut{callArgs: fields}
out.points = make([]PositionPoint, 0, limit)
minheap := topBottomMapOut{
&out,

View File

@ -785,10 +785,9 @@ func TestMapTopBottom(t *testing.T) {
}
lit, _ := test.call.Args[len(test.call.Args)-1].(*influxql.NumberLiteral)
limit := int(lit.Val)
args := topCallArgs(test.call)
fields := test.call.Fields()
fields := topCallArgs(test.call)
values := MapTopBottom(test.iter, limit, args, fields, len(test.call.Args), test.call.Name).(PositionPoints)
values := MapTopBottom(test.iter, limit, fields, len(test.call.Args), test.call.Name).(PositionPoints)
t.Logf("Test: %s", test.name)
if exp, got := len(test.exp.points), len(values); exp != got {
t.Errorf("Wrong number of values. exp %v got %v", exp, got)