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

java.lang.Object
  extended by org.apache.derby.impl.sql.execute.IndexChanger

public class IndexChanger
extends java.lang.Object

Perform Index maintenace associated with DML operations for a single index.


Field Summary
private  Activation activation
           
private  ConglomerateController baseCC
           
private  FormatableBitSet baseRowReadMap
           
private  ConglomerateController indexCC
           
private  long indexCID
           
private  DynamicCompiledOpenConglomInfo indexDCOCI
           
private  java.lang.String indexName
           
private  ScanController indexSC
           
private  StaticCompiledOpenConglomInfo indexSCOCI
           
private  IndexRowGenerator irg
           
private  int isolationLevel
           
private  int lockMode
           
private  ExecIndexRow ourIndexRow
           
private  ExecIndexRow ourUpdatedIndexRow
           
private  boolean ownIndexSC
           
private  TemporaryRowHolderImpl rowHolder
           
private  boolean rowHolderPassedIn
           
private  TransactionController tc
           
 
Constructor Summary
IndexChanger(IndexRowGenerator irg, long indexCID, StaticCompiledOpenConglomInfo indexSCOCI, DynamicCompiledOpenConglomInfo indexDCOCI, java.lang.String indexName, ConglomerateController baseCC, TransactionController tc, int lockMode, FormatableBitSet baseRowReadMap, int isolationLevel, Activation activation)
          Create an IndexChanger
 
Method Summary
 void close()
          Close this IndexChanger.
private  void closeIndexCC()
          Close our index Conglomerate Controller
private  void closeIndexSC()
          Close our index ScanController.
 void delete(ExecRow baseRow, RowLocation baseRowLocation)
          Perform index maintenance to support a delete of a base table row.
private  void doDeferredInsert()
          Insert a row into the temporary conglomerate This opens our deferred ConglomeratController the first time it is called.
private  void doDelete()
          Delete a row from our index.
private  void doInsert()
          Insert a row into our indes.
 void finish()
          Finish doing the changes for this index.
private  boolean indexRowChanged()
          Determine whether or not any columns in the current index row are being changed by the update.
 void insert(ExecRow newRow, RowLocation baseRowLocation)
          Perform index maintenance to support an insert of a base table row.
private  void insertAndCheckDups(ExecIndexRow row)
          Insert the given row into the given conglomerate and check for duplicate key error.
(package private)  void insertForUpdate(ExecRow newRow, RowLocation baseRowLocation)
          If we're updating a unique index, the inserts have to be deferred.
 void open()
          Open this IndexChanger.
private  ConglomerateController openIndexCC()
          Open the ConglomerateController for this index if it isn't open yet.
 void setBaseCC(ConglomerateController baseCC)
          Propagate the heap's ConglomerateController to this index changer.
private  void setOurIndexRow(ExecRow baseRow, RowLocation baseRowLoc)
          Set the column values for 'ourIndexRow' to refer to a base table row and location provided by the caller.
private  void setOurUpdatedIndexRow(ExecRow baseRow, RowLocation baseRowLoc)
          Set the column values for 'ourUpdatedIndexRow' to refer to a base table row and location provided by the caller.
 void setRowHolder(TemporaryRowHolderImpl rowHolder)
          Set the row holder for this changer to use.
private  void setScan()
          Position our index scan to 'ourIndexRow'.
 void update(ExecRow oldBaseRow, ExecRow newBaseRow, RowLocation baseRowLocation)
          Perform index maintenance to support an update of a base table row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

irg

private IndexRowGenerator irg

indexCID

private long indexCID

indexDCOCI

private DynamicCompiledOpenConglomInfo indexDCOCI

indexSCOCI

private StaticCompiledOpenConglomInfo indexSCOCI

indexName

private java.lang.String indexName

baseCC

private ConglomerateController baseCC

tc

private TransactionController tc

lockMode

private int lockMode

baseRowReadMap

private FormatableBitSet baseRowReadMap

indexCC

private ConglomerateController indexCC

indexSC

private ScanController indexSC

ourIndexRow

private ExecIndexRow ourIndexRow

ourUpdatedIndexRow

private ExecIndexRow ourUpdatedIndexRow

rowHolder

private TemporaryRowHolderImpl rowHolder

rowHolderPassedIn

private boolean rowHolderPassedIn

isolationLevel

private int isolationLevel

activation

private final Activation activation

ownIndexSC

private boolean ownIndexSC
Constructor Detail

IndexChanger

public IndexChanger(IndexRowGenerator irg,
                    long indexCID,
                    StaticCompiledOpenConglomInfo indexSCOCI,
                    DynamicCompiledOpenConglomInfo indexDCOCI,
                    java.lang.String indexName,
                    ConglomerateController baseCC,
                    TransactionController tc,
                    int lockMode,
                    FormatableBitSet baseRowReadMap,
                    int isolationLevel,
                    Activation activation)
             throws StandardException
Create an IndexChanger

Parameters:
irg - the IndexRowGenerator for the index.
indexCID - the conglomerate id for the index.
indexSCOCI - the SCOCI for the idexes.
indexDCOCI - the DCOCI for the idexes.
baseCC - the ConglomerateController for the base table.
tc - The TransactionController
lockMode - The lock mode (granularity) to use
baseRowReadMap - Map of columns read in. 1 based.
isolationLevel - Isolation level to use.
activation - Current activation
Throws:
StandardException - Thrown on error
Method Detail

