Class FunctionFactory
java.lang.Object
org.apache.cassandra.cql3.functions.FunctionFactory
- Direct Known Subclasses:
MaskingFunction.Factory
Class for dynamically building different overloads of a CQL
Function according to specific function calls.
For example, the factory for the max function will return a (text) -> text function if it's called
with an text argument, like in max('abc'). It however will return a (list<int>) -> list<int>
function if it's called with max([1,2,3]), etc.
This is meant to be used to create functions that require too many overloads to have them pre-created in memory. Note that in the case of functions accepting collections, tuples or UDTs the number of overloads is potentially infinite.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final FunctionNameThe name of the built functions.protected final List<FunctionParameter>The accepted parameters. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract NativeFunctiondoGetOrCreateFunction(List<AbstractType<?>> argTypes, AbstractType<?> receiverType) Returns a function compatible with the specified signature.getOrCreateFunction(List<? extends AssignmentTestable> args, AbstractType<?> receiverType, String receiverKeyspace, String receiverTable) Returns a function with a signature compatible with the specified function call.name()toString()
-
Field Details
-
name
The name of the built functions. -
parameters
The accepted parameters.
-
-
Constructor Details
-
FunctionFactory
- Parameters:
name- the name of the built functionsparameters- the accepted parameters
-
-
Method Details
-
name
-
getOrCreateFunction
@Nullable public NativeFunction getOrCreateFunction(List<? extends AssignmentTestable> args, AbstractType<?> receiverType, String receiverKeyspace, String receiverTable) Returns a function with a signature compatible with the specified function call.- Parameters:
args- the arguments in the function call for which the function is going to be builtreceiverType- the expected return type of the function call for which the function is going to be builtreceiverKeyspace- the name of the recevier keyspacereceiverTable- the name of the recevier table- Returns:
- a function with a signature compatible with the specified function call, or
nullif the factory cannot create a function for the supplied arguments but there might be another factory with the samename()able to do it.
-
invalidNumberOfArgumentsException
-
doGetOrCreateFunction
@Nullable protected abstract NativeFunction doGetOrCreateFunction(List<AbstractType<?>> argTypes, AbstractType<?> receiverType) Returns a function compatible with the specified signature.- Parameters:
argTypes- the types of the function argumentsreceiverType- the expected return type of the function- Returns:
- a function compatible with the specified signature, or
nullif this cannot create a function for the supplied arguments but there might be another factory with the samename()able to do it.
-
toString
-