Class FunctionCall

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class FunctionCall
    extends Expression
    This class represents all kinds of function-call expressions, including simple function calls, aggregate function calls, and table-returning function calls. The set of available functions to call is stored in the FunctionDirectory.
    • Field Detail

      • funcName

        private java.lang.String funcName
        The string name of the function as specified in the original SQL.
      • distinct

        private boolean distinct
        A flag indicating whether the DISTINCT keyword was used in the function invocation, e.g. COUNT(DISTINCT n). This flag is only used in the context of aggregate functions; if it is set for other kinds of functions, it is a semantic error.
      • args

        private java.util.ArrayList<Expression> args
        The list of one or more arguments for the function call.
      • function

        private Function function
        The actual function object that implements the function call. This may be either a simple function or an aggregate function.
    • Constructor Detail

      • FunctionCall

        public FunctionCall​(java.lang.String funcName,
                            boolean distinct,
                            java.util.ArrayList<Expression> args)
      • FunctionCall

        public FunctionCall​(java.lang.String funcName,
                            boolean distinct,
                            Expression... args)
    • Method Detail

      • resolve

        public void resolve​(FunctionDirectory directory)
        Resolve this function-call against the function directory so that the implementation of the function is available at evaluation time.
        Parameters:
        directory - the function directory to resolve the function against
        Throws:
        java.lang.IllegalArgumentException - if the distinct flag is true but the function implementation is not an AggregateFunction.
      • getFunction

        public Function getFunction()
        Returns the implementation of the function, or null if the implementation has not yet been resolved via the resolve(edu.caltech.nanodb.functions.FunctionDirectory) method.
        Returns:
        the implementation of the function, or null if the implementation has not yet been resolved.
      • getArguments

        public java.util.List<Expression> getArguments()
      • getColumnInfo

        public ColumnInfo getColumnInfo​(Schema schema)
                                 throws SchemaNameException
        Description copied from class: Expression
        Returns a ColumnInfo object describing the type (and possibly the name) of the expression's result.
        Specified by:
        getColumnInfo in class Expression
        Parameters:
        schema - a schema object that can be used to look up name and type details for symbols referenced by the expression.
        Returns:
        a column-information object describing the type (and possibly the name and table-name) of this expression's result
        Throws:
        SchemaNameException - if a symbol cannot be resolved, either because it doesn't appear in the schema, or because the name is ambiguous.
      • evaluate

        public java.lang.Object evaluate​(Environment env)
                                  throws ExpressionException
        Description copied from class: Expression
        Evaluates this expression object in the context of the specified environment. The environment provides any external information necessary to evaluate the expression, such as the current tuples loaded from tables referenced within the expression.
        Specified by:
        evaluate in class Expression
        Parameters:
        env - the environment to look up symbol-values from, when evaluating the expression
        Returns:
        the result of the expression evaluation
        Throws:
        ExpressionException - if the expression cannot be evaluated for some reason.
      • traverse

        public Expression traverse​(ExpressionProcessor p)
        Description copied from class: Expression

        This method allows the entire expression tree to be traversed node by node, either for analysis or for transformation. The ExpressionProcessor instance receives notifications as each node in the expression is entered and left.

        The expression tree can also be manipulated by this traversal process, depending on what the ExpressionProcessor wants to do. If the expression node that traverse() is invoked on, needs to be replaced with a new expression node, the replacement is returned by the traverse() method. (The ExpressionProcessor specifies the replacement as the return-value from the ExpressionProcessor.leave(Expression) method.)

        Specified by:
        traverse in class Expression
        Parameters:
        p - the object that performs analysis or transformation of the expression tree
        Returns:
        an Expression node to replace this node, or null if no changes are to be made.
      • equals

        public boolean equals​(java.lang.Object obj)
        Description copied from class: Expression
        Checks if the argument is an expression with the same structure, but not necesarily the same references.
        Specified by:
        equals in class Expression
        Parameters:
        obj - the object to which we are comparing
      • hashCode

        public int hashCode()
        Description copied from class: Expression
        Computes the hashcode of an Expression. This method is used to see if two expressions CAN be equal.
        Specified by:
        hashCode in class Expression
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • clone

        protected java.lang.Object clone()
                                  throws java.lang.CloneNotSupportedException
        Creates a copy of expression.
        Overrides:
        clone in class Expression
        Throws:
        java.lang.CloneNotSupportedException