setRowHolder

public void setRowHolder(TemporaryRowHolderImpl rowHolder)
Set the row holder for this changer to use. If the row holder is set, it wont bother saving copies of rows needed for deferred processing. Also, it will never close the passed in rowHolder.

Parameters:
rowHolder - the row holder

setBaseCC

public void setBaseCC(ConglomerateController baseCC)
Propagate the heap's ConglomerateController to this index changer.

Parameters:
baseCC - The heap's ConglomerateController.

setOurIndexRow

private void setOurIndexRow(ExecRow baseRow,
                            RowLocation baseRowLoc)
                     throws StandardException
Set the column values for 'ourIndexRow' to refer to a base table row and location provided by the caller. The idea here is to

Parameters:
baseRow - a base table row.
baseRowLoc - baseRowLoc baseRow's location
Throws:
StandardException - Thrown on error

setOurUpdatedIndexRow

private void setOurUpdatedIndexRow(ExecRow baseRow,
                                   RowLocation baseRowLoc)
                            throws StandardException
Set the column values for 'ourUpdatedIndexRow' to refer to a base table row and location provided by the caller. The idea here is to

Parameters:
baseRow - a base table row.
baseRowLoc - baseRowLoc baseRow's location
Throws:
StandardException - Thrown on error

indexRowChanged

private boolean indexRowChanged()
                         throws StandardException
Determine whether or not any columns in the current index row are being changed by the update. No need to update the index if no columns changed.

Returns:
Nothing.
Throws:
StandardException - Thrown on error

setScan

private void setScan()
              throws StandardException
Position our index scan to 'ourIndexRow'.

This creates the scan the first time it is called.

Throws:
StandardException - Thrown on error

closeIndexCC

private void closeIndexCC()
                   throws StandardException
Close our index Conglomerate Controller

Throws:
StandardException

closeIndexSC

private void closeIndexSC()
                   throws StandardException
Close our index ScanController.

Throws:
StandardException

doDelete

private void doDelete()
               throws StandardException
Delete a row from our index. This assumes our index ScanController is positioned before the row by setScan if we own the SC, otherwise it is positioned on the row by the underlying index scan.

This verifies the row exists and is unique.

Throws:
StandardException - Thrown on error

doInsert

private void doInsert()
               throws StandardException
Insert a row into our indes.

This opens our index ConglomeratController the first time it is called.

Throws:
StandardException - Thrown on error

doDeferredInsert

private void doDeferredInsert()
                       throws StandardException
Insert a row into the temporary conglomerate

This opens our deferred ConglomeratController the first time it is called.

Throws:
StandardException - Thrown on error

insertAndCheckDups

private void insertAndCheckDups(ExecIndexRow row)
                         throws StandardException
Insert the given row into the given conglomerate and check for duplicate key error.

Parameters:
row - The row to insert
Throws:
StandardException - Thrown on duplicate key error

openIndexCC

private ConglomerateController openIndexCC()
                                    throws StandardException
Open the ConglomerateController for this index if it isn't open yet.

Returns:
The ConglomerateController for this index.
Throws:
StandardException - Thrown on duplicate key error

open

public void open()
          throws StandardException
Open this IndexChanger.

Throws:
StandardException - Thrown on error

delete

public void delete(ExecRow baseRow,
                   RowLocation baseRowLocation)
            throws StandardException
Perform index maintenance to support a delete of a base table row.

Parameters:
baseRow - the base table row.
baseRowLocation - the base table row's location.
Throws:
StandardException - Thrown on error

update

public void update(ExecRow oldBaseRow,
                   ExecRow newBaseRow,
                   RowLocation baseRowLocation)
            throws StandardException
Perform index maintenance to support an update of a base table row.

Parameters:
oldBaseRow - the old image of the base table row.
newBaseRow - the new image of the base table row.
baseRowLocation - the base table row's location.
Throws:
StandardException - Thrown on error

insert

public void insert(ExecRow newRow,
                   RowLocation baseRowLocation)
            throws StandardException
Perform index maintenance to support an insert of a base table row.

Parameters:
newRow - the base table row.
baseRowLocation - the base table row's location.
Throws:
StandardException - Thrown on error

insertForUpdate

void insertForUpdate(ExecRow newRow,
                     RowLocation baseRowLocation)
               throws StandardException
If we're updating a unique index, the inserts have to be deferred. This is to avoid uniqueness violations that are only temporary. If we do all the deletes first, only "true" uniqueness violations can happen. We do this here, rather than in open(), because this is the only operation that requires deferred inserts, and we only want to create the conglomerate if necessary.

Parameters:
newRow - the base table row.
baseRowLocation - the base table row's location.
Throws:
StandardException - Thrown on error

finish

public void finish()
            throws StandardException
Finish doing the changes for this index. This is intended for deferred inserts for unique indexes. It has no effect unless we are doing an update of a unique index.

Throws:
StandardException - Thrown on error

close

public void close()
           throws StandardException
Close this IndexChanger.

Throws:
StandardException - Thrown on error

Built on Thu 2010-12-23 20:49:13+0000, from revision ???

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