Class UDFunction
java.lang.Object
org.apache.cassandra.cql3.functions.AbstractFunction
org.apache.cassandra.cql3.functions.UserFunction
org.apache.cassandra.cql3.functions.UDFunction
- All Implemented Interfaces:
AssignmentTestable,Function,ScalarFunction,SchemaElement
- Direct Known Subclasses:
JavaBasedUDFunction
Base class for User Defined Functions.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.cassandra.cql3.AssignmentTestable
AssignmentTestable.TestResultNested classes/interfaces inherited from interface org.apache.cassandra.cql3.SchemaElement
SchemaElement.SchemaElementType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<ColumnIdentifier>protected final List<UDFDataType>protected final Stringprotected final booleanprotected final Stringprotected static final org.slf4j.Loggerprotected final UDFDataTypeprotected final UDFContextFields inherited from class org.apache.cassandra.cql3.functions.AbstractFunction
argTypes, name, returnTypeFields inherited from interface org.apache.cassandra.cql3.functions.Function
UNRESOLVEDFields inherited from interface org.apache.cassandra.cql3.SchemaElement
NAME_COMPARATOR -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedUDFunction(FunctionName name, List<ColumnIdentifier> argNames, List<AbstractType<?>> argTypes, AbstractType<?> returnType, boolean calledOnNullInput, String language, String body) -
Method Summary
Modifier and TypeMethodDescriptionargNames()static voidassertUdfsEnabled(String language) body()static UDFunctioncreate(FunctionName name, List<ColumnIdentifier> argNames, List<AbstractType<?>> argTypes, AbstractType<?> returnType, boolean calledOnNullInput, String language, String body) static UDFunctioncreateBrokenFunction(FunctionName name, List<ColumnIdentifier> argNames, List<AbstractType<?>> argTypes, AbstractType<?> returnType, boolean calledOnNullInput, String language, String body, InvalidRequestException reason) It can happen that a function has been declared (is listed in the scheam) but cannot be loaded (maybe only on some nodes).protected ByteBufferdecompose(ProtocolVersion protocolVersion, Object value) Used by UDF implementations (both Java code generated byJavaBasedUDFunction) to convert the Java object representation for the return value to the C* serialized representation.Return the schema element typebooleanfinal ByteBufferApplies this function to the specified arguments.protected abstract ObjectexecuteAggregateUserDefined(Object firstParam, Arguments arguments) final ObjectexecuteForAggregate(Object state, Arguments arguments) protected abstract ByteBufferexecuteUserDefined(Arguments arguments) protected abstract ExecutorServiceexecutor()inthashCode()booleanChecks whether the function is an aggregate function or not.booleanisCallableWrtNullable(Arguments arguments) booleanbooleanisPure()Checks whether the function is a pure function (as in doesn't depend on, nor produces side effects) or not.language()newArguments(ProtocolVersion version) Creates some new input arguments for this function.booleanreferencesUserType(ByteBuffer name) toCqlString(boolean withInternals, boolean ifNotExists) Returns a CQL representation of this elementstatic UDFunctiontryCreate(FunctionName name, List<ColumnIdentifier> argNames, List<AbstractType<?>> argTypes, AbstractType<?> returnType, boolean calledOnNullInput, String language, String body) Methods inherited from class org.apache.cassandra.cql3.functions.UserFunction
isNativeMethods inherited from class org.apache.cassandra.cql3.functions.AbstractFunction
addFunctionsTo, argTypes, argumentsList, columnName, elementKeyspace, elementName, getCompatibleTypeIfKnown, name, returnType, testAssignment, toCqlString, toString, typesMatchMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.cassandra.cql3.AssignmentTestable
getCompatibleTypeIfKnown, testAssignmentMethods inherited from interface org.apache.cassandra.cql3.functions.Function
addFunctionsTo, argTypes, columnName, isNative, name, returnTypeMethods inherited from interface org.apache.cassandra.cql3.functions.ScalarFunction
isMonotonic, partialApplicationMethods inherited from interface org.apache.cassandra.cql3.SchemaElement
elementKeyspace, elementKeyspaceQuotedIfNeeded, elementName, elementNameQuotedIfNeeded
-
Field Details
-
logger
protected static final org.slf4j.Logger logger -
argNames
-
language
-
body
-
argumentTypes
-
resultType
-
calledOnNullInput
protected final boolean calledOnNullInput -
udfContext
-
-
Constructor Details
-
UDFunction
protected UDFunction(FunctionName name, List<ColumnIdentifier> argNames, List<AbstractType<?>> argTypes, AbstractType<?> returnType, boolean calledOnNullInput, String language, String body)
-
-
Method Details
-
newArguments
Description copied from interface:FunctionCreates some new input arguments for this function.- Specified by:
newArgumentsin interfaceFunction- Parameters:
version- the protocol version- Returns:
- some new input arguments for this function
-
tryCreate
public static UDFunction tryCreate(FunctionName name, List<ColumnIdentifier> argNames, List<AbstractType<?>> argTypes, AbstractType<?> returnType, boolean calledOnNullInput, String language, String body) -
create
public static UDFunction create(FunctionName name, List<ColumnIdentifier> argNames, List<AbstractType<?>> argTypes, AbstractType<?> returnType, boolean calledOnNullInput, String language, String body) -
createBrokenFunction
public static UDFunction createBrokenFunction(FunctionName name, List<ColumnIdentifier> argNames, List<AbstractType<?>> argTypes, AbstractType<?> returnType, boolean calledOnNullInput, String language, String body, InvalidRequestException reason) It can happen that a function has been declared (is listed in the scheam) but cannot be loaded (maybe only on some nodes). This is the case for instance if the class defining the class is not on the classpath for some of the node, or after a restart. In that case, we create a "fake" function so that: 1) the broken function can be dropped easily if that is what people want to do. 2) we return a meaningful error message if the function is executed (something more precise than saying that the function doesn't exist) -
elementType
Description copied from interface:SchemaElementReturn the schema element type- Specified by:
elementTypein interfaceSchemaElement- Returns:
- the schema element type
-
toCqlString
Description copied from interface:SchemaElementReturns a CQL representation of this element- Specified by:
toCqlStringin interfaceSchemaElement- Parameters:
withInternals- if the internals part of the CQL should be exposed.ifNotExists- if "IF NOT EXISTS" should be included.- Returns:
- a CQL representation of this element
-
isPure
public boolean isPure()Description copied from interface:FunctionChecks whether the function is a pure function (as in doesn't depend on, nor produces side effects) or not. -
execute
Description copied from interface:ScalarFunctionApplies this function to the specified arguments.- Specified by:
executein interfaceScalarFunction- Parameters:
arguments- the input arguments for the function- Returns:
- the result of applying this function to the arguments
-
executeForAggregate
-
assertUdfsEnabled
-
executor
-
isCallableWrtNullable
-
executeUserDefined
-
executeAggregateUserDefined
-
isAggregate
public boolean isAggregate()Description copied from interface:FunctionChecks whether the function is an aggregate function or not.- Specified by:
isAggregatein interfaceFunction- Returns:
trueif the function is an aggregate function,falseotherwise.
-
isCalledOnNullInput
public boolean isCalledOnNullInput()- Specified by:
isCalledOnNullInputin interfaceScalarFunction
-
argNames
-
body
-
language
-
decompose
Used by UDF implementations (both Java code generated byJavaBasedUDFunction) to convert the Java object representation for the return value to the C* serialized representation.- Parameters:
protocolVersion- the native protocol version used for serialization
-
referencesUserType
- Specified by:
referencesUserTypein interfaceFunction- Overrides:
referencesUserTypein classAbstractFunction
-
withUpdatedUserType
-
equals
- Overrides:
equalsin classAbstractFunction
-
compare
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractFunction
-