Class ExpressionFunction


  • public class ExpressionFunction
    extends java.lang.Object
    A function defined by a ranking expression, optionally containing type information for inputs and outputs. Immutable, but note that ranking expressions are *not* immutable.
    Author:
    Simon Thoresen Hult, bratseth
    • Constructor Detail

      • ExpressionFunction

        public ExpressionFunction​(java.lang.String name,
                                  RankingExpression body)
        Constructs a new function with no arguments
        Parameters:
        name - the name of this function
        body - the ranking expression that defines this function
      • ExpressionFunction

        public ExpressionFunction​(java.lang.String name,
                                  java.util.List<java.lang.String> arguments,
                                  RankingExpression body)
        Constructs a new function
        Parameters:
        name - the name of this function
        arguments - its argument names
        body - the ranking expression that defines this function
      • ExpressionFunction

        public ExpressionFunction​(java.lang.String name,
                                  java.util.List<java.lang.String> arguments,
                                  RankingExpression body,
                                  java.util.Map<java.lang.String,​com.yahoo.tensor.TensorType> argumentTypes,
                                  java.util.Optional<com.yahoo.tensor.TensorType> returnType)
    • Method Detail

      • getName

        public java.lang.String getName()
      • arguments

        public java.util.List<java.lang.String> arguments()
        Returns an immutable list of the arguments of this
      • argumentTypes

        public java.util.Map<java.lang.String,​com.yahoo.tensor.TensorType> argumentTypes()
        Returns the types of the arguments of this, if specified. The keys of this may be any subset of the arguments
      • returnType

        public java.util.Optional<com.yahoo.tensor.TensorType> returnType()
        Returns the return type of this, or empty if not specified
      • withReturnType

        public ExpressionFunction withReturnType​(com.yahoo.tensor.TensorType returnType)
      • withArgument

        public ExpressionFunction withArgument​(java.lang.String argument)
        Returns a copy of this with the given argument added (if not already present)
      • withArgument

        public ExpressionFunction withArgument​(java.lang.String argument,
                                               com.yahoo.tensor.TensorType type)
        Returns a copy of this with the given argument (if not present) and argument type added
      • expand

        public ExpressionFunction.Instance expand​(SerializationContext context,
                                                  java.util.List<ExpressionNode> argumentValues,
                                                  java.util.Deque<java.lang.String> path)
        Creates and returns an instance of this function based on the given arguments. If function calls are nested, this call may produce additional functions.
        Parameters:
        context - the context used to expand this
        argumentValues - the arguments to instantiate on.
        path - the expansion path leading to this.
        Returns:
        the script function instance created.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object