Package edu.caltech.nanodb.commands
Class UpdateCommand
- java.lang.Object
-
- edu.caltech.nanodb.commands.Command
-
- edu.caltech.nanodb.commands.QueryCommand
-
- edu.caltech.nanodb.commands.UpdateCommand
-
public class UpdateCommand extends QueryCommand
This command object represents a top-level UPDATE command issued against the database.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
UpdateCommand.TupleUpdater
An implementation of the tuple processor interface used by theUpdateCommand
to update each tuple.-
Nested classes/interfaces inherited from class edu.caltech.nanodb.commands.QueryCommand
QueryCommand.Type
-
-
Field Summary
Fields Modifier and Type Field Description private TableInfo
tableInfo
private java.lang.String
tableName
The name of the table that the rows will be updated on.private java.util.List<UpdateValue>
values
This field holds the list of names and expressions that will be applied in the update command.private Expression
whereExpr
If a WHERE expression is specified, this field will refer to the expression to be evaluated.-
Fields inherited from class edu.caltech.nanodb.commands.QueryCommand
explain, plan
-
-
Constructor Summary
Constructors Constructor Description UpdateCommand(java.lang.String tableName)
Constructs a new update command for UPDATE statements.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addValue(java.lang.String colName, Expression valueExpr)
java.lang.String
getTableName()
protected TupleProcessor
getTupleProcessor(EventDispatcher eventDispatcher)
Creates a tuple-processor responsible for dealing with the tuples that are generated by the query command.java.util.List<UpdateValue>
getValues()
Expression
getWhereExpr()
protected void
prepareQueryPlan(NanoDBServer server)
Prepares an execution plan for generating the tuples that this query command will operate on.void
setWhereExpr(Expression whereExpr)
Sets the expression for the WHERE clause.java.lang.String
toString()
-
Methods inherited from class edu.caltech.nanodb.commands.QueryCommand
execute, setExplain
-
Methods inherited from class edu.caltech.nanodb.commands.Command
getCommandType
-
-
-
-
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.
-
tableInfo
private TableInfo tableInfo
-
-
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. Anull
value indicates that the UPDATE command has no WHERE condition.- Parameters:
whereExpr
- the where-expression that constrains which rows will be updated
-
getWhereExpr
public Expression getWhereExpr()
-
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 classQueryCommand
- 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 classQueryCommand
- 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 classjava.lang.Object
-
-