📄 rowchangerimpl.java
字号:
else { isolationLevel = lcc.getCurrentIsolationLevel(); } switch (isolationLevel) { // Even though we preserve the isolation level at READ UNCOMMITTED, // Cloudscape Store will overwrite it to READ COMMITTED for update. case ExecutionContext.READ_UNCOMMITTED_ISOLATION_LEVEL: isolationLevel = TransactionController.ISOLATION_READ_UNCOMMITTED; break; case ExecutionContext.READ_COMMITTED_ISOLATION_LEVEL: isolationLevel = TransactionController.ISOLATION_READ_COMMITTED; break; case ExecutionContext.REPEATABLE_READ_ISOLATION_LEVEL: isolationLevel = TransactionController.ISOLATION_REPEATABLE_READ; break; case ExecutionContext.SERIALIZABLE_ISOLATION_LEVEL: isolationLevel = TransactionController.ISOLATION_SERIALIZABLE; break; default: if (SanityManager.DEBUG) { SanityManager.THROWASSERT( "Invalid isolation level - " + isolationLevel); } } try { /* We can get called by either an activation or * the DataDictionary. The DD cannot use the * CompiledInfo while the activation can. */ if (heapSCOCI != null) { baseCC = tc.openCompiledConglomerate( false, (TransactionController.OPENMODE_FORUPDATE | ((wait) ? 0 : TransactionController.OPENMODE_LOCK_NOWAIT)), lockMode, isolationLevel, heapSCOCI, heapDCOCI); } else { baseCC = tc.openConglomerate( heapConglom, false, (TransactionController.OPENMODE_FORUPDATE | ((wait) ? 0 : TransactionController.OPENMODE_LOCK_NOWAIT)), lockMode, isolationLevel); } } catch (StandardException se) { if (activation != null) activation.checkStatementValidity(); throw se; } /* Save the ConglomerateController off in the activation * to eliminate the need to open it a 2nd time if we are doing * and index to base row for the search as part of an update or * delete below us. * NOTE: activation can be null. (We don't have it in * the DataDictionary.) */ if (activation != null) { activation.checkStatementValidity(); activation.setHeapConglomerateController(baseCC); } /* Only worry about indexes if there are indexes to worry about */ if (indexCIDS.length != 0) { /* IndexSetChanger re-used across executions. */ if (isc == null) { isc = new IndexSetChanger(irgs, indexCIDS, indexSCOCIs, indexDCOCIs, indexNames, baseCC, tc, lockMode, baseRowReadList, isolationLevel, activation ); isc.setRowHolder(rowHolder); } else { /* Propagate the heap's ConglomerateController to * all of the underlying index changers. */ isc.setBaseCC(baseCC); } isc.open(fixOnUpdate); if (baseRowLocation == null) baseRowLocation = baseCC.newRowLocationTemplate(); } isOpen = true; } /** Insert a row into the table and perform associated index maintenance. @param baseRow the row. @param baseRowLocation the row's base conglomerate location @exception StandardException Thrown on error */ public void insertRow(ExecRow baseRow) throws StandardException { if (SanityManager.DEBUG) SanityManager.ASSERT(! baseCC.isKeyed(), "Keyed inserts not yet supported"); if (baseCC.isKeyed()) { //kcc.insert(row.key(), row()); } else { if (isc != null) { baseCC.insertAndFetchLocation(baseRow.getRowArray(), baseRowLocation); isc.insert(baseRow, baseRowLocation); } else { baseCC.insert(baseRow.getRowArray()); } } } /** Delete a row from the table and perform associated index maintenance. @param baseRow the row. @param baseRowLocation the row's base conglomerate location @exception StandardException Thrown on error */ public void deleteRow(ExecRow baseRow, RowLocation baseRowLocation) throws StandardException { if (isc != null) { isc.delete(baseRow, baseRowLocation); } baseCC.delete(baseRowLocation); } /** Update a row in the table and perform associated index maintenance. @param ef ExecutionFactory to use for cloning @param oldBaseRow the old image of the row. @param newBaseRow the new image of the row. @param baseRowLocation the row's base conglomerate location @exception StandardException Thrown on error */ public void updateRow(ExecRow oldBaseRow, ExecRow newBaseRow, RowLocation baseRowLocation) throws StandardException { if (isc != null) { isc.update(oldBaseRow, newBaseRow, baseRowLocation); } if (changedColumnBitSet != null) { DataValueDescriptor[] baseRowArray = newBaseRow.getRowArray(); int[] changedColumnArray = (partialChangedColumnIds == null) ? changedColumnIds : partialChangedColumnIds; int nextColumnToUpdate = -1; for (int i = 0; i < changedColumnArray.length; i++) { int copyFrom = changedColumnArray[i] - 1; nextColumnToUpdate = changedColumnBitSet.anySetBit(nextColumnToUpdate); if (SanityManager.DEBUG) { SanityManager.ASSERT(nextColumnToUpdate >= 0, "More columns in changedColumnArray than in changedColumnBitSet"); } sparseRowArray[nextColumnToUpdate] = baseRowArray[copyFrom]; } } else { sparseRowArray = newBaseRow.getRowArray(); } baseCC.replace(baseRowLocation, sparseRowArray, changedColumnBitSet); } /** Finish processing the changes. This means applying the deferred inserts for updates to unique indexes. @exception StandardException Thrown on error */ public void finish() throws StandardException { if (isc != null) { isc.finish(); } } /** Close this RowChanger. @exception StandardException Thrown on error */ public void close() throws StandardException { // //NOTE: isc uses baseCC. Since we close baseCC we free isc for now. //We could consider making isc open its own baseCC or even leaving //baseCC open to promote re-use. We must keep in mind that baseCC //is associated with the opener's TransactionController. if (isc != null) { isc.close(); } if (baseCC != null) { if (activation == null || activation.getForUpdateIndexScan() == null) baseCC.close(); //beetle 3865, don't close if borrowed to cursor baseCC = null; } isOpen = false; // rowHolder is reused across executions and closed by caller // since caller creates it if (activation != null) { activation.clearHeapConglomerateController(); } } /** @see RowChanger#getHeapConglomerateController */ public ConglomerateController getHeapConglomerateController() { return baseCC; } private int[] sortArray(int[] input) { /* ** Sotring.sort() will change the underlying array, so we ** 'clone' it first */ int[] output = new int[input.length]; System.arraycopy(input, 0, output, 0, input.length); java.util.Arrays.sort(output); return output; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -