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

pack-priv Class RowChangerImpl

extends Object
implements RowChanger
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.sql.execute.RowChanger
Imports
org.apache.derby.iapi.services.io.FormatableBitSet, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.sql.conn.LanguageConnectionContext, .StatementContext, org.apache.derby.iapi.sql.dictionary.IndexRowGenerator, org.apache.derby.iapi.sql.execute.ExecRow, .ExecutionContext, .RowChanger, .ExecutionFactory, .TemporaryRowHolder, org.apache.derby.iapi.sql.Activation, org.apache.derby.iapi.store.access.ConglomerateController, .DynamicCompiledOpenConglomInfo, .StaticCompiledOpenConglomInfo, .TransactionController, org.apache.derby.iapi.transaction.TransactionControl, org.apache.derby.iapi.types.DataValueDescriptor, .RowLocation, java.util.Vector

Perform row at a time DML operations of tables and maintain indexes.

Field Summary

Modifier and TypeField and Description
private final Activation
private ConglomerateController
private RowLocation
pack-priv FormatableBitSet
private int[]
pack-priv FormatableBitSet
pack-priv int[]
pack-priv boolean[]
pack-priv long
pack-priv DynamicCompiledOpenConglomInfo
pack-priv StaticCompiledOpenConglomInfo
pack-priv long[]
pack-priv DynamicCompiledOpenConglomInfo[]
pack-priv String[]
pack-priv StaticCompiledOpenConglomInfo[]
pack-priv IndexRowGenerator[]
private IndexSetChanger
pack-priv boolean
private int[]
pack-priv TemporaryRowHolderImpl
private DataValueDescriptor[]
pack-priv TransactionController

Constructor Summary

AccessConstructor and Description
public
RowChangerImpl(long
Conglomerate # for the heap
heapConglom
,
StaticCompiledOpenConglomInfo
SCOCI for heap.
heapSCOCI
,
DynamicCompiledOpenConglomInfo
DCOCI for heap
heapDCOCI
,
IndexRowGenerator[]
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.
irgs
,
long[]
the conglomerateids for the table's idexes. indexCIDS[ix] corresponds to the same index as irgs[ix].
indexCIDS
,
StaticCompiledOpenConglomInfo[]
the SCOCIs for the table's idexes. indexSCOCIs[ix] corresponds to the same index as irgs[ix].
indexSCOCIs
,
DynamicCompiledOpenConglomInfo[]
the DCOCIs for the table's idexes. indexDCOCIs[ix] corresponds to the same index as irgs[ix].
indexDCOCIs
,
int
Number of columns in partial write row.
numberOfColumns
,
int[]
array of 1 based ints indicating the columns to be updated. Only used for updates
changedColumnIdsInput
,
TransactionController
the transaction controller
tc
,
FormatableBitSet
bit set of columns read from base row. 1 based.
baseRowReadList
,
int[]
BaseRowReadMap[heapColId]->ReadRowColumnId. (0 based)
baseRowReadMap
,
Activation activation)

Create a new RowChanger for performing update and delete operations based on partial before and after rows.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements org.apache.derby.iapi.sql.execute.RowChanger.close.

Close this RowChanger.

public void
deleteRow(ExecRow
the row.
baseRow
,
RowLocation
the row's base conglomerate location
baseRowLocation
)

Implements org.apache.derby.iapi.sql.execute.RowChanger.deleteRow.

Delete a row from the table and perform associated index maintenance.

public int
findSelectedCol(int
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).
selectedCol
)

Implements org.apache.derby.iapi.sql.execute.RowChanger.findSelectedCol.

Return what column no in the input ExecRow (cf nextBaseRow argument to #updateRow) would correspond to selected column, if any.

public void
finish()

Implements org.apache.derby.iapi.sql.execute.RowChanger.finish.

Finish processing the changes.

public ConglomerateController
getHeapConglomerateController()

Implements org.apache.derby.iapi.sql.execute.RowChanger.getHeapConglomerateController.

Return the ConglomerateController from this RowChanger.

public RowLocation
insertRow(ExecRow
the row.
baseRow
,
boolean
return a row location of the inserted row
getRL
)

Implements org.apache.derby.iapi.sql.execute.RowChanger.insertRow.

Insert a row into the table and perform associated index maintenance.

public void
open(int
The lock mode to use (row or table, see TransactionController)
lockMode
)

Implements org.apache.derby.iapi.sql.execute.RowChanger.open.

Open this RowChanger.

public void
open(int
The lock mode to use (row or table, see TransactionController)
lockMode
,
boolean
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.
wait
)

Implements org.apache.derby.iapi.sql.execute.RowChanger.open.

Open this RowChanger.

public void
openForUpdate(boolean[]
fixOnUpdat[ix] == true ==> fix index 'ix' on an update operation.
fixOnUpdate
,
int
The lock mode to use (row or table, see TransactionController)
lockMode
,
boolean
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)
wait
)

