Package edu.caltech.nanodb.commands
Class CreateIndexCommand
- java.lang.Object
-
- edu.caltech.nanodb.commands.Command
-
- edu.caltech.nanodb.commands.CreateIndexCommand
-
public class CreateIndexCommand extends Command
This command-class represents the CREATE INDEX DDL command.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class edu.caltech.nanodb.commands.Command
Command.Type
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.ArrayList<java.lang.String>
columnNames
The list of column-names that the index is built against.private boolean
ifNotExists
If this flag istrue
then the create-index operation should only be performed if the specified index doesn't already exist.private java.lang.String
indexName
The name of the index being created.private static org.apache.logging.log4j.Logger
logger
A logging object for reporting anything interesting that happens.private CommandProperties
properties
Any additional properties specified in the command.private java.lang.String
tableName
The name of the table that the index is built against.private boolean
unique
This flag specifies whether the index is a unique index or not.
-
Constructor Summary
Constructors Constructor Description CreateIndexCommand(java.lang.String indexName, java.lang.String tableName, boolean unique)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addColumn(java.lang.String columnName)
Adds a column to the list of columns to be included in the index.void
execute(NanoDBServer server)
Actually performs the command.java.util.List<java.lang.String>
getColumnNames()
Returns the list of column names specified for the index as an unmodifiable list.boolean
getIfNotExists()
Returnstrue
if index creation should only be attempted if it doesn't already exist,false
if index creation should always be attempted.java.lang.String
getIndexName()
Get the name of the index to be dropped.CommandProperties
getProperties()
Returns any additional properties specified for the command, ornull
if no additional properties were specified.java.lang.String
getTableName()
Get the name of the table containing the index to be dropped.boolean
isUnique()
Returns true if the requested index is a unique index; false otherwise.void
setIfNotExists(boolean b)
Sets the flag indicating whether index creation should only be attempted if it doesn't already exist.void
setProperties(CommandProperties properties)
Sets any additional properties associated with the command.-
Methods inherited from class edu.caltech.nanodb.commands.Command
getCommandType
-
-
-
-
Field Detail
-
logger
private static org.apache.logging.log4j.Logger logger
A logging object for reporting anything interesting that happens.
-
indexName
private java.lang.String indexName
The name of the index being created.
-
unique
private boolean unique
This flag specifies whether the index is a unique index or not. If the value is true then no key-value may appear multiple times; if the value is false then a key-value may appear multiple times.
-
ifNotExists
private boolean ifNotExists
If this flag istrue
then the create-index operation should only be performed if the specified index doesn't already exist.
-
tableName
private java.lang.String tableName
The name of the table that the index is built against.
-
columnNames
private java.util.ArrayList<java.lang.String> columnNames
The list of column-names that the index is built against. The order of these values is important; for ordered indexes, the index records must be kept in the order specified by the sequence of column names.
-
properties
private CommandProperties properties
Any additional properties specified in the command.
-
-
Method Detail
-
getIfNotExists
public boolean getIfNotExists()
Returnstrue
if index creation should only be attempted if it doesn't already exist,false
if index creation should always be attempted.- Returns:
true
if index creation should only be attempted if it doesn't already exist,false
if index creation should always be attempted.
-
setIfNotExists
public void setIfNotExists(boolean b)
Sets the flag indicating whether index creation should only be attempted if it doesn't already exist.- Parameters:
b
- the flag indicating whether index creation should only be attempted if it doesn't already exist.
-
getTableName
public java.lang.String getTableName()
Get the name of the table containing the index to be dropped.- Returns:
- the name of the table containing the index to drop
-
getIndexName
public java.lang.String getIndexName()
Get the name of the index to be dropped.- Returns:
- the name of the index to drop
-
getColumnNames
public java.util.List<java.lang.String> getColumnNames()
Returns the list of column names specified for the index as an unmodifiable list.- Returns:
- the list of column names specified for the index as an unmodifiable list.
-
isUnique
public boolean isUnique()
Returns true if the requested index is a unique index; false otherwise.- Returns:
- true if the requested index is a unique index; false otherwise.
-
setProperties
public void setProperties(CommandProperties properties)
Sets any additional properties associated with the command. The value may benull
to indicate no properties.- Parameters:
properties
- any additional properties to associate with the command.
-
getProperties
public CommandProperties getProperties()
Returns any additional properties specified for the command, ornull
if no additional properties were specified.- Returns:
- any additional properties specified for the command, or
null
if no additional properties were specified.
-
addColumn
public void addColumn(java.lang.String columnName)
Adds a column to the list of columns to be included in the index.- Parameters:
columnName
- the name of the column to add to the columns to be included in the index.
-
execute
public void execute(NanoDBServer server) throws ExecutionException
Description copied from class:Command
Actually performs the command.- Specified by:
execute
in classCommand
- Throws:
ExecutionException
- if an issue occurs during command execution
-
-