1 21 22 package org.apache.derby.impl.sql.execute; 23 24 import org.apache.derby.iapi.types.DataValueDescriptor; 25 import org.apache.derby.iapi.sql.execute.NoPutResultSet; 26 import org.apache.derby.iapi.services.io.StreamStorable; 27 import org.apache.derby.iapi.sql.execute.ExecRow; 28 import org.apache.derby.iapi.sql.execute.ConstantAction; 29 import org.apache.derby.iapi.error.StandardException; 30 import org.apache.derby.iapi.sql.Activation; 31 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext; 32 33 import org.apache.derby.iapi.store.access.DynamicCompiledOpenConglomInfo; 34 import org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo; 35 import org.apache.derby.iapi.store.access.TransactionController; 36 37 import org.apache.derby.catalog.UUID; 38 import org.apache.derby.iapi.services.io.FormatableBitSet; 39 40 43 abstract class DMLWriteResultSet extends NoRowsResultSetImpl 44 { 45 protected WriteCursorConstantAction constantAction; 46 protected int[] baseRowReadMap; 47 protected int[] streamStorableHeapColIds; 48 protected ExecRow deferredSparseRow; 49 protected DynamicCompiledOpenConglomInfo heapDCOCI; 50 protected DynamicCompiledOpenConglomInfo[] indexDCOCIs; 51 private boolean needToObjectifyStream; 52 53 54 public int rowCount; 55 56 57 64 DMLWriteResultSet(Activation activation) 65 throws StandardException 66 { 67 this(activation, activation.getConstantAction()); 68 } 69 DMLWriteResultSet(Activation activation, ConstantAction constantAction) 70 throws StandardException 71 { 72 super(activation); 73 74 this.constantAction = (WriteCursorConstantAction) constantAction; 75 baseRowReadMap = this.constantAction.getBaseRowReadMap(); 76 streamStorableHeapColIds = this.constantAction.getStreamStorableHeapColIds(); 77 78 TransactionController tc = activation.getTransactionController(); 79 80 if (! (constantAction instanceof UpdatableVTIConstantAction)) 82 { 83 heapDCOCI = tc.getDynamicCompiledConglomInfo(this.constantAction.conglomId); 84 if (this.constantAction.indexCIDS.length != 0) 85 { 86 indexDCOCIs = new DynamicCompiledOpenConglomInfo[this.constantAction.indexCIDS.length]; 87 for (int index = 0; index < this.constantAction.indexCIDS.length; index++) 88 { 89 indexDCOCIs[index] = tc.getDynamicCompiledConglomInfo( 90 this.constantAction.indexCIDS[index]); 91 } 92 } 93 } 94 95 108 needToObjectifyStream = (this.constantAction.getTriggerInfo( 109 activation.getLanguageConnectionContext().getExecutionContext()) != null); 110 } 111 112 public final int modifiedRowCount() { return rowCount; } 113 114 115 121 protected ExecRow getNextRowCore(NoPutResultSet source) 122 throws StandardException 123 { 124 ExecRow row = source.getNextRowCore(); 125 if (needToObjectifyStream) 126 { 127 132 objectifyStreams(row); 133 } 134 return row; 135 } 136 137 private void objectifyStreams(ExecRow row) throws StandardException 138 { 139 if ((row != null) && (streamStorableHeapColIds != null)) 142 { 143 for (int ix=0; ix < streamStorableHeapColIds.length; ix++) 144 { 145 int heapIx = streamStorableHeapColIds[ix]; 146 int readIx = (baseRowReadMap == null) ? 147 heapIx : 148 baseRowReadMap[heapIx]; 149 150 DataValueDescriptor col = row.getColumn(readIx+1); 151 ((StreamStorable)col).loadStream(); 152 } 153 } 154 } 155 156 163 protected ExecRow makeDeferredSparseRow( 164 ExecRow deferredBaseRow, 165 FormatableBitSet baseRowReadList, 166 LanguageConnectionContext lcc) 167 throws StandardException 168 { 169 ExecRow deferredSparseRow; 170 171 if (baseRowReadList == null) 172 { 173 174 deferredSparseRow = deferredBaseRow; 175 } 176 else 177 { 178 184 deferredSparseRow = 185 RowUtil.getEmptyValueRow( 186 baseRowReadList.getLength() - 1, 187 lcc); 188 192 int fromPosition = 1; 193 for (int i = 1; i <= deferredSparseRow.nColumns(); i++) 194 { 195 if (baseRowReadList.isSet(i)) 196 { 197 deferredSparseRow.setColumn( 198 i, 199 deferredBaseRow.getColumn(fromPosition++) 200 ); 201 } 202 } 203 } 204 205 return deferredSparseRow; 206 } 207 208 215 String getIndexNameFromCID(long indexCID) 216 { 217 return this.constantAction.getIndexNameFromCID(indexCID); 218 } 219 } 220 | Popular Tags |