Class UDFunction

    • Field Detail

      • logger

        protected static final org.slf4j.Logger logger
      • language

        protected final java.lang.String language
      • body

        protected final java.lang.String body
      • argumentTypes

        protected final java.util.List<UDFDataType> argumentTypes
      • calledOnNullInput

        protected final boolean calledOnNullInput
      • udfContext

        protected final UDFContext udfContext
    • Constructor Detail

    • Method Detail

      • newArguments

        public Arguments newArguments​(ProtocolVersion version)
        Description copied from interface: Function
        Creates some new input arguments for this function.
        Specified by:
        newArguments in interface Function
        Parameters:
        version - the protocol version
        Returns:
        some new input arguments for this function
      • createBrokenFunction

        public static UDFunction createBrokenFunction​(FunctionName name,
                                                      java.util.List<ColumnIdentifier> argNames,
                                                      java.util.List<AbstractType<?>> argTypes,
                                                      AbstractType<?> returnType,
                                                      boolean calledOnNullInput,
                                                      java.lang.String language,
                                                      java.lang.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)
      • toCqlString

        public java.lang.String toCqlString​(boolean withInternals,
                                            boolean ifNotExists)
        Description copied from interface: SchemaElement
        Returns a CQL representation of this element
        Specified by:
        toCqlString in interface SchemaElement
        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: Function
        Checks whether the function is a pure function (as in doesn't depend on, nor produces side effects) or not.
        Specified by:
        isPure in interface Function
        Returns:
        true if the function is a pure function, false otherwise.
      • execute

        public final java.nio.ByteBuffer execute​(Arguments arguments)
        Description copied from interface: ScalarFunction
        Applies this function to the specified arguments.
        Specified by:
        execute in interface ScalarFunction
        Parameters:
        arguments - the input arguments for the function
        Returns:
        the result of applying this function to the arguments
      • executeForAggregate

        public final java.lang.Object executeForAggregate​(java.lang.Object state,
                                                          Arguments arguments)
      • assertUdfsEnabled

        public static void assertUdfsEnabled​(java.lang.String language)
      • executor

        protected abstract java.util.concurrent.ExecutorService executor()
      • isCallableWrtNullable

        public boolean isCallableWrtNullable​(Arguments arguments)
      • executeUserDefined

        protected abstract java.nio.ByteBuffer executeUserDefined​(Arguments arguments)
      • executeAggregateUserDefined

        protected abstract java.lang.Object executeAggregateUserDefined​(java.lang.Object firstParam,
                                                                        Arguments arguments)
      • isAggregate

        public boolean isAggregate()
        Description copied from interface: Function
        Checks whether the function is an aggregate function or not.
        Specified by:
        isAggregate in interface Function
        Returns:
        true if the function is an aggregate function, false otherwise.
      • body

        public java.lang.String body()
      • language

        public java.lang.String language()
      • decompose

        protected java.nio.ByteBuffer decompose​(ProtocolVersion protocolVersion,
                                                java.lang.Object value)
        Used by UDF implementations (both Java code generated by JavaBasedUDFunction) to convert the Java object representation for the return value to the C* serialized representation.
        Parameters:
        protocolVersion - the native protocol version used for serialization