org.apache.derby.impl.sql.execute
Class CreateIndexConstantAction

java.lang.Object
  extended by org.apache.derby.impl.sql.execute.DDLConstantAction
      extended by org.apache.derby.impl.sql.execute.DDLSingleTableConstantAction
          extended by org.apache.derby.impl.sql.execute.IndexConstantAction
              extended by org.apache.derby.impl.sql.execute.CreateIndexConstantAction
All Implemented Interfaces:
ConstantAction

 class CreateIndexConstantAction
extends IndexConstantAction

ConstantAction to create an index either through a CREATE INDEX statement or as a backing index to a constraint.


Field Summary
private  java.lang.String[] columnNames
           
private  UUID conglomerateUUID
           
private  long conglomId
          Conglomerate number for the conglomerate created by this constant action; -1L if this constant action has not been executed.
private  long droppedConglomNum
          Conglomerate number of the physical conglomerate that we will "replace" using this constant action.
private  boolean forCreateTable
          Is this for a CREATE TABLE, i.e. it is for a constraint declared in a CREATE TABLE statement that requires a backing index.
private  ExecRow indexTemplateRow
           
private  java.lang.String indexType
           
private  boolean[] isAscending
           
private  boolean isConstraint
           
private  java.util.Properties properties
           
private  boolean unique
           
private  boolean uniqueWithDuplicateNulls
           
 
Fields inherited from class org.apache.derby.impl.sql.execute.IndexConstantAction
indexName, schemaName, tableName
 
Fields inherited from class org.apache.derby.impl.sql.execute.DDLSingleTableConstantAction
tableId
 
Constructor Summary
CreateIndexConstantAction(boolean forCreateTable, boolean unique, boolean uniqueWithDuplicateNulls, java.lang.String indexType, java.lang.String schemaName, java.lang.String indexName, java.lang.String tableName, UUID tableId, java.lang.String[] columnNames, boolean[] isAscending, boolean isConstraint, UUID conglomerateUUID, java.util.Properties properties)
          Make the ConstantAction to create an index.
CreateIndexConstantAction(ConglomerateDescriptor srcCD, TableDescriptor td, java.util.Properties properties)
          Make a ConstantAction that creates a new physical conglomerate based on index information stored in the received descriptors.
 
Method Summary
 void executeConstantAction(Activation activation)
          This is the guts of the Execution-time logic for creating an index.
(package private)  long getCreatedConglomNumber()
          Get the conglomerate number for the conglomerate that was created by this constant action.
(package private)  UUID getCreatedUUID()
          Get the UUID for the conglomerate descriptor that was created (or re-used) by this constant action.
(package private)  ExecRow getIndexTemplateRow()
           
(package private)  long getReplacedConglomNumber()
          If the purpose of this constant action was to "replace" a dropped physical conglomerate, then this method returns the conglomerate number of the dropped conglomerate.
private  RowLocationRetRowSource loadSorter(ExecRow[] baseRows, ExecIndexRow[] indexRows, TransactionController tc, GroupFetchScanController scan, long sortId, RowLocation[] rl)
          Scan the base conglomerate and insert the keys into a sorter, returning a rowSource on the sorter.
private  void statementExceptionCleanup(ScanController scan, ConglomerateController indexController)
          Do necessary clean up (close down controllers, etc.) before throwing a statement exception.
 java.lang.String toString()
           
 
Methods inherited from class org.apache.derby.impl.sql.execute.IndexConstantAction
getIndexName, setIndexName
 
Methods inherited from class org.apache.derby.impl.sql.execute.DDLSingleTableConstantAction
dropConglomerate, dropConglomerate, dropConstraint, dropConstraint, dropConstraint, executeConglomReplacement, getConglomReplacementAction, recreateUniqueConstraintBackingIndexAsUniqueWhenNotNull
 
Methods inherited from class org.apache.derby.impl.sql.execute.DDLConstantAction
addColumnDependencies, adjustUDTDependencies, adjustUDTDependencies, constructToString, getAndCheckSchemaDescriptor, getSchemaDescriptorForCreate, lockTableForDDL, storeConstraintDependenciesOnPrivileges, storeViewTriggerDependenciesOnPrivileges
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

forCreateTable

private final boolean forCreateTable
Is this for a CREATE TABLE, i.e. it is for a constraint declared in a CREATE TABLE statement that requires a backing index.


unique

private boolean unique

uniqueWithDuplicateNulls

private boolean uniqueWithDuplicateNulls

indexType

private java.lang.String indexType

columnNames

private java.lang.String[] columnNames

isAscending

private boolean[] isAscending

isConstraint

private boolean isConstraint

conglomerateUUID

private UUID conglomerateUUID

properties

private java.util.Properties properties

indexTemplateRow

private ExecRow indexTemplateRow

conglomId

