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<?>>
argTypes
protected FunctionName
name
protected AbstractType<?>
returnType
-
Fields inherited from interface org.apache.cassandra.cql3.functions.Function
UNRESOLVED
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractFunction(FunctionName name, java.util.List<AbstractType<?>> argTypes, AbstractType<?> returnType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFunctionsTo(java.util.List<Function> functions)
java.util.List<AbstractType<?>>
argTypes()
java.util.List<java.lang.String>
argumentsList()
java.lang.String
columnName(java.util.List<java.lang.String> columnNames)
Returns the name of the function to use within a ResultSet.java.lang.String
elementKeyspace()
java.lang.String
elementName()
boolean
equals(java.lang.Object o)
AbstractType<?>
getCompatibleTypeIfKnown(java.lang.String keyspace)
int
hashCode()
FunctionName
name()
boolean
referencesUserType(java.nio.ByteBuffer name)
AbstractType<?>
returnType()
AssignmentTestable.TestResult
testAssignment(java.lang.String keyspace, ColumnSpecification receiver)
protected java.lang.String
toCqlString(AbstractType<?> type)
Converts the specified type into its CQL representation.java.lang.String
toString()
boolean
typesMatch(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:
returnType
in interfaceFunction
-
argumentsList
public java.util.List<java.lang.String> argumentsList()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
addFunctionsTo
public void addFunctionsTo(java.util.List<Function> functions)
- Specified by:
addFunctionsTo
in interfaceFunction
-
referencesUserType
public boolean referencesUserType(java.nio.ByteBuffer name)
- Specified by:
referencesUserType
in interfaceFunction
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
testAssignment
public final AssignmentTestable.TestResult testAssignment(java.lang.String keyspace, ColumnSpecification receiver)
- Specified by:
testAssignment
in 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:
getCompatibleTypeIfKnown
in interfaceAssignmentTestable
- 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 java.lang.String toString()
- Overrides:
toString
in 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:Function
Returns the name of the function to use within a ResultSet.- Specified by:
columnName
in 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)
-
-