Class IndexChanger
- java.lang.Object
-
- org.apache.derby.impl.sql.execute.IndexChanger
-
class IndexChanger extends java.lang.Object
Perform Index maintenance associated with DML operations for a single index.
-
-
Field Summary
Fields Modifier and Type Field Description private Activation
activation
private ConglomerateController
baseCC
private FormatableBitSet
baseRowReadMap
private boolean
deferrable
private BackingStoreHashtable
deferredDuplicates
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 LanguageConnectionContext
lcc
private int
lockMode
private ExecIndexRow
ourIndexRow
private ExecIndexRow
ourUpdatedIndexRow
private boolean
ownIndexSC
private TemporaryRowHolderImpl
rowHolder
private boolean
rowHolderPassedIn
private TransactionController
tc
private UUID
uniqueConstraintId
-
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) void
close()
Close this IndexChanger.private void
closeIndexCC()
Close our index Conglomerate Controllerprivate void
closeIndexSC()
Close our index ScanController.(package private) 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 conglomerateprivate void
doDelete()
Delete a row from our index.private void
doInsert()
Insert a row into our indes.(package private) void
finish()
Finish doing the changes for this index.private UUID
getUniqueConstraintId()
private boolean
indexRowChanged()
Determine whether or not any columns in the current index row are being changed by the update.(package private) 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.(package private) void
open()
Open this IndexChanger.private ConglomerateController
openIndexCC()
Open the ConglomerateController for this index if it isn't open yet.(package private) 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.(package private) void
setRowHolder(TemporaryRowHolderImpl rowHolder)
Set the row holder for this changer to use.private void
setScan()
Position our index scan to 'ourIndexRow'.(package private) void
update(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 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 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 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
void close() throws StandardException
Close this IndexChanger.- Throws:
StandardException
- Thrown on error
-
-