Record Class AggregateSignature

java.lang.Object
java.lang.Record
com.darkcollective.relix.function.AggregateSignature
Record Components:
name - the canonical spelling; matching is case-insensitive
parameters - the declared parameters, in order. Most aggregates take one value per row, but not all: a "row with the maximum" reduction takes the ranking expression and the one to yield from it
arity - how many arguments a call may pass
returnType - the declared result type. A Type rather than a ScalarType, because a reduction can produce a nested value: one that gathers a group's values yields an array of whatever it gathered. See AggregateFunction.returnTypeFor(List) for a result type that follows the argument types
properties - the optimizer contracts this aggregate honours
skipsNulls - whether a row is ignored when any of its argument values is NULL. True for the SQL reducers; false for one that gathers values into an array, where a NULL is part of the group's contents, and false for one whose NULL rule is its own — a "row with the maximum" reduction skips a NULL rank but yields whatever the winning row holds, NULL included
category - the grouping a function index lists it under
docKey - the key of this aggregate's documentation page, when it has one

public record AggregateSignature(String name, List<ParameterDefinition> parameters, Arity arity, Type returnType, Set<AggregateProperty> properties, boolean skipsNulls, String category, Optional<String> docKey) extends Record
The form of an aggregate — what the engine needs to plan a grouping before any row is read.

It is the scalar FunctionSignature with two additions that only a reduction has. skipsNulls() states the SQL rule once instead of at every site that has to honour it: an aggregate that skips NULLs counts values rather than rows, and yields NULL for a group with no non-NULL value. properties() carries what the optimizer may conclude — that a duplicate-removing step below this aggregate is redundant, say.

  • Field Details

    • AGGREGATE

      public static final String AGGREGATE
      The category an aggregate falls into when it declares none.
      See Also:
  • Constructor Details

    • AggregateSignature

      public AggregateSignature(String name, List<ParameterDefinition> parameters, Arity arity, Type returnType, Set<AggregateProperty> properties, boolean skipsNulls, String category, Optional<String> docKey)
      Creates an instance of a AggregateSignature record class.
      Parameters:
      name - the value for the name record component
      parameters - the value for the parameters record component
      arity - the value for the arity record component
      returnType - the value for the returnType record component
      properties - the value for the properties record component
      skipsNulls - the value for the skipsNulls record component
      category - the value for the category record component
      docKey - the value for the docKey record component
  • Method Details

    • of

      public static AggregateSignature of(String name, Type returnType, Set<AggregateProperty> properties, ParameterDefinition... parameters)
      A NULL-skipping aggregate whose arity is exactly its parameter list, filed under the default category with no documentation key.
      Parameters:
      name - the canonical spelling
      returnType - the declared result type
      properties - the optimizer contracts this aggregate 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.
      Returns:
      the lower-cased name
    • returnTypeFor

      public Type returnTypeFor(List<Type> argumentTypes)
      The declared result type, whatever the arguments are — see AggregateFunction.returnTypeFor(List) for the overridable rule.
      Parameters:
      argumentTypes - the argument types at a call site, in order
      Returns:
      returnType()
    • has

      public boolean has(AggregateProperty property)
      Parameters:
      property - the property to test
      Returns:
      true when this aggregate 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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 Type returnType()
      Returns the value of the returnType record component.
      Returns:
      the value of the returnType record component
    • properties

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

      public boolean skipsNulls()
      Returns the value of the skipsNulls record component.
      Returns:
      the value of the skipsNulls 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