Class IndexChanger
java.lang.Object
org.apache.derby.impl.sql.execute.IndexChanger
Perform Index maintenance associated with DML operations for a single index.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Activationprivate ConglomerateControllerprivate final FormatableBitSetprivate final booleanprivate BackingStoreHashtableprivate ConglomerateControllerprivate final longprivate final DynamicCompiledOpenConglomInfoprivate final Stringprivate ScanControllerprivate final StaticCompiledOpenConglomInfoprivate final IndexRowGeneratorprivate intprivate final LanguageConnectionContextprivate final intprivate ExecIndexRowprivate ExecIndexRowprivate booleanprivate TemporaryRowHolderImplprivate booleanprivate final TransactionControllerprivate UUID -
Constructor Summary
ConstructorsConstructorDescriptionIndexChanger(IndexRowGenerator irg, long indexCID, StaticCompiledOpenConglomInfo indexSCOCI, DynamicCompiledOpenConglomInfo indexDCOCI, String indexName, ConglomerateController baseCC, TransactionController tc, int lockMode, FormatableBitSet baseRowReadMap, int isolationLevel, Activation activation) Create an IndexChanger -
Method Summary
Modifier and TypeMethodDescription(package private) voidclose()Close this IndexChanger.private voidClose our index Conglomerate Controllerprivate voidClose our index ScanController.(package private) voiddelete(ExecRow baseRow, RowLocation baseRowLocation) Perform index maintenance to support a delete of a base table row.private voidInsert 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 UUIDprivate booleanDetermine 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 voidInsert 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 ConglomerateControllerOpen 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 Details
-
irg
-
indexCID
private final long indexCID -
indexDCOCI
-
indexSCOCI
-
indexName
-
baseCC
-
tc
-
lockMode
private final int lockMode -
baseRowReadMap
-
indexCC
-
indexSC
-
ourIndexRow
-
ourUpdatedIndexRow
-
rowHolder
-
rowHolderPassedIn
private boolean rowHolderPassedIn -
isolationLevel
private int isolationLevel -
activation
-
ownIndexSC
private boolean ownIndexSC -
deferrable
private final boolean deferrable -
lcc
-
deferredDuplicates
-
uniqueConstraintId
-
-
Constructor Details
-
IndexChanger
IndexChanger(IndexRowGenerator irg, long indexCID, StaticCompiledOpenConglomInfo indexSCOCI, DynamicCompiledOpenConglomInfo indexDCOCI, 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 Details
-
setRowHolder
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
Propagate the heap's ConglomerateController to this index changer.- Parameters:
baseCC- The heap's ConglomerateController.
-
setOurIndexRow
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
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
Position our index scan to 'ourIndexRow'.This creates the scan the first time it is called.
- Throws:
StandardException- Thrown on error
-
closeIndexCC
Close our index Conglomerate Controller- Throws:
StandardException
-
closeIndexSC
Close our index ScanController.- Throws:
StandardException
-
doDelete
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
Insert a row into our indes.This opens our index ConglomeratController the first time it is called.
- Throws:
StandardException- Thrown on error
-
doDeferredInsert
Insert a row into the temporary conglomerateThis opens our deferred ConglomeratController the first time it is called.
- Throws:
StandardException- Thrown on error
-
getUniqueConstraintId
- Throws:
StandardException
-
insertAndCheckDups
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
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
Open this IndexChanger.- Throws:
StandardException- Thrown on error
-
delete
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
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
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
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
Close this IndexChanger.- Throws:
StandardException- Thrown on error
-