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 java.lang.Object implements Function
Base class for our native/hardcoded functions.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.cassandra.cql3.AssignmentTestable
AssignmentTestable.TestResult
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<AbstractType<?>>argTypesprotected FunctionNamenameprotected AbstractType<?>returnType-
Fields inherited from interface org.apache.cassandra.cql3.functions.Function
UNRESOLVED
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractFunction(FunctionName name, java.util.List<AbstractType<?>> argTypes, AbstractType<?> returnType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFunctionsTo(java.util.List<Function> functions)java.util.List<AbstractType<?>>argTypes()java.util.List<java.lang.String>argumentsList()java.lang.StringcolumnName(java.util.List<java.lang.String> columnNames)Returns the name of the function to use within a ResultSet.java.lang.StringelementKeyspace()java.lang.StringelementName()booleanequals(java.lang.Object o)AbstractType<?>getCompatibleTypeIfKnown(java.lang.String keyspace)inthashCode()FunctionNamename()booleanreferencesUserType(java.nio.ByteBuffer name)AbstractType<?>returnType()AssignmentTestable.TestResulttestAssignment(java.lang.String keyspace, ColumnSpecification receiver)protected java.lang.StringtoCqlString(AbstractType<?> type)Converts the specified type into its CQL representation.java.lang.StringtoString()booleantypesMatch(java.util.List<AbstractType<?>> types)-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.cassandra.cql3.functions.Function
compare, isAggregate, isNative, isPure, newArguments
-
-
-
-
Field Detail
-
name
protected final FunctionName name
-
argTypes
protected final java.util.List<AbstractType<?>> argTypes
-
returnType
protected final AbstractType<?> returnType
-
-
Constructor Detail
-
AbstractFunction
protected AbstractFunction(FunctionName name, java.util.List<AbstractType<?>> argTypes, AbstractType<?> returnType)
-
-
Method Detail
-
name
public FunctionName name()
-
argTypes
public java.util.List<AbstractType<?>> argTypes()
-
returnType
public AbstractType<?> returnType()
- Specified by:
returnTypein interfaceFunction
-
argumentsList
public java.util.List<java.lang.String> argumentsList()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
addFunctionsTo
public void addFunctionsTo(java.util.List<Function> functions)
- Specified by:
addFunctionsToin interfaceFunction
-
referencesUserType
public boolean referencesUserType(java.nio.ByteBuffer name)
- Specified by:
referencesUserTypein interfaceFunction
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
testAssignment
public final AssignmentTestable.TestResult testAssignment(java.lang.String keyspace, ColumnSpecification receiver)
- Specified by:
testAssignmentin interfaceAssignmentTestable- 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(java.lang.String keyspace)
- Specified by:
getCompatibleTypeIfKnownin interfaceAssignmentTestable- Returns:
- A data type that can represent this, or
nullif 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 java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
elementKeyspace
public java.lang.String elementKeyspace()
-
elementName
public java.lang.String elementName()
-
toCqlString
protected java.lang.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 java.lang.String columnName(java.util.List<java.lang.String> columnNames)
Description copied from interface:FunctionReturns the name of the function to use within a ResultSet.- Specified by:
columnNamein interfaceFunction- 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(java.util.List<AbstractType<?>> types)
-
-