Class AbstractFunction

java.lang.Object
org.apache.cassandra.cql3.functions.AbstractFunction
All Implemented Interfaces:
AssignmentTestable, Function
Direct Known Subclasses:
NativeFunction, UserFunction

public abstract class AbstractFunction extends Object implements Function
Base class for our native/hardcoded functions.
  • Field Details

  • Constructor Details

  • Method Details

    • name

      public FunctionName name()
      Specified by:
      name in interface Function
    • argTypes

      public List<AbstractType<?>> argTypes()
      Specified by:
      argTypes in interface Function
    • returnType

      public AbstractType<?> returnType()
      Specified by:
      returnType in interface Function
    • argumentsList

      public List<String> argumentsList()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • addFunctionsTo

      public void addFunctionsTo(List<Function> functions)
      Specified by:
      addFunctionsTo in interface Function
    • referencesUserType

      public boolean referencesUserType(ByteBuffer name)
      Specified by:
      referencesUserType in interface Function
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • testAssignment

      public final AssignmentTestable.TestResult testAssignment(String keyspace, ColumnSpecification receiver)
      Specified by:
      testAssignment in interface AssignmentTestable
      Returns:
      whether this object can be assigned to the provided receiver. We distinguish between 3 values: - EXACT_MATCH if this object is exactly of the type expected by the receiver - WEAKLY_ASSIGNABLE if this object is not exactly the expected type but is assignable nonetheless - NOT_ASSIGNABLE if it's not assignable Most caller should just call the isAssignable() method on the result, though functions have a use for testing "strong" equality to decide the most precise overload to pick when multiple could match.
    • getCompatibleTypeIfKnown

      public AbstractType<?> getCompatibleTypeIfKnown(String keyspace)
      Specified by:
      getCompatibleTypeIfKnown in interface AssignmentTestable
      Returns:
      A data type that can represent this, or null if we can't determine that type. The returned type won't necessarely be the exact type, but one that is compatible with it.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • elementKeyspace

      public String elementKeyspace()
    • elementName

      public String elementName()
    • toCqlString

      protected String toCqlString(AbstractType<?> type)
      Converts the specified type into its CQL representation.

      For user function and aggregates tuples need to be handle in a special way as they are frozen by nature but the frozen keyword should not appear in their CQL definition.

      Parameters:
      type - the type
      Returns:
      the CQL representation of the specified type
    • columnName

      public String columnName(List<String> columnNames)
      Description copied from interface: Function
      Returns the name of the function to use within a ResultSet.
      Specified by:
      columnName in interface Function
      Parameters:
      columnNames - the names of the columns used to call the function
      Returns:
      the name of the function to use within a ResultSet
    • typesMatch

      public boolean typesMatch(List<AbstractType<?>> types)