Class RowChangerImpl

java.lang.Object
org.apache.derby.impl.sql.execute.RowChangerImpl
All Implemented Interfaces:
RowChanger

class RowChangerImpl extends Object implements RowChanger
Perform row at a time DML operations of tables and maintain indexes.
  • Field Details

  • Constructor Details

    • 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 Details

    • 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(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:
    • 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 RowLocation insertRow(ExecRow baseRow, boolean getRL) throws StandardException
      Insert a row into the table and perform associated index maintenance.
      Specified by:
      insertRow in interface RowChanger
      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:
      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:
    • 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 String toString()
      Overrides:
      toString in class Object