Class SerializationContext

java.lang.Object
com.yahoo.searchlib.rankingexpression.rule.FunctionReferenceContext
com.yahoo.searchlib.rankingexpression.rule.SerializationContext

public class SerializationContext extends FunctionReferenceContext
Context needed to serialize an expression to a string. This has the lifetime of a single serialization
Author:
bratseth
  • Constructor Details

    • SerializationContext

      public SerializationContext()
      Create a context for a single serialization task
    • SerializationContext

      public SerializationContext(Collection<ExpressionFunction> functions, Optional<com.yahoo.tensor.evaluation.TypeContext<Reference>> typeContext)
      Create a context for a single serialization task
      Parameters:
      functions - the functions of this
      typeContext - the type context of this: Serialization may depend on type resolution
    • SerializationContext

      public SerializationContext(Collection<ExpressionFunction> functions, Map<String,String> bindings, com.yahoo.tensor.evaluation.TypeContext<Reference> typeContext)
      Create a context for a single serialization task
      Parameters:
      functions - the functions of this
      bindings - the arguments of this
      typeContext - the type context of this: Serialization may depend on type resolution
    • SerializationContext

      public SerializationContext(Map<String,ExpressionFunction> functions, Map<String,String> bindings, Optional<com.yahoo.tensor.evaluation.TypeContext<Reference>> typeContext, Map<String,String> serializedFunctions)
  • Method Details

    • typeContext

      public Optional<com.yahoo.tensor.evaluation.TypeContext<Reference>> typeContext()
      Returns the type context of this, if it is able to resolve types.
    • addFunctionSerialization

      public void addFunctionSerialization(String name, String expressionString)
      Adds the serialization of a function
    • addArgumentTypeSerialization

      public void addArgumentTypeSerialization(String functionName, String argumentName, com.yahoo.tensor.TensorType type)
      Adds the serialization of the argument type to a function
    • addFunctionTypeSerialization

      public void addFunctionTypeSerialization(String functionName, com.yahoo.tensor.TensorType type)
      Adds the serialization of the return type of a function
    • withBindings

      public SerializationContext withBindings(Map<String,String> bindings)
      Description copied from class: FunctionReferenceContext
      Returns a new context with the bindings replaced by the given bindings
      Overrides:
      withBindings in class FunctionReferenceContext
    • withoutBindings

      public SerializationContext withoutBindings()
      Returns a fresh context without bindings
      Overrides:
      withoutBindings in class FunctionReferenceContext
    • serializedFunctions

      public Map<String,String> serializedFunctions()
    • needSerialization

      public boolean needSerialization(String functionName)