1 21 22 package org.apache.derby.impl.store.raw.data; 23 24 import org.apache.derby.impl.store.raw.data.PageActions; 25 import org.apache.derby.impl.store.raw.data.BasePage; 26 27 import org.apache.derby.iapi.services.io.FormatIdUtil; 28 29 import org.apache.derby.iapi.store.access.conglomerate.LogicalUndo; 30 31 import org.apache.derby.iapi.store.raw.xact.RawTransaction; 32 import org.apache.derby.iapi.store.raw.RecordHandle; 33 import org.apache.derby.iapi.store.raw.Loggable; 34 import org.apache.derby.iapi.store.raw.log.LogInstant; 35 36 import org.apache.derby.iapi.error.StandardException; 37 import org.apache.derby.iapi.types.DataValueDescriptor; 38 39 import org.apache.derby.iapi.services.sanity.SanityManager; 40 import org.apache.derby.iapi.services.io.FormatableBitSet; 41 import org.apache.derby.iapi.services.io.DynamicByteArrayOutputStream; 42 import org.apache.derby.iapi.services.io.DynamicByteArrayOutputStream; 43 44 import java.io.IOException ; 45 46 47 48 public class LoggableActions implements PageActions { 49 50 51 public void actionDelete( 52 RawTransaction t, 53 BasePage page, 54 int slot, 55 int recordId, 56 boolean delete, 57 LogicalUndo undo) 58 throws StandardException 59 { 60 61 DeleteOperation lop = 62 new DeleteOperation(t, page, slot, recordId, delete, undo); 63 64 doAction(t, page, lop); 65 } 66 67 public int actionUpdate( 68 RawTransaction t, 69 BasePage page, 70 int slot, 71 int recordId, 72 Object [] row, 73 FormatableBitSet validColumns, 74 int realStartColumn, 75 DynamicByteArrayOutputStream logBuffer, 76 int realSpaceOnPage, 77 RecordHandle headRowHandle) 78 throws StandardException 79 { 80 UpdateOperation lop = 81 new UpdateOperation(t, page, slot, recordId, row, validColumns, 82 realStartColumn, logBuffer, 83 realSpaceOnPage, headRowHandle); 84 85 doAction(t, page, lop); 86 87 return lop.getNextStartColumn(); 88 } 89 90 public void actionPurge( 91 RawTransaction t, 92 BasePage page, 93 int slot, 94 int num_rows, 95 int[] recordIds, 96 boolean logData) 97 throws StandardException 98 { 99 PurgeOperation lop = 100 new PurgeOperation(t, page, slot, num_rows, recordIds, logData); 101 102 doAction(t, page, lop); 103 } 104 105 public void actionUpdateField( 106 RawTransaction t, 107 BasePage page, 108 int slot, 109 int recordId, 110 int fieldId, 111 Object newValue, 112 LogicalUndo undo) 113 throws StandardException 114 { 115 UpdateFieldOperation lop = 116 new UpdateFieldOperation( 117 t, page, slot, recordId, fieldId, newValue, undo); 118 119 doAction(t, page, lop); 120 } 121 122 public int actionInsert( 123 RawTransaction t, 124 BasePage page, 125 int slot, 126 int recordId, 127 Object [] row, 128 FormatableBitSet validColumns, 129 LogicalUndo undo, 130 byte insertFlag, 131 int startColumn, 132 boolean isLongColumn, 133 int realStartColumn, 134 DynamicByteArrayOutputStream logBuffer, 135 int realSpaceOnPage, 136 int overflowThreshold) 137 throws StandardException 138 { 139 InsertOperation lop = new InsertOperation(t, page, slot, recordId, 140 row, validColumns, undo, insertFlag, startColumn, isLongColumn, 141 realStartColumn, logBuffer, realSpaceOnPage, overflowThreshold); 142 143 doAction(t, page, lop); 144 return (lop.getNextStartColumn()); 145 146 } 147 148 public void actionCopyRows( 149 RawTransaction t, 150 BasePage destPage, 151 BasePage srcPage, 152 int srcSlot, 153 int numRows, 154 int destSlot, 155 int[] recordIds) 156 throws StandardException 157 { 158 159 CopyRowsOperation lop = 160 new CopyRowsOperation( 161 t, destPage, srcPage,srcSlot, numRows, destSlot, recordIds); 162 163 doAction(t, destPage, lop); 164 } 165 166 public void actionInvalidatePage(RawTransaction t, BasePage page) 167 throws StandardException 168 { 169 170 InvalidatePageOperation lop = new InvalidatePageOperation(page); 171 doAction(t, page, lop); 172 } 173 174 public void actionInitPage( 175 RawTransaction t, 176 BasePage page, 177 int initFlag, 178 int pageFormatId, 179 long pageOffset) 180 throws StandardException 181 { 182 InitPageOperation lop = 183 new InitPageOperation(page, initFlag, pageFormatId, pageOffset); 184 185 doAction(t, page, lop); 186 } 187 188 public void actionShrinkReservedSpace( 189 RawTransaction t, 190 BasePage page, 191 int slot, 192 int recordId, 193 int newValue, 194 int oldValue) 195 throws StandardException 196 { 197 198 SetReservedSpaceOperation lop = 199 new SetReservedSpaceOperation( 200 page, slot, recordId, newValue, oldValue); 201 202 doAction(t, page, lop); 203 } 204 205 private void doAction(RawTransaction t, BasePage page, Loggable lop) 206 throws StandardException 207 { 208 long oldversion = 0; LogInstant oldLogInstant = null; if (SanityManager.DEBUG) 211 { 212 oldLogInstant = page.getLastLogInstant(); 213 oldversion = page.getPageVersion(); 214 } 215 216 page.preDirty(); 220 221 t.logAndDo(lop); 222 223 if (SanityManager.DEBUG) { 224 if (oldLogInstant != null && page.getLastLogInstant() != null && 227 ! oldLogInstant.lessThan(page.getLastLogInstant())) 228 SanityManager.THROWASSERT( 229 "old log instant = " + oldLogInstant + 230 " lastlog = " + page.getLastLogInstant() ); 231 232 SanityManager.ASSERT( 233 oldversion == ((PageBasicOperation)lop).getPageVersion()); 234 SanityManager.ASSERT(page.getPageVersion() > oldversion); 235 } 236 237 } 238 239 } 240 | Popular Tags |