org.apache.derby.impl.sql.execute
Class RowChangerImpl

java.lang.Object
  extended by 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
private  Activation activation
           
private  ConglomerateController baseCC
           
private  RowLocation baseRowLocation
           
(package private)  FormatableBitSet baseRowReadList
           
private  int[] baseRowReadMap
           
(package private)  FormatableBitSet changedColumnBitSet
           
(package private)  int[] changedColumnIds
           
(package private)  boolean[] fixOnUpdate
           
(package private)  long heapConglom
           
(package private)  DynamicCompiledOpenConglomInfo heapDCOCI
           
(package private)  StaticCompiledOpenConglomInfo heapSCOCI
           
(package private)  long[] indexCIDS
           
(package private)  DynamicCompiledOpenConglomInfo[] indexDCOCIs
           
(package private)  java.lang.String[] indexNames
           
(package private)  StaticCompiledOpenConglomInfo[] indexSCOCIs
           
(package private)  IndexRowGenerator[] irgs
           
private  IndexSetChanger isc
           
(package private)  boolean isOpen
           
private  int[] partialChangedColumnIds
           
(package private)  TemporaryRowHolderImpl rowHolder
           
private  DataValueDescriptor[] sparseRowArray
           
(package private)  TransactionController tc
           
 
Constructor Summary
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
 void close()
          Close this RowChanger.
 void deleteRow(ExecRow baseRow, RowLocation baseRowLocation)
          Delete a row from the table and perform associated index maintenance.
 int findSelectedCol(int selectedCol)
          Return what column no in the input ExecRow (cf nextBaseRow argument to #updateRow) would correspond to selected column, if any.
 void finish()
          Finish processing the changes.
 ConglomerateController getHeapConglomerateController()
          Return the ConglomerateController from this RowChanger.
 void insertRow(ExecRow baseRow)
          Insert a row into the table and perform associated index maintenance.
 void open(int lockMode)
          Open this RowChanger.
 void open(int lockMode, boolean wait)
          Open this RowChanger.
 void openForUpdate(boolean[] fixOnUpdate, int lockMode, boolean wait)
          Open this RowChanger to avoid fixing indexes that do not change during update operations.
 void setIndexNames(java.lang.String[] indexNames)
          Sets the index names of the tables indices.
 void setRowHolder(TemporaryRowHolder rowHolder)
          Set the row holder for this changer to use.
private  int[] sortArray(int[] input)
           
 java.lang.String toString()
           
 void updateRow(ExecRow oldBaseRow, ExecRow newBaseRow, RowLocation baseRowLocation)
          Update a row in the table and perform associated index maintenance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 StandardException
Create a new RowChanger for performing update and delete operations based on partial before and after rows.

Parameters:
heapConglom - Conglomerate # for the heap
heapSCOCI - SCOCI for heap.
heapDCOCI - DCOCI for heap
irgs - 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 updates
tc - the transaction controller
baseRowReadList - 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:
setRowHolder in interface RowChanger
Parameters:
rowHolder - the TemporaryRowHolder

setIndexNames

public void setIndexNames(java.lang.String[] indexNames)
Description copied from interface: RowChanger
Sets the index names of the tables indices. Used for error reporting.

Specified by:
setIndexNames in interface RowChanger
Parameters:
indexNames - Names of all the indices on this table.
See Also:
RowChanger.setIndexNames(java.lang.String[])

open

public void open(int lockMode)
          throws StandardException
Open this RowChanger.

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

Specified by:
open in interface RowChanger
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 StandardException
Description copied from interface: RowChanger
Open this RowChanger.

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

Specified by:
open in interface RowChanger
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 StandardException
Open this RowChanger to avoid fixing indexes that do not change during update operations.

Specified by:
openForUpdate in interface RowChanger
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 void insertRow(ExecRow baseRow)
               throws StandardException
Insert a row into the table and perform associated index maintenance.

Specified by:
insertRow in interface RowChanger
Parameters:
baseRow - the row.
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:
deleteRow in interface RowChanger
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:
updateRow in interface RowChanger
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 StandardException
Finish processing the changes. This means applying the deferred inserts for updates to unique indexes.

Specified by:
finish in interface RowChanger
Throws:
StandardException - Thrown on error

close

public void close()
           throws StandardException
Close this RowChanger.

Specified by:
close in interface RowChanger
Throws:
StandardException - Thrown on error

getHeapConglomerateController

public ConglomerateController getHeapConglomerateController()
Description copied from interface: RowChanger
Return the ConglomerateController from this RowChanger. This is useful when copying properties from heap to temp conglomerate on insert/update/delete.

Specified by:
getHeapConglomerateController in interface RowChanger
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: RowChanger
Return what column no in the input ExecRow (cf nextBaseRow argument to #updateRow) would correspond to selected column, if any.

Specified by:
findSelectedCol in interface RowChanger
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:
toString in class java.lang.Object

Built on Thu 2011-03-10 11:54:14+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.