Package edu.caltech.nanodb.functions
This package contains the abstractions for supporting simple functions,
aggregate functions, and tablereturning functions in NanoDB. Additionally,
this package contains many function implementations to use in SQL queries,
as well as a FunctionDirectory
for looking up function implementations
from within the query planning and evaluation code.
Here is a brief description of the abstractions implemented in NanoDB.
 All kinds of functions derive from the abstract
Function
base class.  "Simple functions" take zero or more arguments, and produce one result for
each set of inputs. They may be deterministic or nondeterministic, and
they may access or maintain state data. All simple functions derive from
the
SimpleFunction
class.  "Aggregate functions" take a multiset of inputs, and produce one aggregate
result from that multiset of inputs. Currently, aggregate functions only
accept one multiset (e.g. AVG(n)). All aggregate functions
derive from the
AggregateFunction
class.  Both simple functions and aggregate functions derive from the
ScalarFunction
class, since both of them return a single result value, and both can appear in expressions.  "Table functions" take zero or more arguments, and return a resultset of zero or more tuples. Table functions have an interface similar to the plannode interface so that tuples can be produced one at a time, and other details such as schema and costing details can be exposed by the function.
Function Naming
All function names are uppercase.
Aggregate functions may support the DISTINCT keyword, e.g. "SELECT COUNT(DISTINCT a) FROM t;". In NanoDB, these invocations are mapped to a function invocation with "#DISTINCT" appended to the specified function name. For example, the example SQL will result in NanoDB resolving the invocation to the "COUNT#DISTINCT" function.

Class Summary Class Description Abs Implementation of the ABS(x) SQL function, computes the absolute value of a single argument.AggregateFunction This class provides the general abstraction for aggregate functions.ArcCos Implementation of the ACOS(x) SQL function, computes the arccosine of a single argument.ArcSin Implementation of the ASIN(x) SQL function, computes the arcsine of a single argument.ArcTan Implementation of the ATAN(x) SQL function, computes the arctangent of a single argument.ArcTan2 Implementation of the ATAN2(y, x) SQL function, computes the arctangent of two arguments.Avg Implementation of the AVG(x) SQL aggregate function, computes the average of its inputs.AvgDistinct Implementation of the AVG(DISTINCT x) SQL aggregate function, computes the average of its inputs.Ceil Implementation of the CEIL(x) / CEILING(x) SQL function, computes the smallest whole number larger than the argument.Coalesce Implementation of the COALESCE(a, b, ...) SQL function, returns the first nonNULL argument.Concat Implementation of the CONCAT(s1, s2, ...) SQL function, concatenates two or more arguments as strings.Cos Implementation of the COS(x) SQL function, computes the cosine of a single argument.Count Created by donnie on 12/6/13.CountAggregate This aggregate function can be used to compute both COUNT(...) and COUNT(DISTINCT ...) aggregate functions.CountDistinct Created by donnie on 12/7/13.CountStar Created by donnie on 11/1/14.Floor Computes the largest whole number smaller than the argument.Function This is the root class of all kinds of functions in NanoDB.FunctionDirectory This class is a directory of all functions recognized within NanoDB, including simple functions, aggregate functions and table functions.Greatest Returns the greatest value of all arguments.If ImplementsIF (cond, expr1, expr2)
.IfNull ImplementsIFNULL(expr1, expr2)
.Least Returns the least value of all arguments.Max Created by donnie on 12/7/13.Min Created by donnie on 12/7/13.MinMaxAggregate This aggregate function can be used to compute either the minimum or the maximum of a collection of values.NullIf ImplementsNULLIF(cond, expr)
.Pow Returns the first argument, raised to the second argument power.ReadPerfCounter Returns the current value of the specified performance counter.ResetPerfCounter Resets the specified performance counter, and returns the old value.Round Computes the whole number that is closest to the argument.ScalarFunction This class represents functions that return a scalar value.SimpleFunction Created by donnie on 12/5/13.Sin Implementation of the SIN(x) SQL function, computes the sine of a single argument.Sqrt Computes the square root of a single argument.StdDev Created by donnie on 12/7/13.StdDevVarAggregate This aggregate function can be used to compute either the standard deviation or the variance of a collection of values.Sum Created by donnie on 12/7/13.SumAvgAggregate This aggregate function can be used to compute both SUM and AVERAGE functions.SumDistinct Created by donnie on 12/7/13.TableFunction This is the baseclass for all tablereturning functions.Tan Implementation of the TAN(x) SQL function, computes the tangent of a single argument.Variance Created by donnie on 12/7/13.