Class RowChangerImpl
- java.lang.Object
-
- org.apache.derby.impl.sql.execute.RowChangerImpl
-
- All Implemented Interfaces:
RowChanger
class RowChangerImpl extends java.lang.Object implements RowChanger
Perform row at a time DML operations of tables and maintain indexes.
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description RowChangerImpl(long heapConglom, StaticCompiledOpenConglomInfo heapSCOCI, DynamicCompiledOpenConglomInfo heapDCOCI, IndexRowGenerator[] irgs, long[] indexCIDS, StaticCompiledOpenConglomInfo[] indexSCOCIs, DynamicCompiledOpenConglomInfo[] indexDCOCIs, int numberOfColumns, int[] changedColumnIdsInput, TransactionController tc, FormatableBitSet baseRowReadList, int[] baseRowReadMap, Activation activation)Create a new RowChanger for performing update and delete operations based on partial before and after rows.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close this RowChanger.voiddeleteRow(ExecRow baseRow, RowLocation baseRowLocation)Delete a row from the table and perform associated index maintenance.intfindSelectedCol(int selectedCol)Return what column no in the input ExecRow (cf nextBaseRow argument to #updateRow) would correspond to selected column, if any.voidfinish()Finish processing the changes.ConglomerateControllergetHeapConglomerateController()Return the ConglomerateController from this RowChanger.RowLocationinsertRow(ExecRow baseRow, boolean getRL)Insert a row into the table and perform associated index maintenance.voidopen(int lockMode)Open this RowChanger.voidopen(int lockMode, boolean wait)Open this RowChanger.voidopenForUpdate(boolean[] fixOnUpdate, int lockMode, boolean wait)Open this RowChanger to avoid fixing indexes that do not change during update operations.voidsetIndexNames(java.lang.String[] indexNames)Sets the index names of the tables indices.voidsetRowHolder(TemporaryRowHolder rowHolder)Set the row holder for this changer to use.private int[]sortArray(int[] input)java.lang.StringtoString()voidupdateRow(ExecRow oldBaseRow, ExecRow newBaseRow, RowLocation baseRowLocation)Update a row in the table and perform associated index maintenance.
-
-
-
Field Detail
-
isOpen
boolean isOpen
-
fixOnUpdate
boolean[] fixOnUpdate
-
heapConglom
long heapConglom
-
heapDCOCI
DynamicCompiledOpenConglomInfo heapDCOCI
-
heapSCOCI
StaticCompiledOpenConglomInfo heapSCOCI
-
indexCIDS
long[] indexCIDS
-
indexDCOCIs
DynamicCompiledOpenConglomInfo[] indexDCOCIs
-
indexSCOCIs
StaticCompiledOpenConglomInfo[] indexSCOCIs
-
irgs
IndexRowGenerator[] irgs
-
activation
private final Activation activation
-
tc
TransactionController tc
-
changedColumnBitSet
FormatableBitSet changedColumnBitSet
-
baseRowReadList
FormatableBitSet baseRowReadList
-
baseRowReadMap
private int[] baseRowReadMap
-
changedColumnIds
int[] changedColumnIds
-
rowHolder
TemporaryRowHolderImpl rowHolder
-
indexNames
java.lang.String[] indexNames
-
baseCC
private ConglomerateController baseCC
-
baseRowLocation
private RowLocation baseRowLocation
-
isc
private IndexSetChanger isc
-
sparseRowArray
private DataValueDescriptor[] sparseRowArray
-
partialChangedColumnIds
private int[] partialChangedColumnIds
-
-
Constructor Detail
-
RowChangerImpl
public RowChangerImpl(long heapConglom, StaticCompiledOpenConglomInfo heapSCOCI, DynamicCompiledOpenConglomInfo heapDCOCI, IndexRowGenerator[] irgs, long[] indexCIDS, StaticCompiledOpenConglomInfo[] indexSCOCIs, DynamicCompiledOpenConglomInfo[] indexDCOCIs, int numberOfColumns, int[] changedColumnIdsInput, TransactionController tc, FormatableBitSet baseRowReadList, int[] baseRowReadMap, Activation activation) throws StandardExceptionCreate a new RowChanger for performing update and delete operations based on partial before and after rows.- Parameters:
heapConglom- Conglomerate # for the heapheapSCOCI- SCOCI for heap.heapDCOCI- DCOCI for heapirgs- the IndexRowGenerators for the table's indexes. We use positions in this array as local id's for indexes. To support updates, only indexes that change need be included.indexCIDS- the conglomerateids for the table's idexes. indexCIDS[ix] corresponds to the same index as irgs[ix].indexSCOCIs- the SCOCIs for the table's idexes. indexSCOCIs[ix] corresponds to the same index as irgs[ix].indexDCOCIs- the DCOCIs for the table's idexes. indexDCOCIs[ix] corresponds to the same index as irgs[ix].numberOfColumns- Number of columns in partial write row.changedColumnIdsInput- array of 1 based ints indicating the columns to be updated. Only used for updatestc- the transaction controllerbaseRowReadList- bit set of columns read from base row. 1 based.baseRowReadMap- BaseRowReadMap[heapColId]->ReadRowColumnId. (0 based)- Throws:
StandardException- Thrown on error
-
-
Method Detail
-
setRowHolder
public void setRowHolder(TemporaryRowHolder 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.- Specified by:
setRowHolderin interfaceRowChanger- Parameters:
rowHolder- the TemporaryRowHolder
-
setIndexNames
public void setIndexNames(java.lang.String[] indexNames)
Description copied from interface:RowChangerSets the index names of the tables indices. Used for error reporting.- Specified by:
setIndexNamesin interfaceRowChanger- Parameters:
indexNames- Names of all the indices on this table.- See Also:
RowChanger.setIndexNames(java.lang.String[])
-
open
public void open(int lockMode) throws StandardExceptionOpen this RowChanger.Note to avoid the cost of fixing indexes that do not change during update operations use openForUpdate().
- Specified by:
openin interfaceRowChanger- Parameters:
lockMode- The lock mode to use (row or table, see TransactionController)- Throws:
StandardException- thrown on failure to convert
-
open
public void open(int lockMode, boolean wait) throws StandardExceptionDescription copied from interface:RowChangerOpen this RowChanger.Note to avoid the cost of fixing indexes that do not change during update operations use openForUpdate().
- Specified by:
openin interfaceRowChanger- Parameters:
lockMode- The lock mode to use (row or table, see TransactionController)wait- If true, then the caller wants to wait for locks. False will be when we using a nested user xaction - we want to timeout right away if the parent holds the lock.- Throws:
StandardException- thrown on failure to convert
-
openForUpdate
public void openForUpdate(boolean[] fixOnUpdate, int lockMode, boolean wait) throws StandardExceptionOpen this RowChanger to avoid fixing indexes that do not change during update operations.- Specified by:
openForUpdatein interfaceRowChanger- Parameters:
fixOnUpdate- fixOnUpdat[ix] == true ==> fix index 'ix' on an update operation.lockMode- The lock mode to use (row or table, see TransactionController)wait- If true, then the caller wants to wait for locks. False will be when we using a nested user xaction - we want to timeout right away if the parent holds the lock. (bug 4821)- Throws:
StandardException- thrown on failure to convert
-
insertRow
public RowLocation insertRow(ExecRow baseRow, boolean getRL) throws StandardException
Insert a row into the table and perform associated index maintenance.- Specified by:
insertRowin interfaceRowChanger- Parameters:
baseRow- the row.getRL- return a row location of the inserted row- Returns:
- row location if requested, else
null. - Throws:
StandardException- Thrown on error
-
deleteRow
public void deleteRow(ExecRow baseRow, RowLocation baseRowLocation) throws StandardException
Delete a row from the table and perform associated index maintenance.- Specified by:
deleteRowin interfaceRowChanger- Parameters:
baseRow- the row.baseRowLocation- the row's base conglomerate location- Throws:
StandardException- Thrown on error
-
updateRow
public void updateRow(ExecRow oldBaseRow, ExecRow newBaseRow, RowLocation baseRowLocation) throws StandardException
Update a row in the table and perform associated index maintenance.- Specified by:
updateRowin interfaceRowChanger- Parameters:
oldBaseRow- the old image of the row.newBaseRow- the new image of the row.baseRowLocation- the row's base conglomerate location- Throws:
StandardException- Thrown on error
-
finish
public void finish() throws StandardExceptionFinish processing the changes. This means applying the deferred inserts for updates to unique indexes.- Specified by:
finishin interfaceRowChanger- Throws:
StandardException- Thrown on error
-
close
public void close() throws StandardExceptionClose this RowChanger.- Specified by:
closein interfaceRowChanger- Throws:
StandardException- Thrown on error
-
getHeapConglomerateController
public ConglomerateController getHeapConglomerateController()
Description copied from interface:RowChangerReturn the ConglomerateController from this RowChanger. This is useful when copying properties from heap to temp conglomerate on insert/update/delete.- Specified by:
getHeapConglomerateControllerin interfaceRowChanger- Returns:
- The ConglomerateController from this RowChanger.
- See Also:
RowChanger.getHeapConglomerateController()
-
sortArray
private int[] sortArray(int[] input)
-
findSelectedCol
public int findSelectedCol(int selectedCol)
Description copied from interface:RowChangerReturn what column no in the input ExecRow (cf nextBaseRow argument to #updateRow) would correspond to selected column, if any.- Specified by:
findSelectedColin interfaceRowChanger- Parameters:
selectedCol- the column number in the base table of a selected column or -1 (if selected column is not a base table column, e.g. i+4).- Returns:
- column no, or -1 if not found or not a base column
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-