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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns an expression where the children of this has been converted using the given converter.
    protected abstract void
     
    protected void
     
    final com.yahoo.document.datatypes.FieldValue
     
    final com.yahoo.document.datatypes.FieldValue
    execute(com.yahoo.document.datatypes.FieldValue val)
     
    final com.yahoo.document.Document
    execute(DocumentFieldValues adapter, com.yahoo.document.DocumentId docId)
     
    final com.yahoo.document.datatypes.FieldValue
     
    static com.yahoo.document.Document
    execute(Expression expression, com.yahoo.document.Document doc)
     
    static com.yahoo.document.DocumentUpdate
    execute(Expression expression, com.yahoo.document.DocumentUpdate update)
     
    static com.yahoo.document.DocumentUpdate
    execute(Expression expression, FieldValuesFactory factory, com.yahoo.document.DocumentUpdate update)
     
    final com.yahoo.document.datatypes.FieldValue
     
    com.yahoo.document.datatypes.FieldValue
    execute(FieldValues adapter, com.yahoo.document.DocumentId docId)
     
    final com.yahoo.document.Document
    execute(FieldValuesFactory factory, com.yahoo.document.Document doc)
     
    com.yahoo.document.Document
    execute(FieldValuesFactory factory, com.yahoo.document.Document doc, boolean isReindexing)
     
    final com.yahoo.document.DocumentUpdate
    execute(UpdateFieldValues adapter, com.yahoo.document.DocumentId docId)
     
    static Expression
    fromString(String expression)
    Creates an expression with simple lingustics for testing
    static Expression
    fromString(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.DataType
     
    com.yahoo.document.DataType
    Returns the already assigned (during verification) output type, or null if no type is assigned.
    com.yahoo.document.DataType
    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.
    boolean
    Returns whether this expression outputs a different value than what it gets as input.
    protected com.yahoo.document.DataType
    leastGeneralNonNullOf(com.yahoo.document.DataType left, com.yahoo.document.DataType right)
     
    protected com.yahoo.document.DataType
    leastGeneralOf(com.yahoo.document.DataType left, com.yahoo.document.DataType right)
     
    protected com.yahoo.document.DataType
    mostGeneralOf(com.yahoo.document.DataType left, com.yahoo.document.DataType right)
     
    static Expression
     
    com.yahoo.document.DataType
    Returns the already assigned (during verification) output type, or throws an exception if no type is assigned.
    boolean
    Returns whether this expression requires an input value.
    final void
    resolve(com.yahoo.document.Document document)
     
    final void
    resolve(com.yahoo.document.DocumentType type)
     
    final void
    resolve(com.yahoo.document.DocumentUpdate update)
     
    final void
     
    final void
    resolve(FieldTypes fieldTypes)
     
    final void
     
    final void
    resolve(FieldValuesFactory factory, com.yahoo.document.Document document)
     
    final void
    resolve(FieldValuesFactory factory, com.yahoo.document.DocumentUpdate update)
     
    final void
     
    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.
    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.
    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.
    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.
    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

    Methods inherited from class com.yahoo.vespa.objects.Selectable

    select, select, selectMembers

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public Expression convertChildren(ExpressionConverter converter)
      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

      public com.yahoo.document.DataType getInputType(TypeContext context)
    • 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 determined
      requiredType - the type the input type must be assignable to
      context - 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

      public com.yahoo.document.DataType getOutputType(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.
    • 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 known
      requiredOutput - 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 this
      context - 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

      public final void resolve(FieldValuesFactory factory, com.yahoo.document.Document document)
    • resolve

      public final void resolve(DocumentFieldValues fieldValues)
    • resolve

      public final void resolve(com.yahoo.document.DocumentUpdate update)
    • resolve

      public final void resolve(FieldValuesFactory factory, com.yahoo.document.DocumentUpdate update)
    • resolve

      public final void resolve(UpdateFieldValues fieldTypes)
    • resolve

      public final void resolve(FieldTypes fieldTypes)
    • resolve

      public final void resolve(TypeContext context)
    • doResolve

      protected void doResolve(TypeContext context)
    • 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

      public final com.yahoo.document.datatypes.FieldValue execute(FieldValues adapter)
    • execute

      public com.yahoo.document.datatypes.FieldValue execute(FieldValues adapter, com.yahoo.document.DocumentId docId)
    • execute

      public final com.yahoo.document.datatypes.FieldValue execute(ExecutionContext context)
    • doExecute

      protected abstract void doExecute(ExecutionContext context)
    • fromString

      public static Expression fromString(String expression) throws ParseException
      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,com.yahoo.language.process.Embedder> embedders, Map<String,com.yahoo.language.process.FieldGenerator> generators) throws ParseException
      Throws:
      ParseException
    • newInstance

      public static Expression newInstance(ScriptParserContext context) throws ParseException
      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)