Top Description Fields Constructors Methods
org.apache.derby.impl.sql.execute

pack-priv Class IndexChanger

extends Object
Class Inheritance
Imports
java.util.Properties, org.apache.derby.catalog.UUID, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.shared.common.i18n.MessageService, org.apache.derby.iapi.services.io.FormatableBitSet, org.apache.derby.iapi.services.monitor.Monitor, org.apache.derby.iapi.sql.Activation, .ResultDescription, org.apache.derby.iapi.sql.conn.LanguageConnectionContext, org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor, .ConstraintDescriptor, .ConstraintDescriptorList, .DataDictionary, .IndexRowGenerator, .ReferencedKeyConstraintDescriptor, .TableDescriptor, org.apache.derby.iapi.sql.execute.CursorResultSet, .ExecIndexRow, .ExecRow, org.apache.derby.iapi.store.access.BackingStoreHashtable, .ConglomerateController, .DynamicCompiledOpenConglomInfo, .ScanController, .StaticCompiledOpenConglomInfo, .TransactionController, org.apache.derby.iapi.types.DataValueDescriptor, .RowLocation, org.apache.derby.shared.common.sanity.SanityManager

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

Field Summary

Modifier and TypeField and Description
private final Activation
private ConglomerateController
private final FormatableBitSet
private final boolean
private BackingStoreHashtable
private ConglomerateController
private final long
private final DynamicCompiledOpenConglomInfo
private final String
private ScanController
private final StaticCompiledOpenConglomInfo
private final IndexRowGenerator
private int
private final LanguageConnectionContext
private final int
private ExecIndexRow
private ExecIndexRow
private boolean
private TemporaryRowHolderImpl
private boolean
private final TransactionController
private UUID

Constructor Summary

AccessConstructor and Description
pack-priv
IndexChanger(IndexRowGenerator
the IndexRowGenerator for the index.
irg
,
long
the conglomerate id for the index.
indexCID
,
StaticCompiledOpenConglomInfo
the SCOCI for the indexes.
indexSCOCI
,
DynamicCompiledOpenConglomInfo
the DCOCI for the indexes.
indexDCOCI
,
String indexName, ConglomerateController
the ConglomerateController for the base table.
baseCC
,
TransactionController
The TransactionController
tc
,
int
The lock mode (granularity) to use
lockMode
,
FormatableBitSet
Map of columns read in. 1 based.
baseRowReadMap
,
int
Isolation level to use.
isolationLevel
,
Activation
Current activation
activation
)

Create an IndexChanger

Method Summary

Modifier and TypeMethod and Description
pack-priv void
close()

Close this IndexChanger.

private void
closeIndexCC()

Close our index Conglomerate Controller

private void
closeIndexSC()

Close our index ScanController.

