1 21 22 package org.apache.derby.impl.store.raw.data; 23 24 import org.apache.derby.impl.store.raw.data.PhysicalPageOperation; 25 import org.apache.derby.impl.store.raw.data.BasePage; 26 27 import org.apache.derby.iapi.services.io.FormatIdUtil; 28 import org.apache.derby.iapi.services.io.StoredFormatIds; 29 import org.apache.derby.iapi.services.sanity.SanityManager; 30 31 import org.apache.derby.iapi.error.StandardException; 32 import org.apache.derby.iapi.store.raw.ContainerHandle; 33 import org.apache.derby.iapi.store.raw.data.RawContainerHandle; 34 import org.apache.derby.iapi.store.raw.Transaction; 35 import org.apache.derby.iapi.store.raw.log.LogInstant; 36 37 import org.apache.derby.iapi.services.io.CompressedNumber; 38 39 import java.io.OutputStream ; 40 import java.io.ObjectOutput ; 41 import java.io.IOException ; 42 import org.apache.derby.iapi.services.io.LimitObjectInput; 43 import java.io.ObjectInput ; 44 45 46 public final class ChainAllocPageOperation extends PhysicalPageOperation 48 { 49 50 protected long newAllocPageNum; protected long newAllocPageOffset; 53 public ChainAllocPageOperation(AllocPage allocPage, long pageNumber, long pageOffset) 54 throws StandardException 55 { 56 super(allocPage); 57 58 newAllocPageNum = pageNumber; 59 newAllocPageOffset = pageOffset; 60 } 61 62 65 66 public ChainAllocPageOperation() { super(); } 68 69 public void writeExternal(ObjectOutput out) throws IOException 70 { 71 super.writeExternal(out); 72 CompressedNumber.writeLong(out, newAllocPageNum); 73 CompressedNumber.writeLong(out, newAllocPageOffset); 74 } 75 76 80 public void readExternal(ObjectInput in) 81 throws IOException , ClassNotFoundException 82 { 83 super.readExternal(in); 84 newAllocPageNum = CompressedNumber.readLong(in); 85 newAllocPageOffset = CompressedNumber.readLong(in); 86 } 87 88 91 public int getTypeFormatId() { 92 return StoredFormatIds.LOGOP_CHAIN_ALLOC_PAGE; 93 } 94 95 98 102 public final void doMe(Transaction tran, LogInstant instant, LimitObjectInput in) 103 throws StandardException 104 { 105 if (SanityManager.DEBUG) { 106 SanityManager.ASSERT(this.page instanceof AllocPage); 107 } 108 109 ((AllocPage)page).chainNextAllocPage(instant, newAllocPageNum, newAllocPageOffset); 110 } 111 112 115 116 122 public void undoMe(Transaction xact, BasePage undoPage, LogInstant CLRInstant, 123 LimitObjectInput in) 124 throws StandardException 125 { 126 if (SanityManager.DEBUG) { 127 SanityManager.ASSERT(undoPage != null, "undo Page null"); 128 SanityManager.ASSERT(undoPage instanceof AllocPage, 129 "undo Page is not an allocPage"); 130 } 131 132 ((AllocPage)undoPage).chainNextAllocPage(CLRInstant, 133 ContainerHandle.INVALID_PAGE_NUMBER, 134 0 ); 135 } 136 137 140 public void restoreMe(Transaction xact, BasePage undoPage, LogInstant CLRinstant, LimitObjectInput in) 141 { 142 if (SanityManager.DEBUG) 145 SanityManager.THROWASSERT("cannot call restoreMe on BI_ChainAllocPageOperation"); 146 } 147 148 149 150 public String toString() 151 { 152 if (SanityManager.DEBUG) 153 { 154 String str = super.toString(); 155 str += " Chain new alloc page number " + newAllocPageNum + " at " + 156 newAllocPageOffset + " to " + getPageId(); 157 return str; 158 } 159 else 160 return null; 161 } 162 163 } 164 165 | Popular Tags |