Class FunctionFactory
- java.lang.Object
-
- org.apache.cassandra.cql3.functions.FunctionFactory
-
- Direct Known Subclasses:
MaskingFunction.Factory
public abstract class FunctionFactory extends java.lang.ObjectClass for dynamically building different overloads of a CQLFunctionaccording to specific function calls.For example, the factory for the
maxfunction will return a(text) -> textfunction if it's called with antextargument, like inmax('abc'). It however will return a(list<int>) -> list<int>function if it's called withmax([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
Fields Modifier and Type Field Description protected FunctionNamenameThe name of the built functions.protected java.util.List<FunctionParameter>parametersThe accepted parameters.
-
Constructor Summary
Constructors Constructor Description FunctionFactory(java.lang.String name, FunctionParameter... parameters)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract NativeFunctiondoGetOrCreateFunction(java.util.List<AbstractType<?>> argTypes, AbstractType<?> receiverType)Returns a function compatible with the specified signature.NativeFunctiongetOrCreateFunction(java.util.List<? extends AssignmentTestable> args, AbstractType<?> receiverType, java.lang.String receiverKeyspace, java.lang.String receiverTable)Returns a function with a signature compatible with the specified function call.InvalidRequestExceptioninvalidNumberOfArgumentsException()FunctionNamename()java.lang.StringtoString()
-
-
-
Field Detail
-
name
protected final FunctionName name
The name of the built functions.
-
parameters
protected final java.util.List<FunctionParameter> parameters
The accepted parameters.
-
-
Constructor Detail
-
FunctionFactory
public FunctionFactory(java.lang.String name, FunctionParameter... parameters)- Parameters:
name- the name of the built functionsparameters- the accepted parameters
-
-
Method Detail
-
name
public FunctionName name()
-
getOrCreateFunction
@Nullable public NativeFunction getOrCreateFunction(java.util.List<? extends AssignmentTestable> args, AbstractType<?> receiverType, java.lang.String receiverKeyspace, java.lang.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
public InvalidRequestException invalidNumberOfArgumentsException()
-
doGetOrCreateFunction
@Nullable protected abstract NativeFunction doGetOrCreateFunction(java.util.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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-