1 21 22 package org.apache.derby.impl.store.access.btree.index; 23 24 import java.util.Properties ; 25 26 import org.apache.derby.iapi.reference.SQLState; 27 28 import org.apache.derby.iapi.services.monitor.ModuleControl; 29 import org.apache.derby.iapi.services.monitor.Monitor; 30 import org.apache.derby.iapi.services.property.PropertyUtil; 31 import org.apache.derby.iapi.services.sanity.SanityManager; 32 import org.apache.derby.iapi.services.io.FormatIdUtil; 33 34 import org.apache.derby.catalog.UUID; 35 import org.apache.derby.iapi.services.uuid.UUIDFactory; 36 import org.apache.derby.iapi.error.StandardException; 37 import org.apache.derby.iapi.store.access.conglomerate.Conglomerate; 38 import org.apache.derby.iapi.store.access.conglomerate.ConglomerateFactory; 39 import org.apache.derby.iapi.store.access.conglomerate.LogicalUndo; 40 import org.apache.derby.iapi.store.access.conglomerate.TransactionManager; 41 import org.apache.derby.iapi.store.access.AccessFactory; 42 import org.apache.derby.iapi.store.access.ColumnOrdering; 43 import org.apache.derby.iapi.store.access.ConglomerateController; 44 import org.apache.derby.iapi.store.access.DynamicCompiledOpenConglomInfo; 45 import org.apache.derby.iapi.store.access.ScanController; 46 import org.apache.derby.iapi.store.access.TransactionController; 47 48 import org.apache.derby.iapi.store.raw.ContainerKey; 49 import org.apache.derby.iapi.store.raw.ContainerHandle; 50 import org.apache.derby.iapi.store.raw.LockingPolicy; 51 import org.apache.derby.iapi.store.raw.Transaction; 52 53 import org.apache.derby.iapi.types.DataValueDescriptor; 54 55 import org.apache.derby.impl.store.access.btree.BTree; 56 import org.apache.derby.impl.store.access.btree.BranchControlRow; 57 import org.apache.derby.impl.store.access.btree.ControlRow; 58 import org.apache.derby.impl.store.access.btree.BTreeController; 59 import org.apache.derby.impl.store.access.btree.LeafControlRow; 60 import org.apache.derby.impl.store.access.btree.OpenBTree; 61 62 77 78 public class B2IFactory implements ConglomerateFactory, ModuleControl 79 { 80 81 private static final String IMPLEMENTATIONID = "BTREE"; 82 private static final String FORMATUUIDSTRING = "C6CEEEF0-DAD3-11d0-BB01-0060973F0942"; 83 private UUID formatUUID; 84 85 86 89 90 94 public Properties defaultProperties() 95 { 96 return new Properties (); 98 } 99 100 107 public boolean supportsImplementation(String implementationId) 108 { 109 return implementationId.equals(IMPLEMENTATIONID); 110 } 111 112 118 public String primaryImplementationType() 119 { 120 return IMPLEMENTATIONID; 121 } 122 123 130 public boolean supportsFormat(UUID formatid) 131 { 132 return formatid.equals(formatUUID); 133 } 134 135 141 public UUID primaryFormat() 142 { 143 return formatUUID; 144 } 145 146 149 150 163 public int getConglomerateFactoryId() 164 { 165 return(ConglomerateFactory.BTREE_FACTORY_ID); 166 } 167 168 175 public Conglomerate createConglomerate( 176 TransactionManager xact_mgr, 177 int segment, 178 long input_containerid, 179 DataValueDescriptor[] template, 180 ColumnOrdering[] columnOrder, 181 Properties properties, 182 int temporaryFlag) 183 throws StandardException 184 { 185 B2I btree = new B2I(); 186 btree.create( 187 xact_mgr, segment, input_containerid, template, columnOrder, 188 properties, temporaryFlag); 189 190 return(btree); 191 } 192 193 214 public Conglomerate readConglomerate( 215 TransactionManager xact_manager, 216 ContainerKey container_key) 217 throws StandardException 218 { 219 Conglomerate btree = null; 220 ContainerHandle container = null; 221 ControlRow root = null; 222 223 try 224 { 225 container = 231 (xact_manager.getRawStoreXact()).openContainer( 232 container_key, 233 (LockingPolicy) null, 234 ContainerHandle.MODE_READONLY); 235 236 if (container == null) 237 { 238 242 throw StandardException.newException( 243 SQLState.STORE_CONGLOMERATE_DOES_NOT_EXIST, 244 new Long (container_key.getContainerId())); 245 } 246 247 root = ControlRow.Get(container, BTree.ROOTPAGEID); 249 250 if (SanityManager.DEBUG) 251 SanityManager.ASSERT(root.getPage().isLatched()); 252 253 btree = (B2I) root.getConglom(B2I.FORMAT_NUMBER); 255 256 if (SanityManager.DEBUG) 257 SanityManager.ASSERT(btree instanceof B2I); 258 } 259 finally 260 { 261 262 if (root != null) 263 root.release(); 264 265 if (container != null) 266 container.close(); 267 } 268 269 271 return(btree); 272 } 273 274 277 278 public boolean canSupport(Properties startParams) { 279 280 String impl = startParams.getProperty("derby.access.Conglomerate.type"); 281 if (impl == null) 282 return false; 283 284 return supportsImplementation(impl); 285 } 286 287 public void boot(boolean create, Properties startParams) 288 throws StandardException 289 { 290 UUIDFactory uuidFactory = 292 Monitor.getMonitor().getUUIDFactory(); 293 294 formatUUID = uuidFactory.recreateUUID(FORMATUUIDSTRING); 296 } 297 298 public void stop() 299 { 300 } 301 } 302 | Popular Tags |