1 21 22 package org.apache.derby.impl.store.access.btree.index; 23 24 import java.io.IOException ; 25 import java.util.Properties ; 26 import org.apache.derby.iapi.services.sanity.SanityManager; 27 import org.apache.derby.iapi.error.StandardException; 28 import org.apache.derby.iapi.store.access.conglomerate.Conglomerate; 29 import org.apache.derby.iapi.store.access.conglomerate.TransactionManager; 30 import org.apache.derby.iapi.store.access.ConglomerateController; 31 import org.apache.derby.iapi.store.access.DynamicCompiledOpenConglomInfo; 32 import org.apache.derby.iapi.store.access.Qualifier; 33 import org.apache.derby.iapi.types.RowLocation; 34 import org.apache.derby.iapi.store.access.ScanController; 35 import org.apache.derby.iapi.store.access.TransactionController; 36 import org.apache.derby.iapi.store.access.ConglomerateController; 37 import org.apache.derby.iapi.store.raw.ContainerHandle; 38 import org.apache.derby.iapi.store.raw.LockingPolicy; 39 import org.apache.derby.iapi.store.raw.Transaction; 40 41 import org.apache.derby.iapi.types.DataValueDescriptor; 42 43 import org.apache.derby.impl.store.access.btree.BTreeController; 44 import org.apache.derby.impl.store.access.btree.BTreeLockingPolicy; 45 46 import org.apache.derby.impl.store.access.conglomerate.ConglomerateUtil; 47 48 import org.apache.derby.iapi.services.io.FormatableBitSet; 49 50 60 public class B2IController extends BTreeController 61 { 62 63 66 private ConglomerateController base_cc_for_locking; 67 68 71 72 B2IController() 73 { 74 super(); 76 } 77 78 void init( 79 TransactionManager xact_manager, 80 Transaction rawtran, 81 boolean hold, 82 int open_mode, 83 int lock_level, 84 LockingPolicy locking_policy, 85 boolean get_locks, 86 B2I conglomerate, 87 B2IUndo undo, 88 B2IStaticCompiledInfo static_info, 89 DynamicCompiledOpenConglomInfo dynamic_info) 90 throws StandardException 91 { 92 94 int base_open_mode = 95 open_mode | TransactionController.OPENMODE_FOR_LOCK_ONLY; 96 97 if (static_info != null) 102 { 103 base_cc_for_locking = 104 xact_manager.openCompiledConglomerate( 105 false, 106 base_open_mode, lock_level, 107 TransactionController.ISOLATION_REPEATABLE_READ, 108 static_info.base_table_static_info, 109 110 ((Conglomerate) static_info.getConglom()). 111 getDynamicCompiledConglomInfo( 112 conglomerate.baseConglomerateId)); 113 } 114 else 115 { 116 base_cc_for_locking = 117 xact_manager.openConglomerate( 118 conglomerate.baseConglomerateId, 119 false, 120 base_open_mode, lock_level, 121 TransactionController.ISOLATION_REPEATABLE_READ); 122 } 123 124 BTreeLockingPolicy b2i_locking_policy; 125 if (lock_level == TransactionController.MODE_TABLE) 126 { 127 b2i_locking_policy = 128 new B2ITableLocking3( 129 rawtran, lock_level, locking_policy, 130 base_cc_for_locking, this); 131 } 132 else if (lock_level == TransactionController.MODE_RECORD) 133 { 134 b2i_locking_policy = 135 new B2IRowLocking3( 136 rawtran, lock_level, locking_policy, 137 base_cc_for_locking, this); 138 } 139 else 140 { 141 if (SanityManager.DEBUG) 142 { 143 SanityManager.THROWASSERT("Bad lock level: " + lock_level); 144 } 145 b2i_locking_policy = null; 146 } 147 148 super.init( 150 xact_manager, 151 hold, 152 (ContainerHandle) null, 153 rawtran, 154 open_mode, 155 lock_level, 156 b2i_locking_policy, 157 conglomerate, 158 undo, 159 static_info, 160 dynamic_info); 161 162 if (SanityManager.DEBUG) 163 SanityManager.ASSERT(conglomerate != null); 164 } 165 166 169 170 183 public void close() 184 throws StandardException 185 { 186 super.close(); 187 188 if (base_cc_for_locking != null) 189 { 190 base_cc_for_locking.close(); 191 base_cc_for_locking = null; 192 } 193 } 194 195 196 202 public int insert(DataValueDescriptor[] row) 203 throws StandardException 204 { 205 if (SanityManager.DEBUG) 206 { 207 if (this.container != null) 208 { 209 SanityManager.ASSERT(this.getConglomerate() instanceof B2I); 210 211 RowLocation rowloc = (RowLocation) 212 row[((B2I)(this.getConglomerate())).rowLocationColumn]; 213 214 SanityManager.ASSERT( 215 !rowloc.isNull(), "RowLocation value is null"); 216 } 217 } 218 219 return(super.insert(row)); 220 } 221 } 222 | Popular Tags |