Class ExpressionFunction
java.lang.Object
com.yahoo.searchlib.rankingexpression.ExpressionFunction
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassAn instance of a serialization of this function, using a particular serialization context (byexpand(com.yahoo.searchlib.rankingexpression.rule.SerializationContext, java.util.List<com.yahoo.searchlib.rankingexpression.rule.ExpressionNode>, java.util.Deque<java.lang.String>)) -
Constructor Summary
ConstructorsConstructorDescriptionExpressionFunction(String name, RankingExpression body) Constructs a new function with no argumentsExpressionFunction(String name, List<String> arguments, RankingExpression body) Constructs a new functionExpressionFunction(String name, List<String> arguments, RankingExpression body, Map<String, com.yahoo.tensor.TensorType> argumentTypes, Optional<com.yahoo.tensor.TensorType> returnType) -
Method Summary
Modifier and TypeMethodDescriptionReturns an immutable list of the arguments of thisReturns the types of the arguments of this, if specified.expand(SerializationContext context, List<ExpressionNode> argumentValues, Deque<String> path) Creates and returns an instance of this function based on the given arguments.com.yahoo.tensor.TensorTypegetArgumentType(String argumentName) getBody()getName()Optional<com.yahoo.tensor.TensorType>Returns the return type of this, or empty if not specifiedtoString()withArgument(String argument) Returns a copy of this with the given argument added (if not already present)withArgument(String argument, com.yahoo.tensor.TensorType type) Returns a copy of this with the given argument (if not present) and argument type addedwithBody(RankingExpression body) Returns a copy of this with the body changed to the given valuewithReturnType(com.yahoo.tensor.TensorType returnType)
-
Constructor Details
-
ExpressionFunction
Constructs a new function with no arguments- Parameters:
name- the name of this functionbody- the ranking expression that defines this function
-
ExpressionFunction
Constructs a new function- Parameters:
name- the name of this functionarguments- its argument namesbody- the ranking expression that defines this function
-
ExpressionFunction
-
-
Method Details
-
getName
-
arguments
Returns an immutable list of the arguments of this -
getBody
-
argumentTypes
Returns the types of the arguments of this, if specified. The keys of this may be any subset of the arguments -
getArgumentType
-
returnType
Returns the return type of this, or empty if not specified -
withName
-
withBody
Returns a copy of this with the body changed to the given value -
withReturnType
-
withArgument
Returns a copy of this with the given argument added (if not already present) -
withArgument
Returns a copy of this with the given argument (if not present) and argument type added -
expand
public ExpressionFunction.Instance expand(SerializationContext context, List<ExpressionNode> argumentValues, Deque<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 thisargumentValues- the arguments to instantiate on.path- the expansion path leading to this.- Returns:
- the script function instance created.
-
toString
-