1 21 22 package org.apache.derby.impl.store.access.heap; 23 24 import org.apache.derby.iapi.reference.SQLState; 25 26 import org.apache.derby.iapi.services.io.FormatableBitSet; 27 28 import org.apache.derby.iapi.services.monitor.ModuleControl; 29 import org.apache.derby.iapi.services.monitor.ModuleSupportable; 30 import org.apache.derby.iapi.services.monitor.Monitor; 31 import org.apache.derby.iapi.services.sanity.SanityManager; 32 import org.apache.derby.iapi.services.io.FormatIdUtil; 33 import org.apache.derby.iapi.error.StandardException; 34 35 import org.apache.derby.iapi.store.access.conglomerate.Conglomerate; 36 import org.apache.derby.iapi.store.access.conglomerate.ConglomerateFactory; 37 import org.apache.derby.iapi.store.access.conglomerate.MethodFactory; 38 import org.apache.derby.iapi.store.access.conglomerate.TransactionManager; 39 40 import org.apache.derby.iapi.store.access.AccessFactory; 41 import org.apache.derby.iapi.store.access.ColumnOrdering; 42 import org.apache.derby.iapi.store.access.ConglomerateController; 43 import org.apache.derby.iapi.store.access.Qualifier; 44 45 import org.apache.derby.iapi.store.raw.ContainerHandle; 46 import org.apache.derby.iapi.store.raw.FetchDescriptor; 47 import org.apache.derby.iapi.store.raw.ContainerKey; 48 import org.apache.derby.iapi.store.raw.LockingPolicy; 49 import org.apache.derby.iapi.store.raw.Page; 50 import org.apache.derby.iapi.store.raw.RecordHandle; 51 import org.apache.derby.iapi.store.raw.Transaction; 52 53 import org.apache.derby.iapi.types.DataValueDescriptor; 54 55 import org.apache.derby.iapi.services.uuid.UUIDFactory; 56 57 import org.apache.derby.catalog.UUID; 58 59 import java.util.Properties ; 60 61 67 68 public class HeapConglomerateFactory implements ConglomerateFactory, ModuleControl, ModuleSupportable 69 { 70 71 private static final String IMPLEMENTATIONID = "heap"; 74 private static final String FORMATUUIDSTRING = "D2976090-D9F5-11d0-B54D-00A024BF8878"; 75 private UUID formatUUID; 76 77 80 81 85 public Properties defaultProperties() 86 { 87 return new Properties (); 89 } 90 91 98 public boolean supportsImplementation(String implementationId) 99 { 100 return implementationId.equals(IMPLEMENTATIONID); 101 } 102 103 109 public String primaryImplementationType() 110 { 111 return IMPLEMENTATIONID; 112 } 113 114 121 public boolean supportsFormat(UUID formatid) 122 { 123 return formatid.equals(formatUUID); 124 } 125 126 132 public UUID primaryFormat() 133 { 134 return formatUUID; 135 } 136 137 140 141 155 public int getConglomerateFactoryId() 156 { 157 return(ConglomerateFactory.HEAP_FACTORY_ID); 158 } 159 160 167 public Conglomerate createConglomerate( 168 TransactionManager xact_mgr, 169 int segment, 170 long input_containerid, 171 DataValueDescriptor[] template, 172 ColumnOrdering[] columnOrder, Properties properties, 174 int temporaryFlag) 175 throws StandardException 176 { 177 Heap heap = new Heap(); 179 heap.create( 180 xact_mgr.getRawStoreXact(), segment, input_containerid, 181 template, properties, temporaryFlag); 182 183 return heap; 184 } 185 186 207 public Conglomerate readConglomerate( 208 TransactionManager xact_mgr, 209 ContainerKey container_key) 210 throws StandardException 211 { 212 ContainerHandle container = null; 213 Page page = null; 214 DataValueDescriptor[] control_row = new DataValueDescriptor[1]; 215 216 try 217 { 218 container = 220 xact_mgr.getRawStoreXact().openContainer( 221 container_key, (LockingPolicy) null, 0); 222 223 if (container == null) 224 { 225 throw StandardException.newException( 226 SQLState.STORE_CONGLOMERATE_DOES_NOT_EXIST, 227 new Long (container_key.getContainerId())); 228 } 229 230 control_row[0] = new Heap(); 233 234 page = container.getPage(ContainerHandle.FIRST_PAGE_NUMBER); 235 236 RecordHandle rh = 237 page.fetchFromSlot( 238 (RecordHandle) null, 0, control_row, 239 (FetchDescriptor) null, 240 true); 241 242 if (SanityManager.DEBUG) 243 { 244 SanityManager.ASSERT(rh != null); 245 246 SanityManager.ASSERT(rh.getId() == 6); 249 } 250 } 251 finally 252 { 253 if (page != null) 254 page.unlatch(); 255 256 if (container != null) 257 container.close(); 258 } 259 260 return((Conglomerate) control_row[0]); 261 } 262 263 266 267 public boolean canSupport(Properties startParams) { 268 269 String impl = 270 startParams.getProperty("derby.access.Conglomerate.type"); 271 272 if (impl == null) 273 return false; 274 275 return supportsImplementation(impl); 276 } 277 278 public void boot(boolean create, Properties startParams) 279 throws StandardException 280 { 281 UUIDFactory uuidFactory = 283 Monitor.getMonitor().getUUIDFactory(); 284 285 formatUUID = uuidFactory.recreateUUID(FORMATUUIDSTRING); 287 } 288 289 public void stop() 290 { 291 } 292 293 296 297 public HeapConglomerateFactory() 298 { 299 } 300 } 301 302 | Popular Tags |