Commit Graph

7 Commits (933a14e16f0232c5ec883644b7363a59da7bcd90)

Author SHA1 Message Date
Tim Brooks 343ce42238 Fix #10261 ABS(int64)
Added inline bit-shift absolute value for int64 type as per:
http://cavaliercoder.com/blog/optimized-abs-for-int64-in-go.html
Updated implementations in Iterator and the continuous query service
2018-09-11 21:53:44 +01:00
Jonathan A. Sternberg a1670613a1 Fix the log2 function to return values
The passed in argument wasn't correct so it always returned null instead
of the appropriate value.

Also includes unit tests for all of the math functions and restricts the
`asin()` and `acos()` functions to floats only since those functions
don't give any meaningful results when using integers or unsigned.
2018-05-17 15:44:58 -05:00
Tom Young 42581c7432 Add new math functions:
- abs
- asin, acos, atan, atan2
- exp, ln, log, log2, log10
- pow, sqrt
2018-04-17 12:56:36 -05:00
ahmah2009 7968e21881 Implement floor, ceil, and round functions 2018-04-04 23:53:55 +03:00
Jonathan A. Sternberg f7bfae4044 Update the interface for the simplified call valuer 2018-03-31 00:21:36 -05:00
Jonathan A. Sternberg 6e627cfdbf Implement basic trigonometry functions
This adds support for math functions into the query language. Math
functions are special because they are transformations and do not access
the filesystem in the same way aggregate functions do. A transformation
takes one point and always outputs one point making it more similar to
binary expressions so these math functions follow the same rules as
binary expressions.

This also supports using math literals (so you can do `sin(1)`) and the
math functions can be used anywhere such as in a field or an expression.
Both of the following are supported:

    SELECT sin(value) FROM cpu
    SELECT value FROM cpu WHERE sin(value) > 0.5

Arguments are in radians. Degrees is not supported.
2018-03-20 14:13:52 -05:00
Jonathan A. Sternberg f8d60a881d Refactor the math engine to compile the query and use eval
This change makes it so that we simplify the math engine so it doesn't
use a complicated set of nested iterators. That way, we have to change
math in one fewer place.

It also greatly simplifies the query engine as now we can create the
necessary iterators, join them by time, name, and tags, and then use the
cursor interface to read them and use eval to compute the result. It
makes it so the auxiliary iterators and all of their complexity can be
removed.

This also makes use of the new eval functionality that was recently
added to the influxql package.

No math functions have been added, but the scaffolding has been included
so things like trigonometry functions are just a single commit away.

This also introduces a small breaking change. Because of the call
optimization, it is now possible to use the same selector multiple times
as a selector. So if you do this:

    SELECT max(value) * 2, max(value) / 2 FROM cpu

This will now return the timestamp of the max value rather than zero
since this query is considered to have only a single selector rather
than multiple separate selectors. If any aspect of the selector is
different, such as different selector functions or different arguments,
it will consider the selectors to be aggregates like the old behavior.
2018-03-19 15:01:15 -05:00