Class IndexChanger

java.lang.Object
org.apache.derby.impl.sql.execute.IndexChanger

class IndexChanger extends Object
Perform Index maintenance associated with DML operations for a single index.
  • Field Details

  • Constructor Details

  • Method Details

    • setRowHolder

      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 - the row holder
    • setBaseCC

      void setBaseCC(ConglomerateController baseCC)
      Propagate the heap's ConglomerateController to this index changer.
      Parameters:
      baseCC - The heap's ConglomerateController.
    • setOurIndexRow

      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 - a base table row.
      baseRowLoc - baseRowLoc baseRow's location
      Throws:
      StandardException - Thrown on error
    • setOurUpdatedIndexRow

      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 - a base table row.
      baseRowLoc - baseRowLoc baseRow's location
      Throws:
      StandardException - Thrown on error
    • indexRowChanged

      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:
      Nothing.
      Throws:
      StandardException - Thrown on error
    • setScan

      private void setScan() throws StandardException
      Position our index scan to 'ourIndexRow'.

      This creates the scan the first time it is called.

      Throws:
      StandardException - Thrown on error
    • closeIndexCC

      private void closeIndexCC() throws StandardException
      Close our index Conglomerate Controller
      Throws:
      StandardException
    • closeIndexSC

      private void closeIndexSC() throws StandardException
      Close our index ScanController.
      Throws:
      StandardException
    • doDelete

      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.

      Throws:
      StandardException - Thrown on error
    • doInsert

      private void doInsert() throws StandardException
      Insert a row into our indes.

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

      Throws:
      StandardException - Thrown on error
    • doDeferredInsert

      private void doDeferredInsert() throws StandardException
      Insert a row into the temporary conglomerate

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

      Throws:
      StandardException - Thrown on error
    • getUniqueConstraintId

      private UUID getUniqueConstraintId() throws StandardException
      Throws:
      StandardException
    • insertAndCheckDups

      private void insertAndCheckDups(ExecIndexRow row) throws StandardException
      Insert the given row into the given conglomerate and check for duplicate key error.
      Parameters:
      row - The row to insert
      Throws:
      StandardException - Thrown on duplicate key error unless we have a deferred constraint. In that index rows are saved for checking on commit.
    • openIndexCC

      private ConglomerateController openIndexCC() throws StandardException
      Open the ConglomerateController for this index if it isn't open yet.
      Returns:
      The ConglomerateController for this index.
      Throws:
      StandardException - Thrown on duplicate key error
    • open

      void open() throws StandardException
      Open this IndexChanger.
      Throws:
      StandardException - Thrown on error
    • delete

      void delete(ExecRow baseRow, RowLocation baseRowLocation) throws StandardException
      Perform index maintenance to support a delete of a base table row.
      Parameters:
      baseRow - the base table row.
      baseRowLocation - the base table row's location.
      Throws:
      StandardException - Thrown on error
    • update

      void update(ExecRow oldBaseRow, ExecRow newBaseRow, RowLocation baseRowLocation) throws StandardException
      Perform index maintenance to support an update of a base table row.
      Parameters:
      oldBaseRow - the old image of the base table row.
      newBaseRow - the new image of the base table row.
      baseRowLocation - the base table row's location.
      Throws:
      StandardException - Thrown on error
    • insert

      void insert(ExecRow newRow, RowLocation baseRowLocation) throws StandardException
      Perform index maintenance to support an insert of a base table row.
      Parameters:
      newRow - the base table row.
      baseRowLocation - the base table row's location.
      Throws:
      StandardException - Thrown on error
    • insertForUpdate

      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 - the base table row.
      baseRowLocation - the base table row's location.
      Throws:
      StandardException - Thrown on error
    • finish

      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.
      Throws:
      StandardException - Thrown on error
    • close

      void close() throws StandardException
      Close this IndexChanger.
      Throws:
      StandardException - Thrown on error