Class IndexChanger
- java.lang.Object
-
- org.apache.derby.impl.sql.execute.IndexChanger
-
class IndexChanger extends java.lang.ObjectPerform Index maintenance associated with DML operations for a single index.
-
-
Field Summary
Fields Modifier and Type Field Description private Activationactivationprivate ConglomerateControllerbaseCCprivate FormatableBitSetbaseRowReadMapprivate booleandeferrableprivate BackingStoreHashtabledeferredDuplicatesprivate ConglomerateControllerindexCCprivate longindexCIDprivate DynamicCompiledOpenConglomInfoindexDCOCIprivate java.lang.StringindexNameprivate ScanControllerindexSCprivate StaticCompiledOpenConglomInfoindexSCOCIprivate IndexRowGeneratorirgprivate intisolationLevelprivate LanguageConnectionContextlccprivate intlockModeprivate ExecIndexRowourIndexRowprivate ExecIndexRowourUpdatedIndexRowprivate booleanownIndexSCprivate TemporaryRowHolderImplrowHolderprivate booleanrowHolderPassedInprivate TransactionControllertcprivate UUIDuniqueConstraintId
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidclose()Close this IndexChanger.private voidcloseIndexCC()Close our index Conglomerate Controllerprivate voidcloseIndexSC()Close our index ScanController.(package private) voiddelete(ExecRow baseRow, RowLocation baseRowLocation)Perform index maintenance to support a delete of a base table row.private voiddoDeferredInsert()Insert a row into the temporary conglomerateprivate voiddoDelete()Delete a row from our index.private voiddoInsert()Insert a row into our indes.(package private) voidfinish()Finish doing the changes for this index.private UUIDgetUniqueConstraintId()private booleanindexRowChanged()Determine whether or not any columns in the current index row are being changed by the update.(package private) voidinsert(ExecRow newRow, RowLocation baseRowLocation)Perform index maintenance to support an insert of a base table row.private voidinsertAndCheckDups(ExecIndexRow row)Insert the given row into the given conglomerate and check for duplicate key error.(package private) voidinsertForUpdate(ExecRow newRow, RowLocation baseRowLocation)If we're updating a unique index, the inserts have to be deferred.(package private) voidopen()Open this IndexChanger.private ConglomerateControlleropenIndexCC()Open the ConglomerateController for this index if it isn't open yet.(package private) voidsetBaseCC(ConglomerateController baseCC)Propagate the heap's ConglomerateController to this index changer.private voidsetOurIndexRow(ExecRow baseRow, RowLocation baseRowLoc)Set the column values for 'ourIndexRow' to refer to a base table row and location provided by the caller.private voidsetOurUpdatedIndexRow(ExecRow baseRow, RowLocation baseRowLoc)Set the column values for 'ourUpdatedIndexRow' to refer to a base table row and location provided by the caller.(package private) voidsetRowHolder(TemporaryRowHolderImpl rowHolder)Set the row holder for this changer to use.private voidsetScan()Position our index scan to 'ourIndexRow'.(package private) voidupdate(ExecRow oldBaseRow, ExecRow newBaseRow, RowLocation baseRowLocation)Perform index maintenance to support an update of a base table row.
-
-
-
Field Detail
-
irg
private final IndexRowGenerator irg
-
indexCID
private final long indexCID
-
indexDCOCI
private final DynamicCompiledOpenConglomInfo indexDCOCI
-
indexSCOCI
private final StaticCompiledOpenConglomInfo indexSCOCI
-
indexName
private final java.lang.String indexName
-
baseCC
private ConglomerateController baseCC
-
tc
private final TransactionController tc
-
lockMode
private final int lockMode
-
baseRowReadMap
private final 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
-
deferrable
private final boolean deferrable
-
lcc
private final LanguageConnectionContext lcc
-
deferredDuplicates
private BackingStoreHashtable deferredDuplicates
-
uniqueConstraintId
private UUID uniqueConstraintId
-
-
Constructor Detail
-
IndexChanger
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 indexes.indexDCOCI- the DCOCI for the indexes.baseCC- the ConglomerateController for the base table.tc- The TransactionControllerlockMode- The lock mode (granularity) to usebaseRowReadMap- Map of columns read in. 1 based.isolationLevel- Isolation level to use.activation- Current activation- Throws:
StandardException- Thrown on error
-
-
Method Detail
-
setRowHolder
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
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 StandardExceptionDetermine 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 StandardExceptionPosition 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 StandardExceptionClose our index Conglomerate Controller- Throws:
StandardException
-
closeIndexSC
private void closeIndexSC() throws StandardExceptionClose our index ScanController.- Throws:
StandardException
-
doDelete
private void doDelete() throws StandardExceptionDelete 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 StandardExceptionInsert 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 StandardExceptionInsert a row into the temporary conglomerateThis opens our deferred ConglomeratController the first time it is called.
- Throws:
StandardException- Thrown on error
-
getUniqueConstraintId
private UUID getUniqueConstraintId() throws StandardException
- Throws:
StandardException
-
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 unless we have a deferred constraint. In that index rows are saved for checking on commit.
-
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
void open() throws StandardException
Open this IndexChanger.- Throws:
StandardException- Thrown on error
-
delete
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
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
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
void finish() throws StandardExceptionFinish 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
void close() throws StandardExceptionClose this IndexChanger.- Throws:
StandardException- Thrown on error
-
-