influxdb/influxdb — pull request #551 by chobie (2014-05-17 18:03:58+00:00)
Title: POC: add aggregate funciton top and low #409

This patch provides aggregate function top and low. these function are useful when executing analytics or summarize queries.

#### Added functions:

```
low(columns..., limit)
top(columns..., limit)
```

(I'm not sure `low` is correct function name for this kind of function)

#### For instance:
`select low(value, 10) from series` will output 10 `value` values with ascending order.
`select top(value, 10) from series` will output 10 `value` values with descending order.

#### How to build:
```
go get github.com/ryszard/goskiplist/skiplist
go build src/daemon.go
```

* ryszard/goskiplist is licensed under apache 2.0 license

Why I choose skiplist:
skiplist is useful algorithm when creating ordered set. But this is little bit overkill to aggregate top and low.
I would like to add `range(columns..., begin, end)` and `revrange(columns..., begin, end)` aggregate function so I choose skiplist.

But actually, I don't stick way to provide these function. so feedbacks are welcome.

#### Known Limitations, Problems and TODOs:
* [TODO] Fix query spec
* [TODO]: Should sort 1st column only. (e.g `top(a, b, c, 10)` should sort a column only. )
* [TODO]: Currently, these function support float64 and int64 types.
* [TODO]: Improve Makefile
* [TODO]: Write test cases
* Can't handle same value correctly (probably goskiplist limitation. I'll take a look later)
* Can't show same column name twice (e.g `select top(column_a, column_a, 10) from series` couldn't show 2nd column_a name)

And, I'm not good at English and Golang. so if you find some wrong points, please feel free to comment it.