Class LogicalPageOperation

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable, Formatable, TypedFormat, Loggable, LogicalUndoable, RePreparable, Undoable
    Direct Known Subclasses:
    DeleteOperation, InsertOperation, UpdateFieldOperation

    abstract class LogicalPageOperation
    extends PageBasicOperation
    implements LogicalUndoable
    An abstract class that is used for logical log operation. A logical log operation is one where the undo of the operation may be applied to a different page than the original operation.
    Format IDno format id, an abstract class.
    Purpose
    provide methods for logical undo
    Upgrade
    Disk LayoutPageBasicOperation the super class recordId(CompressedInt) the recordId this operation affects undo(LogicalUndo) the piece of code that can figure out which page the row has moved into OptionalData none
    • Field Detail

      • recordId

        protected int recordId
    • Constructor Detail

      • LogicalPageOperation

        public LogicalPageOperation()
      • LogicalPageOperation

        LogicalPageOperation​(BasePage page,
                             LogicalUndo undo,
                             int recordId)
    • Method Detail

      • writeExternal

        public void writeExternal​(java.io.ObjectOutput out)
                           throws java.io.IOException
        Specified by:
        writeExternal in interface java.io.Externalizable
        Overrides:
        writeExternal in class PageBasicOperation
        Throws:
        java.io.IOException
      • readExternal

        public void readExternal​(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Read this in
        Specified by:
        readExternal in interface java.io.Externalizable
        Overrides:
        readExternal in class PageBasicOperation
        Throws:
        java.io.IOException - error reading from log stream
        java.lang.ClassNotFoundException - log stream corrupted
      • generateUndo

        public Compensation generateUndo​(Transaction xact,
                                         LimitObjectInput in)
                                  throws StandardException,
                                         java.io.IOException
        Generate a Compensation (PageUndoOperation) that will rollback the changes of this page operation. If this Page operation cannot or need not be rolled back (redo only), overwrite this function to return null.
        Specified by:
        generateUndo in interface Undoable
        Parameters:
        xact - the transaction doing the rollback
        Returns:
        the compensation operation that will rollback this change, or null if nothing to undo.
        Throws:
        StandardException - Standard Derby policy.
        java.io.IOException - Method may read from ObjectInput
        See Also:
        LogicalUndo
      • resetRecordHandle

        public void resetRecordHandle​(RecordHandle rh)
        After the logical undo logic figures out where the real record that needs roll back is, reset this log operation to refer to that record
        Specified by:
        resetRecordHandle in interface LogicalUndoable
        Parameters:
        rh - the RecordHandle that represents the row's new location
      • getRecordHandle

        public RecordHandle getRecordHandle()
        Return the record handle that correspond to the record that was changed during roll forward. This is used as a hint by logical undo as a good place to look for the record to apply the roll back.
        Specified by:
        getRecordHandle in interface LogicalUndoable
      • findLogicalPage

        private BasePage findLogicalPage​(Transaction xact,
                                         LogicalUndo undo,
                                         LimitObjectInput in)
                                  throws StandardException,
                                         java.io.IOException
        Find the page that the rollback operation should be applied to.

        The actual logical log operation is expected to implement Undoable.generateUndo. This utility function findLogicalPage is provided for the common case scenario of using a LogicalUndo interface to find the undo page. The subclass that implements Undoable.generateUndo can use this function to find the logical page with its LogicalUndo callback function. This method can be used with the default releaseResource().

        During recovery redo, the logging system is page oriented and will use the pageID stored in the PageUndoOperation to find the page. The page will be latched and released using the default findpage and releaseResource - this.releaseResource() will still be called so it has to know not to release any resource it did not acquire.

        Parameters:
        xact - the transaction doing the compensating
        in - optional input
        Returns:
        the compensation operation that will rollback this change
        Throws:
        StandardException - Standard Derby error policy
        java.io.IOException - Method may read from ObjectInput
        See Also:
        PageBasicOperation, Undoable.generateUndo(org.apache.derby.iapi.store.raw.Transaction, org.apache.derby.iapi.services.io.LimitObjectInput), Loggable.releaseResource(org.apache.derby.iapi.store.raw.Transaction)
      • undoMe

        public abstract void undoMe​(Transaction xact,
                                    BasePage undoPage,
                                    int undoRecordId,
                                    LogInstant CLRinstant,
                                    LimitObjectInput in)
                             throws StandardException,
                                    java.io.IOException
        Undo the change indicated by this log operation and optional data. The undoPage and undoRecordId is the page, record the undo should apply to. The undoRecorId differs from the roll forward recordId if the undoPage differs from the page the roll forward operation was applied to, in other words, the record moved to another page and the recordId changed.
        A logical operation can at most deal with 1 record.

        The available() method of in indicates how much data can be read, i.e. how much was originally written.
        In this RawStore implementation, should only only be called via CompOp.doMe.

        Parameters:
        xact - the Transaction doing the rollback
        undoPage - the page to rollback changes on
        undoRecordId - the recordId to rollback changes on
        CLRinstant - the log instant of this (PageUndo) operation
        in - optional data for the rollback operation
        Throws:
        java.io.IOException - Can be thrown by any of the methods of ObjectInput.
        StandardException - Standard Derby policy.