Implements org.apache.derby.iapi.sql.execute.RowChanger.openForUpdate.

Open this RowChanger to avoid fixing indexes that do not change during update operations.

public void
setIndexNames(String[]
Names of all the indices on this table.
indexNames
)

Implements org.apache.derby.iapi.sql.execute.RowChanger.setIndexNames.

Sets the index names of the tables indices.

public void
setRowHolder(TemporaryRowHolder
the TemporaryRowHolder
rowHolder
)

Implements org.apache.derby.iapi.sql.execute.RowChanger.setRowHolder.

Set the row holder for this changer to use.

private int[]
sortArray(int[] input)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
updateRow(ExecRow
the old image of the row.
oldBaseRow
,
ExecRow
the new image of the row.
newBaseRow
,
RowLocation
the row's base conglomerate location
baseRowLocation
)

Implements org.apache.derby.iapi.sql.execute.RowChanger.updateRow.

Update a row in the table and perform associated index maintenance.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

activationback to summary
private final Activation activation
baseCCback to summary
private ConglomerateController baseCC
baseRowLocationback to summary
private RowLocation baseRowLocation
baseRowReadListback to summary
pack-priv FormatableBitSet baseRowReadList
baseRowReadMapback to summary
private int[] baseRowReadMap
changedColumnBitSetback to summary
pack-priv FormatableBitSet changedColumnBitSet
changedColumnIdsback to summary
pack-priv int[] changedColumnIds
fixOnUpdateback to summary
pack-priv boolean[] fixOnUpdate
heapConglomback to summary
pack-priv long heapConglom
heapDCOCIback to summary
pack-priv DynamicCompiledOpenConglomInfo heapDCOCI
heapSCOCIback to summary
pack-priv StaticCompiledOpenConglomInfo heapSCOCI
indexCIDSback to summary
pack-priv long[] indexCIDS
indexDCOCIsback to summary
pack-priv DynamicCompiledOpenConglomInfo[] indexDCOCIs
indexNamesback to summary
pack-priv String[] indexNames
indexSCOCIsback to summary
pack-priv StaticCompiledOpenConglomInfo[] indexSCOCIs
irgsback to summary
pack-priv IndexRowGenerator[] irgs
iscback to summary
private IndexSetChanger isc
isOpenback to summary
pack-priv boolean isOpen
partialChangedColumnIdsback to summary
private int[] partialChangedColumnIds
rowHolderback to summary
pack-priv TemporaryRowHolderImpl rowHolder
sparseRowArrayback to summary
private DataValueDescriptor[] sparseRowArray
tcback to summary
pack-priv TransactionController tc

Constructor Detail

RowChangerImplback to summary
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 StandardException

Create a new RowChanger for performing update and delete operations based on partial before and after rows.

Parameters
heapConglom:long

Conglomerate # for the heap

heapSCOCI:StaticCompiledOpenConglomInfo

SCOCI for heap.

heapDCOCI:DynamicCompiledOpenConglomInfo

DCOCI for heap

irgs:IndexRowGenerator[]

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:long[]

the conglomerateids for the table's idexes. indexCIDS[ix] corresponds to the same index as irgs[ix].

indexSCOCIs:StaticCompiledOpenConglomInfo[]

the SCOCIs for the table's idexes. indexSCOCIs[ix] corresponds to the same index as irgs[ix].

indexDCOCIs:DynamicCompiledOpenConglomInfo[]

the DCOCIs for the table's idexes. indexDCOCIs[ix] corresponds to the same index as irgs[ix].

numberOfColumns:int

Number of columns in partial write row.

changedColumnIdsInput:int[]

array of 1 based ints indicating the columns to be updated. Only used for updates

tc:TransactionController

the transaction controller

baseRowReadList:FormatableBitSet

bit set of columns read from base row. 1 based.

baseRowReadMap:int[]

BaseRowReadMap[heapColId]->ReadRowColumnId. (0 based)

Exceptions
StandardException:
Thrown on error

Method Detail

closeback to summary
public void close() throws StandardException

Implements org.apache.derby.iapi.sql.execute.RowChanger.close.

Close this RowChanger.

Exceptions
StandardException:
Thrown on error
deleteRowback to summary
public void deleteRow(ExecRow baseRow, RowLocation baseRowLocation) throws StandardException

Implements org.apache.derby.iapi.sql.execute.RowChanger.deleteRow.

Delete a row from the table and perform associated index maintenance.

