1 21 22 package org.apache.derby.impl.sql.compile; 23 24 import org.apache.derby.iapi.services.loader.GeneratedMethod; 25 26 import org.apache.derby.iapi.services.compiler.MethodBuilder; 27 28 import org.apache.derby.iapi.sql.compile.ExpressionClassBuilderInterface; 29 import org.apache.derby.iapi.sql.compile.JoinStrategy; 30 import org.apache.derby.iapi.sql.compile.Optimizable; 31 import org.apache.derby.iapi.sql.compile.OptimizablePredicateList; 32 33 import org.apache.derby.iapi.sql.Activation; 34 35 import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor; 36 import org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor; 37 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 38 import org.apache.derby.iapi.sql.dictionary.TableDescriptor; 39 40 import org.apache.derby.iapi.store.access.Qualifier; 41 import org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo; 42 import org.apache.derby.iapi.store.access.TransactionController; 43 44 import org.apache.derby.impl.sql.compile.ExpressionClassBuilder; 45 46 import org.apache.derby.iapi.error.StandardException; 47 48 import org.apache.derby.iapi.services.sanity.SanityManager; 49 import org.apache.derby.iapi.reference.ClassName; 50 51 import org.apache.derby.iapi.util.PropertyUtil; 52 53 abstract class BaseJoinStrategy implements JoinStrategy { 54 BaseJoinStrategy() { 55 } 56 57 58 public boolean bulkFetchOK() { 59 return true; 60 } 61 62 63 public boolean ignoreBulkFetch() { 64 return false; 65 } 66 67 85 void fillInScanArgs1( 86 TransactionController tc, 87 MethodBuilder mb, 88 Optimizable innerTable, 89 OptimizablePredicateList predList, 90 ExpressionClassBuilderInterface acbi, 91 MethodBuilder resultRowAllocator 92 ) 93 throws StandardException { 94 boolean sameStartStopPosition = predList.sameStartStopPosition(); 95 ExpressionClassBuilder acb = (ExpressionClassBuilder) acbi; 96 long conglomNumber = 97 innerTable.getTrulyTheBestAccessPath(). 98 getConglomerateDescriptor(). 99 getConglomerateNumber(); 100 StaticCompiledOpenConglomInfo scoci = tc.getStaticCompiledConglomInfo(conglomNumber); 101 102 acb.pushThisAsActivation(mb); 103 mb.push(conglomNumber); 104 mb.push(acb.addItem(scoci)); 105 106 acb.pushMethodReference(mb, resultRowAllocator); 107 mb.push(innerTable.getResultSetNumber()); 108 109 predList.generateStartKey(acb, mb, innerTable); 110 mb.push(predList.startOperator(innerTable)); 111 112 if (! sameStartStopPosition) { 113 predList.generateStopKey(acb, mb, innerTable); 114 } else { 115 mb.pushNull(ClassName.GeneratedMethod); 116 } 117 118 mb.push(predList.stopOperator(innerTable)); 119 mb.push(sameStartStopPosition); 120 121 predList.generateQualifiers(acb, mb, innerTable, true); 122 mb.upCast(ClassName.Qualifier + "[][]"); 123 } 124 125 final void fillInScanArgs2(MethodBuilder mb, 126 Optimizable innerTable, 127 int bulkFetch, 128 int colRefItem, 129 int indexColItem, 130 int lockMode, 131 boolean tableLocked, 132 int isolationLevel) 133 throws StandardException 134 { 135 mb.push(innerTable.getBaseTableName()); 136 if (innerTable.getProperties() != null) 140 mb.push(PropertyUtil.sortProperties(innerTable.getProperties())); 141 else 142 mb.pushNull("java.lang.String"); 143 144 ConglomerateDescriptor cd = 145 innerTable.getTrulyTheBestAccessPath().getConglomerateDescriptor(); 146 if (cd.isConstraint()) 147 { 148 DataDictionary dd = innerTable.getDataDictionary(); 149 TableDescriptor td = innerTable.getTableDescriptor(); 150 ConstraintDescriptor constraintDesc = dd.getConstraintDescriptor( 151 td, cd.getUUID()); 152 mb.push(constraintDesc.getConstraintName()); 153 } else if (cd.isIndex()) { 154 mb.push(cd.getConglomerateName()); 155 } else { 156 mb.pushNull("java.lang.String"); 157 } 158 159 mb.push(cd.isConstraint()); 161 162 mb.push(innerTable.forUpdate()); 166 167 mb.push(colRefItem); 168 169 mb.push(indexColItem); 170 171 mb.push(lockMode); 172 173 mb.push(tableLocked); 174 175 mb.push(isolationLevel); 176 177 if (bulkFetch > 0) { 178 mb.push(bulkFetch); 179 } 180 181 187 if (validForOutermostTable()) 188 { 189 mb.push(innerTable.isOneRowScan()); 190 } 191 192 mb.push( 193 innerTable.getTrulyTheBestAccessPath(). 194 getCostEstimate().rowCount()); 195 196 mb.push( 197 innerTable.getTrulyTheBestAccessPath(). 198 getCostEstimate().getEstimatedCost()); 199 } 200 201 204 public boolean isHashJoin() 205 { 206 return false; 207 } 208 209 216 protected boolean validForOutermostTable() 217 { 218 return false; 219 } 220 } 221 | Popular Tags |