pack-priv void
delete(ExecRow
the base table row.
baseRow
,
RowLocation
the base table row's location.
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.

pack-priv void
finish()

Finish doing the changes for this index.

private UUID
private boolean

Returns:

Nothing.
indexRowChanged
()

Determine whether or not any columns in the current index row are being changed by the update.

pack-priv void
insert(ExecRow
the base table row.
newRow
,
RowLocation
the base table row's location.
baseRowLocation
)

Perform index maintenance to support an insert of a base table row.

private void
insertAndCheckDups(ExecIndexRow
The row to insert
row
)

Insert the given row into the given conglomerate and check for duplicate key error.

pack-priv void
insertForUpdate(ExecRow
the base table row.
newRow
,
RowLocation
the base table row's location.
baseRowLocation
)

If we're updating a unique index, the inserts have to be deferred.

pack-priv void
open()

Open this IndexChanger.

private ConglomerateController

Returns:

The ConglomerateController for this index.
openIndexCC
()

Open the ConglomerateController for this index if it isn't open yet.

pack-priv void
setBaseCC(ConglomerateController
The heap's ConglomerateController.
baseCC
)

Propagate the heap's ConglomerateController to this index changer.

private void
setOurIndexRow(ExecRow
a base table row.
baseRow
,
RowLocation
baseRowLoc baseRow's location
baseRowLoc
)

Set the column values for 'ourIndexRow' to refer to a base table row and location provided by the caller.

private void
setOurUpdatedIndexRow(ExecRow
a base table row.
baseRow
,
RowLocation
baseRowLoc baseRow's location
baseRowLoc
)

Set the column values for 'ourUpdatedIndexRow' to refer to a base table row and location provided by the caller.

pack-priv void
setRowHolder(TemporaryRowHolderImpl
the row holder
rowHolder
)

Set the row holder for this changer to use.

private void
setScan()

Position our index scan to 'ourIndexRow'.

pack-priv void
update(ExecRow
the old image of the base table row.
oldBaseRow
,
ExecRow
the new image of the base table row.
newBaseRow
,
RowLocation
the base table row's location.
baseRowLocation
)

Perform index maintenance to support an update of a base table row.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

activationback to summary
private final Activation activation
baseCCback to summary
private ConglomerateController baseCC
baseRowReadMapback to summary
private final FormatableBitSet baseRowReadMap
deferrableback to summary
private final boolean deferrable
deferredDuplicatesback to summary
private BackingStoreHashtable deferredDuplicates
indexCCback to summary
private ConglomerateController indexCC
indexCIDback to summary
private final long indexCID
indexDCOCIback to summary
private final DynamicCompiledOpenConglomInfo indexDCOCI
indexNameback to summary
private final String indexName
indexSCback to summary
private ScanController indexSC
indexSCOCIback to summary
private final StaticCompiledOpenConglomInfo indexSCOCI
irgback to summary
private final IndexRowGenerator irg
isolationLevelback to summary
private int isolationLevel
lccback to summary
private final LanguageConnectionContext lcc
lockModeback to summary
private final int lockMode
ourIndexRowback to summary
private ExecIndexRow ourIndexRow
ourUpdatedIndexRowback to summary
private ExecIndexRow ourUpdatedIndexRow
ownIndexSCback to summary
private boolean ownIndexSC
rowHolderback to summary
private TemporaryRowHolderImpl rowHolder
rowHolderPassedInback to summary
private boolean rowHolderPassedIn
tcback to summary
private final TransactionController tc
uniqueConstraintIdback to summary
private UUID uniqueConstraintId

Constructor Detail

IndexChangerback to summary
pack-priv 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:IndexRowGenerator

the IndexRowGenerator for the index.

indexCID:long

the conglomerate id for the index.

indexSCOCI:StaticCompiledOpenConglomInfo

the SCOCI for the indexes.

indexDCOCI:DynamicCompiledOpenConglomInfo

the DCOCI for the indexes.

baseCC:ConglomerateController

the ConglomerateController for the base table.

tc:TransactionController

The TransactionController

lockMode:int

The lock mode (granularity) to use

baseRowReadMap:FormatableBitSet

Map of columns read in. 1 based.

isolationLevel:int

Isolation level to use.

activation:Activation

Current activation

Exceptions
StandardException:
Thrown on error

Method Detail

closeback to summary
pack-priv void close() throws StandardException

Close this IndexChanger.

Exceptions
StandardException:
Thrown on error
closeIndexCCback to summary
private void closeIndexCC() throws StandardException

Close our index Conglomerate Controller

closeIndexSCback to summary
private void closeIndexSC() throws StandardException

Close our index ScanController.

deleteback to summary
pack-priv void delete(ExecRow baseRow, RowLocation baseRowLocation) throws StandardException

Perform index maintenance to support a delete of a base table row.

Parameters
baseRow:ExecRow

the base table row.

baseRowLocation:RowLocation

the base table row's location.

Exceptions
StandardException:
Thrown on error
doDeferredInsertback to summary
private void doDeferredInsert() throws StandardException

Insert a row into the temporary conglomerate

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

Exceptions
StandardException:
Thrown on error
doDeleteback to summary
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.

Exceptions
StandardException:
Thrown on error
doInsertback to summary
private void doInsert() throws StandardException

Insert a row into our indes.

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

Exceptions
StandardException:
Thrown on error
finishback to summary
pack-priv 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.

Exceptions
StandardException:
Thrown on error
getUniqueConstraintIdback to summary
private UUID getUniqueConstraintId() throws StandardException
indexRowChangedback to summary
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:boolean

Nothing.

Exceptions
StandardException:
Thrown on error
insertback to summary
pack-priv void insert(ExecRow newRow, RowLocation baseRowLocation) throws StandardException

Perform index maintenance to support an insert of a base table row.

Parameters
newRow:ExecRow

the base table row.

baseRowLocation:RowLocation

the base table row's location.

Exceptions
StandardException:
Thrown on error
insertAndCheckDupsback to summary
private void insertAndCheckDups(ExecIndexRow row) throws StandardException

Insert the given row into the given conglomerate and check for duplicate key error.

Parameters
row:ExecIndexRow

The row to insert

Exceptions
StandardException:
Thrown on duplicate key error unless we have a deferred constraint. In that index rows are saved for checking on commit.
insertForUpdateback to summary
pack-priv 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:ExecRow

the base table row.

baseRowLocation:RowLocation

the base table row's location.

Exceptions
StandardException:
Thrown on error
openback to summary
pack-priv void open() throws StandardException

Open this IndexChanger.

Exceptions
StandardException:
Thrown on error
openIndexCCback to summary
private ConglomerateController openIndexCC() throws StandardException

Open the ConglomerateController for this index if it isn't open yet.

Returns:ConglomerateController

The ConglomerateController for this index.

Exceptions
StandardException:
Thrown on duplicate key error
setBaseCCback to summary
pack-priv void setBaseCC(ConglomerateController baseCC)

Propagate the heap's ConglomerateController to this index changer.

Parameters
baseCC:ConglomerateController

The heap's ConglomerateController.

setOurIndexRowback to summary
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:ExecRow

a base table row.

baseRowLoc:RowLocation

baseRowLoc baseRow's location

Exceptions
StandardException:
Thrown on error
setOurUpdatedIndexRowback to summary
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:ExecRow

a base table row.

baseRowLoc:RowLocation

baseRowLoc baseRow's location

Exceptions
StandardException:
Thrown on error
setRowHolderback to summary
pack-priv 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:TemporaryRowHolderImpl

the row holder

setScanback to summary
private void setScan() throws StandardException

Position our index scan to 'ourIndexRow'.

This creates the scan the first time it is called.

Exceptions
StandardException:
Thrown on error
updateback to summary
pack-priv void update(ExecRow oldBaseRow, ExecRow newBaseRow, RowLocation baseRowLocation) throws StandardException

Perform index maintenance to support an update of a base table row.

Parameters
oldBaseRow:ExecRow

the old image of the base table row.

newBaseRow:ExecRow

the new image of the base table row.

baseRowLocation:RowLocation

the base table row's location.

Exceptions
StandardException:
Thrown on error