--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.impl.store.raw.data.PhysicalPageOperation\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to you under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.store.raw.data;\r
+\r
+import org.apache.derby.impl.store.raw.data.BasePage;\r
+\r
+import org.apache.derby.iapi.store.raw.Compensation;\r
+\r
+import org.apache.derby.iapi.store.raw.log.LogInstant;\r
+\r
+import org.apache.derby.iapi.store.raw.Transaction;\r
+import org.apache.derby.iapi.store.raw.Undoable;\r
+\r
+import org.apache.derby.iapi.error.StandardException;\r
+\r
+import java.io.InputStream;\r
+import java.io.ObjectInput;\r
+import java.io.IOException;\r
+import org.apache.derby.iapi.services.io.LimitObjectInput;\r
+\r
+/**\r
+ An abstract class that is used for physical log operation. A physical log\r
+ operation is one where the undo of the operation must be applied to the\r
+ same page as the original operation, and the undo operation must store the\r
+ byte image of the row(s) changed to its before image. (If a logical page\r
+ operation happened to the page or if another transaction altered other rows\r
+ on the page, the undo of this operation will only restore the before image\r
+ of the row(s) affected).\r
+\r
+ <PRE>\r
+ @format_id no format id, an abstract class.\r
+ @purpose provide methods for physical undo\r
+ @upgrade\r
+ @disk_layout\r
+ PageBasicOperation the super class\r
+ @end_format\r
+ </PRE>\r
+*/\r
+\r
+public abstract class PhysicalPageOperation extends PageBasicOperation implements Undoable\r
+{\r
+ protected PhysicalPageOperation(BasePage page)\r
+ {\r
+ super(page);\r
+ }\r
+\r
+ /*\r
+ * Formatable methods\r
+ */\r
+\r
+ // no-arg constructor, required by Formatable \r
+ public PhysicalPageOperation() { super(); }\r
+\r
+ // no fields, therefore no writeExternal or readExternal\r
+\r
+ /**\r
+ Undoable method\r
+ */\r
+\r
+ /** \r
+ Generate a Compensation (PageUndoOperation) that will rollback the\r
+ changes of this page operation. If this Page operation cannot or need not\r
+ be rolled back (redo only), overwrite this function to return null.\r
+\r
+ <P><B>Note</B><BR> For operation that needs logical undo, use\r
+ LogicalUndoOperation instead</B> This implementation just finds\r
+ the same page that the PageOperation was applied on - i.e., only works\r
+ for undo on the same page. \r
+\r
+ <P>During recovery redo, the logging system is page oriented and will use\r
+ the pageID stored in the PageUndoOperation to find the page. The\r
+ page will be latched and released using the default findpage and\r
+ releaseResource - this.releaseResource() will still be called so it has\r
+ to know not to release any resource it did not acquire.\r
+\r
+ @param xact the transaction doing the compensating\r
+ @param in optional input\r
+\r
+ @return the compensation operation that will rollback this change \r
+\r
+ @exception StandardException Standard Derby policy.\r
+\r
+ @see PageBasicOperation\r
+ @see Undoable#generateUndo\r
+ \r
+ */\r
+ public Compensation generateUndo(Transaction xact, LimitObjectInput in)\r
+ throws StandardException\r
+ {\r
+ // findpage will have the page latched.\r
+ // CompensationOperation.doMe must call this.releaseResource the page\r
+ // when it is done \r
+ BasePage undoPage = findpage(xact);\r
+\r
+ // Needs to pre-dirty this page so that if a checkpoint is taken any\r
+ // time after the CLR is sent to the log stream, it will wait for the\r
+ // actual undo to happen on the page. We need this to preserve the\r
+ // integrity of the redoLWM.\r
+ undoPage.preDirty();\r
+\r
+ return new PhysicalUndoOperation(undoPage, this);\r
+ }\r
+\r
+\r
+ /**\r
+ Undo the change indicated by this log operation and optional data.\r
+ The page the undo should apply to is the latched undoPage, the\r
+ recordId is the same as the roll forward operation. \r
+ \r
+ <BR><B>In this RawStore implementation, should only only be called via\r
+ CompOp.doMe</B>.\r
+\r
+ <P> The available() method of in indicates how much data can be read, i.e.\r
+ how much was originally written.\r
+\r
+ @param xact the Transaction doing the rollback\r
+ @param undoPage the page to rollback changes on\r
+ @param CLRinstant the log instant of this (PageUndo) operation\r
+ @param in optional data for the rollback operation\r
+\r
+ @exception IOException Can be thrown by any of the methods of ObjectInput.\r
+ @exception StandardException Standard Derby policy. \r
+ */\r
+ abstract public void undoMe(Transaction xact, BasePage undoPage,\r
+ LogInstant CLRinstant, LimitObjectInput in) \r
+ throws StandardException, IOException;\r
+\r
+\r
+}\r
+\r