Class HigherOrderBagFunction<RETURN_T extends Value,​SUB_RETURN_T extends AttributeValue>

  • Type Parameters:
    RETURN_T - return type
    SUB_RETURN_T - sub-function's return (primitive) type. Only functions returning primitive type of result are compatible with higher-order functions here.
    All Implemented Interfaces:
    Function<RETURN_T>, PdpExtension, PrimitiveValue, Value

    public abstract class HigherOrderBagFunction<RETURN_T extends Value,​SUB_RETURN_T extends AttributeValue>
    extends BaseFunction<RETURN_T>
    Higher-order bag function
    Version:
    $Id: $
    • Constructor Detail

      • HigherOrderBagFunction

        protected HigherOrderBagFunction​(String functionId,
                                         Datatype<RETURN_T> returnType,
                                         Datatype<?> subFunctionReturnType)
        Instantiates higher-order bag function
        Parameters:
        functionId - function ID
        returnType - function's return type
        subFunctionReturnType - sub-function's return datatype; may be null to indicate any datatype (e.g. map function's sub-function return datatype can be any primitive type)
    • Method Detail

      • getReturnType

        public Datatype<RETURN_T> getReturnType()
        Gets the return type of the function Returns the type of attribute value that will be returned by this function.
        Returns:
        function return type
      • createFunctionCallFromSubFunction

        protected abstract FunctionCall<RETURN_T> createFunctionCallFromSubFunction​(FirstOrderFunction<SUB_RETURN_T> subFunc,
                                                                                    List<Expression<?>> inputsAfterSubFunc)
        Creates function call from sub-function definition and all inputs to higher-order function. To be overridden by OneBagOnlyFunctions (any-of/all-of)
        Parameters:
        subFunc - first-order sub-function
        inputsAfterSubFunc - sub-function arguments
        Returns:
        function call
      • newCall

        public final FunctionCall<RETURN_T> newCall​(List<Expression<?>> inputs)
                                             throws IllegalArgumentException
        Creates new function call with given arguments (Expressions). Any implementation of this method should first validate inputs according to the function signature/definition.
        Parameters:
        inputs - function arguments (expressions)
        Returns:
        Function call handle for calling this function which such inputs (with possible changes from original inputs due to optimizations for instance)
        Throws:
        IllegalArgumentException - if inputs are invalid for this function
      • checkNumberOfArgs

        protected abstract void checkNumberOfArgs​(int numInputs)

        checkNumberOfArgs

        Parameters:
        numInputs - a int.