Class UpdateCommand


  • public class UpdateCommand
    extends QueryCommand
    This command object represents a top-level UPDATE command issued against the database.
    • Field Detail

      • tableName

        private java.lang.String tableName
        The name of the table that the rows will be updated on.
      • values

        private java.util.List<UpdateValue> values
        This field holds the list of names and expressions that will be applied in the update command.
      • whereExpr

        private Expression whereExpr
        If a WHERE expression is specified, this field will refer to the expression to be evaluated.
    • Constructor Detail

      • UpdateCommand

        public UpdateCommand​(java.lang.String tableName)
        Constructs a new update command for UPDATE statements. Note that the list of value and the where-expression are both uninitialized at first.
        Parameters:
        tableName - the name of the table that this command will update
    • Method Detail

      • getTableName

        public java.lang.String getTableName()
      • addValue

        public void addValue​(java.lang.String colName,
                             Expression valueExpr)
      • getValues

        public java.util.List<UpdateValue> getValues()
      • setWhereExpr

        public void setWhereExpr​(Expression whereExpr)
        Sets the expression for the WHERE clause. A null value indicates that the UPDATE command has no WHERE condition.
        Parameters:
        whereExpr - the where-expression that constrains which rows will be updated
      • prepareQueryPlan

        protected void prepareQueryPlan​(NanoDBServer server)
        Description copied from class: QueryCommand
        Prepares an execution plan for generating the tuples that this query command will operate on. Since the specific plan to generate depends on the operation being performed, this is an abstract method to be implemented by subclasses. For example, SELECTs support very sophisticated operations and thus require complex plans, but a DELETE operation simply requires a scan over a tuple file, perhaps with a predicate applied.
        Specified by:
        prepareQueryPlan in class QueryCommand
        Parameters:
        server - the server to use for planning, fetching table schemas, statistics, and other details relevant for planning
      • getTupleProcessor

        protected TupleProcessor getTupleProcessor​(EventDispatcher eventDispatcher)
        Description copied from class: QueryCommand
        Creates a tuple-processor responsible for dealing with the tuples that are generated by the query command. Depending on the operation being performed, different tuple-processors are appropriate. For example, the SELECT processor sends the tuples to the console or to a remote client; the DELETE processor deletes the tuples from the referenced table.
        Specified by:
        getTupleProcessor in class QueryCommand
        Parameters:
        eventDispatcher - used for notifying other components in the database when rows are inserted/updated/deleted
        Returns:
        the tuple processor to use in processing tuples generated by the query
      • toString

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