Record Class FunctionSignature

java.lang.Object
java.lang.Record
com.darkcollective.relix.function.FunctionSignature
Record Components:
name - the canonical spelling, as it should appear in documentation and diagnostics; matching is case-insensitive, so this is the display form rather than a key
parameters - the declared parameters, in order. A function whose arity range is wider than this list — a variadic Coalesce, an optional trailing argument — declares the parameters it can name, and the range in arity governs what a call may pass
arity - how many arguments a call may pass
returnType - the declared result type; see ScalarFunction.returnTypeFor(List) for a result type that depends on the argument types
properties - the optimizer contracts this function honours
category - the grouping a function index lists it under — "string", "math", "datetime"
docKey - the key of this function's documentation page, when it has one

public record FunctionSignature(String name, List<ParameterDefinition> parameters, Arity arity, ScalarType returnType, Set<FunctionProperty> properties, String category, Optional<String> docKey) extends Record
The form of a scalar function — everything the engine reasons about before anything is evaluated.

Analysis, validation, optimisation and pushdown planning all run against this record and never against the implementation behind it. Sin and Cos are the same form; what separates them is the lambda, and the lambda is of no interest to a phase that is checking argument counts or deciding whether a call can be folded.

The property set is a contract with the optimizer, not a description: FunctionProperty.PURE permits hoisting and common-subexpression elimination, and declaring it of a function that reads the clock or an RNG produces wrong answers rather than slow ones. Declare conservatively.

  • Field Details

    • UNCATEGORISED

      public static final String UNCATEGORISED
      The category a function falls into when it declares none.
      See Also:
  • Constructor Details

  • Method Details

    • of

      public static FunctionSignature of(String name, ScalarType returnType, String category, Set<FunctionProperty> properties, ParameterDefinition... parameters)
      A signature whose arity is exactly its parameter list, with no documentation key.
      Parameters:
      name - the canonical spelling
      returnType - the declared result type
      category - the grouping a function index lists it under
      properties - the optimizer contracts this function honours
      parameters - the declared parameters, in order
      Returns:
      the signature
    • canonicalName

      public String canonicalName()
      The key this signature is indexed and looked up under: the name, lower-cased. Names are matched case-insensitively, so UCase, ucase and UCASE are one function.
      Returns:
      the lower-cased name
    • returnTypeFor

      public ScalarType returnTypeFor(List<ScalarType> argumentTypes)
      The declared result type, whatever the arguments are.

      This is the answer for every function whose result type is fixed, which is nearly all of them. A function whose result follows its arguments — a conditional returning whichever branch it selects — states that rule by overriding ScalarFunction.returnTypeFor(List), which delegates here unless it is overridden.

      Parameters:
      argumentTypes - the argument types at a call site, in order
      Returns:
      returnType()
    • has

      public boolean has(FunctionProperty property)
      Parameters:
      property - the property to test
      Returns:
      true when this function declares property
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • parameters

      public List<ParameterDefinition> parameters()
      Returns the value of the parameters record component.
      Returns:
      the value of the parameters record component
    • arity

      public Arity arity()
      Returns the value of the arity record component.
      Returns:
      the value of the arity record component
    • returnType

      public ScalarType returnType()
      Returns the value of the returnType record component.
      Returns:
      the value of the returnType record component
    • properties

      public Set<FunctionProperty> properties()
      Returns the value of the properties record component.
      Returns:
      the value of the properties record component
    • category

      public String category()
      Returns the value of the category record component.
      Returns:
      the value of the category record component
    • docKey

      public Optional<String> docKey()
      Returns the value of the docKey record component.
      Returns:
      the value of the docKey record component