Parameters
baseRow:ExecRow

the row.

baseRowLocation:RowLocation

the row's base conglomerate location

Exceptions
StandardException:
Thrown on error
findSelectedColback to summary
public int findSelectedCol(int selectedCol)

Implements org.apache.derby.iapi.sql.execute.RowChanger.findSelectedCol.

Doc from org.apache.derby.iapi.sql.execute.RowChanger.findSelectedCol.

Return what column no in the input ExecRow (cf nextBaseRow argument to #updateRow) would correspond to selected column, if any.

Parameters
selectedCol:int

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:int

column no, or -1 if not found or not a base column

finishback to summary
public void finish() throws StandardException

Implements org.apache.derby.iapi.sql.execute.RowChanger.finish.

Finish processing the changes. This means applying the deferred inserts for updates to unique indexes.

Exceptions
StandardException:
Thrown on error
getHeapConglomerateControllerback to summary
public ConglomerateController getHeapConglomerateController()

Implements org.apache.derby.iapi.sql.execute.RowChanger.getHeapConglomerateController.

Doc from org.apache.derby.iapi.sql.execute.RowChanger.getHeapConglomerateController.

Return the ConglomerateController from this RowChanger. This is useful when copying properties from heap to temp conglomerate on insert/update/delete.

Returns:ConglomerateController

The ConglomerateController from this RowChanger.

See Also
RowChanger#getHeapConglomerateController
insertRowback to summary
public RowLocation insertRow(ExecRow baseRow, boolean getRL) throws StandardException

Implements org.apache.derby.iapi.sql.execute.RowChanger.insertRow.

Insert a row into the table and perform associated index maintenance.

Parameters
baseRow:ExecRow

the row.

getRL:boolean

Doc from org.apache.derby.iapi.sql.execute.RowChanger.insertRow.

return a row location of the inserted row

Returns:RowLocation

Doc from org.apache.derby.iapi.sql.execute.RowChanger.insertRow.

row location if requested, else null.

Exceptions
StandardException:
Thrown on error
openback to summary
public void open(int lockMode) throws StandardException

Implements org.apache.derby.iapi.sql.execute.RowChanger.open.

Open this RowChanger.

Note to avoid the cost of fixing indexes that do not change during update operations use openForUpdate().

Parameters
lockMode:int

The lock mode to use (row or table, see TransactionController)

Exceptions
StandardException:
thrown on failure to convert
openback to summary
public void open(int lockMode, boolean wait) throws StandardException

Implements org.apache.derby.iapi.sql.execute.RowChanger.open.

Doc from org.apache.derby.iapi.sql.execute.RowChanger.open.

Open this RowChanger.

Note to avoid the cost of fixing indexes that do not change during update operations use openForUpdate().

Parameters
lockMode:int

The lock mode to use (row or table, see TransactionController)

wait:boolean

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.

Exceptions
StandardException:
thrown on failure to convert
openForUpdateback to summary
public void openForUpdate(boolean[] fixOnUpdate, int lockMode, boolean wait) throws StandardException

Implements org.apache.derby.iapi.sql.execute.RowChanger.openForUpdate.

Open this RowChanger to avoid fixing indexes that do not change during update operations.

Parameters
fixOnUpdate:boolean[]

fixOnUpdat[ix] == true ==> fix index 'ix' on an update operation.

lockMode:int

The lock mode to use (row or table, see TransactionController)

wait:boolean

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)

Exceptions
StandardException:
thrown on failure to convert
setIndexNamesback to summary
public void setIndexNames(String[] indexNames)

Implements org.apache.derby.iapi.sql.execute.RowChanger.setIndexNames.

Doc from org.apache.derby.iapi.sql.execute.RowChanger.setIndexNames.

Sets the index names of the tables indices. Used for error reporting.

Parameters
indexNames:String[]

Names of all the indices on this table.

See Also
RowChanger#setIndexNames
setRowHolderback to summary
public void setRowHolder(TemporaryRowHolder rowHolder)

Implements org.apache.derby.iapi.sql.execute.RowChanger.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:TemporaryRowHolder

the TemporaryRowHolder

sortArrayback to summary
private int[] sortArray(int[] input)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

updateRowback to summary
public void updateRow(ExecRow oldBaseRow, ExecRow newBaseRow, RowLocation baseRowLocation) throws StandardException

Implements org.apache.derby.iapi.sql.execute.RowChanger.updateRow.

Update a row in the table and perform associated index maintenance.

Parameters
oldBaseRow:ExecRow

the old image of the row.

newBaseRow:ExecRow

the new image of the row.

baseRowLocation:RowLocation

the row's base conglomerate location

Exceptions
StandardException:
Thrown on error