Class Expression
java.lang.Object
com.yahoo.vespa.objects.Selectable
com.yahoo.vespa.indexinglanguage.expressions.Expression
- Direct Known Subclasses:
Base64DecodeExpression,Base64EncodeExpression,BinarizeExpression,BusyWaitExpression,ChunkExpression,ClearStateExpression,CompositeExpression,ConstantExpression,EchoExpression,EmbedExpression,ExactExpression,ExecutionValueExpression,FlattenExpression,GenerateExpression,GetFieldExpression,GetVarExpression,HashExpression,HexDecodeExpression,HexEncodeExpression,HostNameExpression,InputExpression,JoinExpression,LiteralBoolExpression,LowerCaseExpression,NGramExpression,NormalizeExpression,NowExpression,OptimizePredicateExpression,OutputExpression,PackBitsExpression,RandomExpression,SetLanguageExpression,SetVarExpression,SleepExpression,SplitExpression,SubstringExpression,ThisExpression,ToArrayExpression,ToBoolExpression,ToByteExpression,ToDoubleExpression,ToEpochSecondExpression,ToFloatExpression,ToIntegerExpression,TokenizeExpression,ToLongExpression,ToPositionExpression,ToStringExpression,ToUriExpression,ToWsetExpression,TrimExpression,ZCurveExpression
public abstract class Expression
extends com.yahoo.vespa.objects.Selectable
Superclass of expressions.
Rules:
- All expressions produce an output.
- Expressions that does not require an input overrides requiresInput() to return false
- Author:
- Simon Thoresen Hult, bratseth
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertChildren(ExpressionConverter converter) Returns an expression where the children of this has been converted using the given converter.protected abstract voiddoExecute(ExecutionContext context) protected voiddoResolve(TypeContext context) final com.yahoo.document.datatypes.FieldValueexecute()final com.yahoo.document.datatypes.FieldValueexecute(com.yahoo.document.datatypes.FieldValue val) final com.yahoo.document.Documentexecute(DocumentFieldValues adapter, com.yahoo.document.DocumentId docId) final com.yahoo.document.datatypes.FieldValueexecute(ExecutionContext context) static com.yahoo.document.Documentexecute(Expression expression, com.yahoo.document.Document doc) static com.yahoo.document.DocumentUpdateexecute(Expression expression, com.yahoo.document.DocumentUpdate update) static com.yahoo.document.DocumentUpdateexecute(Expression expression, FieldValuesFactory factory, com.yahoo.document.DocumentUpdate update) final com.yahoo.document.datatypes.FieldValueexecute(FieldValues adapter) com.yahoo.document.datatypes.FieldValueexecute(FieldValues adapter, com.yahoo.document.DocumentId docId) final com.yahoo.document.Documentexecute(FieldValuesFactory factory, com.yahoo.document.Document doc) com.yahoo.document.Documentexecute(FieldValuesFactory factory, com.yahoo.document.Document doc, boolean isReindexing) final com.yahoo.document.DocumentUpdateexecute(UpdateFieldValues adapter, com.yahoo.document.DocumentId docId) static ExpressionfromString(String expression) Creates an expression with simple lingustics for testingstatic ExpressionfromString(String expression, com.yahoo.language.Linguistics linguistics, Map<String, com.yahoo.language.process.Chunker> chunkers, Map<String, com.yahoo.language.process.Embedder> embedders, Map<String, com.yahoo.language.process.FieldGenerator> generators) com.yahoo.document.DataTypegetInputType(TypeContext context) com.yahoo.document.DataTypeReturns the already assigned (during verification) output type, or null if no type is assigned.com.yahoo.document.DataTypegetOutputType(TypeContext context) Returns the output type this is must produce (since it is part of a statement expression), or null if this is not set or there is no output produced at the end of the statement.booleanReturns whether this expression outputs a different value than what it gets as input.protected com.yahoo.document.DataTypeleastGeneralNonNullOf(com.yahoo.document.DataType left, com.yahoo.document.DataType right) protected com.yahoo.document.DataTypeleastGeneralOf(com.yahoo.document.DataType left, com.yahoo.document.DataType right) protected com.yahoo.document.DataTypemostGeneralOf(com.yahoo.document.DataType left, com.yahoo.document.DataType right) static ExpressionnewInstance(ScriptParserContext context) com.yahoo.document.DataTypeReturns the already assigned (during verification) output type, or throws an exception if no type is assigned.booleanReturns whether this expression requires an input value.final voidresolve(com.yahoo.document.Document document) final voidresolve(com.yahoo.document.DocumentType type) final voidresolve(com.yahoo.document.DocumentUpdate update) final voidresolve(DocumentFieldValues fieldValues) final voidresolve(FieldTypes fieldTypes) final voidresolve(TypeContext context) final voidresolve(FieldValuesFactory factory, com.yahoo.document.Document document) final voidresolve(FieldValuesFactory factory, com.yahoo.document.DocumentUpdate update) final voidresolve(UpdateFieldValues fieldTypes) protected final com.yahoo.document.DataTypesetInputType(com.yahoo.document.DataType inputType, com.yahoo.document.DataType requiredType, TypeContext context) Sets the input type of this and returns the resulting output type, or null if it cannot be uniquely determined.com.yahoo.document.DataTypesetInputType(com.yahoo.document.DataType inputType, TypeContext context) Sets the input type of this and returns the resulting output type, or null if it cannot be uniquely determined.protected final com.yahoo.document.DataTypesetOutputType(com.yahoo.document.DataType actualOutput, com.yahoo.document.DataType requiredOutput, com.yahoo.document.DataType requiredType, TypeContext context) Sets the output type of this and returns the resulting input type, or null if it cannot be uniquely determined, with additional arguments for convenience type checking.com.yahoo.document.DataTypesetOutputType(com.yahoo.document.DataType outputType, TypeContext context) Sets the output type of this and returns the resulting input type, or null if it cannot be uniquely determined.voidsetStatementOutput(com.yahoo.document.DocumentType documentType, com.yahoo.document.Field field) Sets the document type and field the statement this expression is part of will write toMethods inherited from class com.yahoo.vespa.objects.Selectable
select, select, selectMembers
-
Constructor Details
-
Expression
public Expression()
-
-
Method Details
-
requiresInput
public boolean requiresInput()Returns whether this expression requires an input value. -
isMutating
public boolean isMutating()Returns whether this expression outputs a different value than what it gets as input. Annotating a string value does not count as modifying it. -
convertChildren
Returns an expression where the children of this has been converted using the given converter. This default implementation returns this as it has no children. -
setStatementOutput
public void setStatementOutput(com.yahoo.document.DocumentType documentType, com.yahoo.document.Field field) Sets the document type and field the statement this expression is part of will write to -
getInputType
-
setInputType
protected final com.yahoo.document.DataType setInputType(com.yahoo.document.DataType inputType, com.yahoo.document.DataType requiredType, TypeContext context) Sets the input type of this and returns the resulting output type, or null if it cannot be uniquely determined. This default implementation returns the same type, which is appropriate for all statements that do not change the type.- Parameters:
inputType- the type to set as the input type of this, or null if it cannot be determinedrequiredType- the type the input type must be assignable tocontext- the context of this- Returns:
- input the input type of this expression resolved from this call and current state
- Throws:
IllegalArgumentException- if inputType isn't assignable to requiredType
-
setInputType
public com.yahoo.document.DataType setInputType(com.yahoo.document.DataType inputType, TypeContext context) Sets the input type of this and returns the resulting output type, or null if it cannot be uniquely determined. Subtypes may implement this by calling setInputType(inputType, requiredType, VerificationContext context). -
getOutputType
Returns the output type this is must produce (since it is part of a statement expression), or null if this is not set or there is no output produced at the end of the statement. -
getOutputType
public com.yahoo.document.DataType getOutputType()Returns the already assigned (during verification) output type, or null if no type is assigned. -
requireOutputType
public com.yahoo.document.DataType requireOutputType()Returns the already assigned (during verification) output type, or throws an exception if no type is assigned. -
setOutputType
protected final com.yahoo.document.DataType setOutputType(com.yahoo.document.DataType actualOutput, com.yahoo.document.DataType requiredOutput, com.yahoo.document.DataType requiredType, TypeContext context) Sets the output type of this and returns the resulting input type, or null if it cannot be uniquely determined, with additional arguments for convenience type checking. This implementation returns the same type, which is appropriate for all statements that do not change the type.- Parameters:
actualOutput- the type actually produced by this, must be assignable to the requiredOutput, or null if not knownrequiredOutput- the type required by the next expression, which actualOutput must be assignable to, or null if it cannot be uniquely determined.requiredType- a type the required output must be assignable to, or null to not verify thiscontext- the context of this- Returns:
- the actualOutput if set, requiredOutput otherwise
- Throws:
IllegalArgumentException- if actualOutput
-
setOutputType
public com.yahoo.document.DataType setOutputType(com.yahoo.document.DataType outputType, TypeContext context) Sets the output type of this and returns the resulting input type, or null if it cannot be uniquely determined. Subtypes implement this by calling setOutputType(outputType, requiredType, VerificationContext context). -
resolve
public final void resolve(com.yahoo.document.DocumentType type) -
resolve
public final void resolve(com.yahoo.document.Document document) -
resolve
-
resolve
-
resolve
public final void resolve(com.yahoo.document.DocumentUpdate update) -
resolve
-
resolve
-
resolve
-
resolve
-
doResolve
-
execute
public final com.yahoo.document.datatypes.FieldValue execute(com.yahoo.document.datatypes.FieldValue val) -
execute
public final com.yahoo.document.Document execute(FieldValuesFactory factory, com.yahoo.document.Document doc) -
execute
public com.yahoo.document.Document execute(FieldValuesFactory factory, com.yahoo.document.Document doc, boolean isReindexing) -
execute
public final com.yahoo.document.Document execute(DocumentFieldValues adapter, com.yahoo.document.DocumentId docId) -
execute
public static com.yahoo.document.DocumentUpdate execute(Expression expression, FieldValuesFactory factory, com.yahoo.document.DocumentUpdate update) -
execute
public final com.yahoo.document.DocumentUpdate execute(UpdateFieldValues adapter, com.yahoo.document.DocumentId docId) -
execute
-
execute
public com.yahoo.document.datatypes.FieldValue execute(FieldValues adapter, com.yahoo.document.DocumentId docId) -
execute
-
doExecute
-
fromString
Creates an expression with simple lingustics for testing- Throws:
ParseException
-
fromString
public static Expression fromString(String expression, com.yahoo.language.Linguistics linguistics, Map<String, com.yahoo.language.process.Chunker> chunkers, Map<String, throws ParseExceptioncom.yahoo.language.process.Embedder> embedders, Map<String, com.yahoo.language.process.FieldGenerator> generators) - Throws:
ParseException
-
newInstance
- Throws:
ParseException
-
execute
public static com.yahoo.document.Document execute(Expression expression, com.yahoo.document.Document doc) -
execute
public static com.yahoo.document.DocumentUpdate execute(Expression expression, com.yahoo.document.DocumentUpdate update) -
execute
public final com.yahoo.document.datatypes.FieldValue execute() -
mostGeneralOf
protected com.yahoo.document.DataType mostGeneralOf(com.yahoo.document.DataType left, com.yahoo.document.DataType right) -
leastGeneralOf
protected com.yahoo.document.DataType leastGeneralOf(com.yahoo.document.DataType left, com.yahoo.document.DataType right) -
leastGeneralNonNullOf
protected com.yahoo.document.DataType leastGeneralNonNullOf(com.yahoo.document.DataType left, com.yahoo.document.DataType right)
-