Package edu.caltech.nanodb.functions
Class FunctionDirectory
- java.lang.Object
-
- edu.caltech.nanodb.functions.FunctionDirectory
-
public class FunctionDirectory extends java.lang.Object
This class is a directory of all functions recognized within NanoDB, including simple functions, aggregate functions and table functions. Generally there will be one function directory perNanoDBServer
object, used for that server.
-
-
Constructor Summary
Constructors Constructor Description FunctionDirectory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFunction(java.lang.String funcName, java.lang.Class<? extends Function> impl)
Add a function to the directory.Function
getFunction(java.lang.String funcName)
If the specified function name corresponds to an existing function, this method instantiates a new object that can compute the function, and then returns it.private void
initBuiltinFunctions()
This helper function initializes all of the built-in functions that are part of NanoDB.
-
-
-
Field Detail
-
functions
private java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Class<? extends Function>> functions
This map holds the association of function names to their implementations.
-
-
Method Detail
-
initBuiltinFunctions
private void initBuiltinFunctions()
This helper function initializes all of the built-in functions that are part of NanoDB.
-
addFunction
public void addFunction(java.lang.String funcName, java.lang.Class<? extends Function> impl)
Add a function to the directory. The function's name is trimmed and converted to uppercase before updating the directory. If the directory already contains a function with the specified name, an exception is reported.- Parameters:
funcName
- the name of the functionimpl
- theFunction
object that implements this function- Throws:
java.lang.IllegalArgumentException
- if the name or implementation is null, or if the function already appears in the directory
-
getFunction
public Function getFunction(java.lang.String funcName)
If the specified function name corresponds to an existing function, this method instantiates a new object that can compute the function, and then returns it.- Parameters:
funcName
- the name of the function to get- Returns:
- an object that can compute the function
-
-