private long conglomId
Conglomerate number for the conglomerate created by this constant action; -1L if this constant action has not been executed. If this constant action doesn't actually create a new conglomerate--which can happen if it finds an existing conglomerate that satisfies all of the criteria--then this field will hold the conglomerate number of whatever existing conglomerate was found.


droppedConglomNum

private long droppedConglomNum
Conglomerate number of the physical conglomerate that we will "replace" using this constant action. That is, if the purpose of this constant action is to create a new physical conglomerate to replace a dropped physical conglomerate, then this field holds the conglomerate number of the dropped physical conglomerate. If -1L then we are not replacing a conglomerate, we're simply creating a new index (and backing physical conglomerate) as normal.

Constructor Detail

CreateIndexConstantAction

CreateIndexConstantAction(boolean forCreateTable,
                          boolean unique,
                          boolean uniqueWithDuplicateNulls,
                          java.lang.String indexType,
                          java.lang.String schemaName,
                          java.lang.String indexName,
                          java.lang.String tableName,
                          UUID tableId,
                          java.lang.String[] columnNames,
                          boolean[] isAscending,
                          boolean isConstraint,
                          UUID conglomerateUUID,
                          java.util.Properties properties)
Make the ConstantAction to create an index.

Parameters:
forCreateTable - Being executed within a CREATE TABLE statement
unique - True means it will be a unique index
uniqueWithDuplicateNulls - True means index check and disallow any duplicate key if key has no column with a null value. If any column in the key has a null value, no checking is done and insert will always succeed.
indexType - type of index (BTREE, for example)
schemaName - schema that table (and index) lives in.
indexName - Name of the index
tableName - Name of table the index will be on
tableId - UUID of table
columnNames - Names of the columns in the index, in order
isAscending - Array of booleans telling asc/desc on each column
isConstraint - TRUE if index is backing up a constraint, else FALSE
conglomerateUUID - ID of conglomerate
properties - The optional properties list associated with the index.

CreateIndexConstantAction

CreateIndexConstantAction(ConglomerateDescriptor srcCD,
                          TableDescriptor td,
                          java.util.Properties properties)
Make a ConstantAction that creates a new physical conglomerate based on index information stored in the received descriptors. Assumption is that the received ConglomerateDescriptor is still valid (meaning it has corresponding entries in the system tables and it describes some constraint/index that has _not_ been dropped--though the physical conglomerate underneath has). This constructor is used in cases where the physical conglomerate for an index has been dropped but the index still exists. That can happen if multiple indexes share a physical conglomerate but then the conglomerate is dropped as part of "drop index" processing for one of the indexes. (Note that "indexes" here includes indexes which were created to back constraints.) In that case we have to create a new conglomerate to satisfy the remaining sharing indexes, so that's what we're here for. See ConglomerateDescriptor.drop() for details on when that is necessary.

Method Detail

toString

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

executeConstantAction

public void executeConstantAction(Activation activation)
                           throws StandardException
This is the guts of the Execution-time logic for creating an index.

A index is represented as:

No dependencies are created.

Parameters:
activation - The execution environment for this constant action.
Throws:
StandardException - Thrown on failure
See Also:
ConglomerateDescriptor, SchemaDescriptor, ConstantAction.executeConstantAction(org.apache.derby.iapi.sql.Activation)

getIndexTemplateRow

ExecRow getIndexTemplateRow()

getCreatedConglomNumber

long getCreatedConglomNumber()
Get the conglomerate number for the conglomerate that was created by this constant action. Will return -1L if the constant action has not yet been executed. This is used for updating conglomerate descriptors which share a conglomerate that has been dropped, in which case those "sharing" descriptors need to point to the newly-created conglomerate (the newly-created conglomerate replaces the dropped one).


getReplacedConglomNumber

long getReplacedConglomNumber()
If the purpose of this constant action was to "replace" a dropped physical conglomerate, then this method returns the conglomerate number of the dropped conglomerate. Otherwise this method will end up returning -1.


getCreatedUUID

UUID getCreatedUUID()
Get the UUID for the conglomerate descriptor that was created (or re-used) by this constant action.


statementExceptionCleanup

private void statementExceptionCleanup(ScanController scan,
                                       ConglomerateController indexController)
                                throws StandardException
Do necessary clean up (close down controllers, etc.) before throwing a statement exception.

Parameters:
scan - ScanController for the heap
indexController - ConglomerateController for the index
Throws:
StandardException

loadSorter

private RowLocationRetRowSource loadSorter(ExecRow[] baseRows,
                                           ExecIndexRow[] indexRows,
                                           TransactionController tc,
                                           GroupFetchScanController scan,
                                           long sortId,
                                           RowLocation[] rl)
                                    throws StandardException
Scan the base conglomerate and insert the keys into a sorter, returning a rowSource on the sorter.

Returns:
RowSource on the sorted index keys.
Throws:
StandardException - thrown on error

Built on Thu 2011-03-10 11:54:14+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.