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 52 53 public final class CompressSpacePageOperation extends PhysicalPageOperation 54 { 55 59 60 67 protected int newHighestPage; 68 69 74 protected int num_pages_truncated; 75 76 80 public CompressSpacePageOperation( 81 AllocPage allocPage, 82 int highest_page, 83 int num_truncated) 84 throws StandardException 85 { 86 super(allocPage); 87 88 newHighestPage = highest_page; 89 num_pages_truncated = num_truncated; 90 } 91 92 96 97 public CompressSpacePageOperation() { super(); } 99 100 public void writeExternal(ObjectOutput out) throws IOException 101 { 102 super.writeExternal(out); 103 CompressedNumber.writeInt(out, newHighestPage); 104 CompressedNumber.writeInt(out, num_pages_truncated); 105 } 106 107 111 public void readExternal(ObjectInput in) 112 throws IOException , ClassNotFoundException 113 { 114 super.readExternal(in); 115 newHighestPage = CompressedNumber.readInt(in); 116 num_pages_truncated = CompressedNumber.readInt(in); 117 } 118 119 122 public int getTypeFormatId() { 123 return StoredFormatIds.LOGOP_COMPRESS_SPACE; 124 } 125 126 130 131 144 public final void doMe( 145 Transaction tran, 146 LogInstant instant, 147 LimitObjectInput in) 148 throws StandardException 149 { 150 if (SanityManager.DEBUG) 151 { 152 SanityManager.ASSERT(this.page instanceof AllocPage); 153 } 154 155 ((AllocPage)page).compressSpace( 156 instant, newHighestPage, num_pages_truncated); 157 } 158 159 163 164 171 public void undoMe( 172 Transaction xact, 173 BasePage undoPage, 174 LogInstant CLRInstant, 175 LimitObjectInput in) 176 throws StandardException 177 { 178 if (SanityManager.DEBUG) 179 { 180 SanityManager.ASSERT(undoPage != null, "undo Page null"); 181 SanityManager.ASSERT( 182 undoPage instanceof AllocPage, 183 "undo Page is not an allocPage"); 184 } 185 186 ((AllocPage)undoPage).undoCompressSpace( 187 CLRInstant, newHighestPage, num_pages_truncated); 188 } 189 190 193 public void restoreMe( 194 Transaction xact, 195 BasePage undoPage, 196 LogInstant CLRinstant, 197 LimitObjectInput in) 198 { 199 if (SanityManager.DEBUG) 202 SanityManager.THROWASSERT( 203 "cannot call restoreMe on CompressSpaceOperation."); 204 } 205 206 207 208 public String toString() 209 { 210 if (SanityManager.DEBUG) 211 { 212 String str = super.toString(); 213 str += " CompressSpaceOperation: " + 214 "newHighestPage = " + newHighestPage + 215 ";num_pages_truncated = " + num_pages_truncated + 216 " to " + getPageId(); 217 218 return str; 219 } 220 else 221 return null; 222 } 223 } 224 | Popular Tags |