📄 tabinfoimpl.java
字号:
ExecIndexRow key, int indexNumber) throws StandardException { RowLocation rl[] = new RowLocation[1]; return getRowInternal(tc, heapCC, key, indexNumber, rl); } /** * @exception StandardException Thrown on failure * @see TabInfo#getRow */ private ExecRow getRowInternal( TransactionController tc, ConglomerateController heapCC, ExecIndexRow key, int indexNumber, RowLocation rl[]) throws StandardException { ScanController drivingScan; ExecIndexRow drivingIndexRow; RowLocation baseRowLocation; ExecRow baseRow = crf.makeEmptyRow(); drivingScan = tc.openScan( getIndexConglomerate(indexNumber), // conglomerate to open false, // don't hold open across commit 0, // open for read TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ, (FormatableBitSet) null, // all fields as objects key.getRowArray(), // start position - first row ScanController.GE, // startSearchOperation null, //scanQualifier key.getRowArray(), // stop position - through last row ScanController.GT); // stopSearchOperation // Get an index row based on the base row drivingIndexRow = getIndexRowFromHeapRow( getIndexRowGenerator( indexNumber ), heapCC.newRowLocationTemplate(), crf.makeEmptyRow()); try { if (drivingScan.next()) { drivingScan.fetch(drivingIndexRow.getRowArray()); rl[0] = baseRowLocation = (RowLocation) drivingIndexRow.getColumn(drivingIndexRow.nColumns()); boolean base_row_exists = heapCC.fetch( baseRowLocation, baseRow.getRowArray(), (FormatableBitSet) null); if (SanityManager.DEBUG) { // it can not be possible for heap row to disappear while // holding scan cursor on index at ISOLATION_REPEATABLE_READ. SanityManager.ASSERT(base_row_exists, "base row not found"); } return baseRow; } else { return null; } } finally { drivingScan.close(); } } /** * Updates a base row in a catalog and updates all the corresponding * index rows. * * @param key key row * @param newRow new version of the row * @param indexNumber index that key operates * @param indicesToUpdate array of booleans, one for each index on the catalog. * if a boolean is true, that means we must update the * corresponding index because changes in the newRow * affect it. * @param colsToUpdate array of ints indicating which columns (1 based) * to update. If null, do all. * @param tc transaction controller * * @exception StandardException Thrown on failure */ public void updateRow( ExecIndexRow key, ExecRow newRow, int indexNumber, boolean[] indicesToUpdate, int[] colsToUpdate, TransactionController tc ) throws StandardException { updateRow(key, newRow, indexNumber, indicesToUpdate, colsToUpdate, tc, true); } /** * Updates a base row in a catalog and updates all the corresponding * index rows. * * @param key key row * @param newRow new version of the row * @param indexNumber index that key operates * @param indicesToUpdate array of booleans, one for each index on the catalog. * if a boolean is true, that means we must update the * corresponding index because changes in the newRow * affect it. * @param colsToUpdate array of ints indicating which columns (1 based) * to update. If null, do all. * @param tc transaction controller * @param wait If true, then the caller wants to wait for locks. False will be * when we using a nested user xaction - we want to timeout right away if the parent * holds the lock. (bug 4821) * * @exception StandardException Thrown on failure */ public void updateRow( ExecIndexRow key, ExecRow newRow, int indexNumber, boolean[] indicesToUpdate, int[] colsToUpdate, TransactionController tc, boolean wait ) throws StandardException { ExecRow[] newRows = new ExecRow[1]; newRows[0] = newRow; updateRow(key, newRows, indexNumber, indicesToUpdate, colsToUpdate, tc, wait); } /** * Updates a set of base rows in a catalog with the same key on an index * and updates all the corresponding index rows. * * @param key key row * @param newRows new version of the array of rows * @param indexNumber index that key operates * @param indicesToUpdate array of booleans, one for each index on the catalog. * if a boolean is true, that means we must update the * corresponding index because changes in the newRow * affect it. * @param colsToUpdate array of ints indicating which columns (1 based) * to update. If null, do all. * @param tc transaction controller * * @exception StandardException Thrown on failure */ public void updateRow( ExecIndexRow key, ExecRow[] newRows, int indexNumber, boolean[] indicesToUpdate, int[] colsToUpdate, TransactionController tc ) throws StandardException { updateRow(key, newRows, indexNumber, indicesToUpdate, colsToUpdate, tc, true); } /** * Updates a set of base rows in a catalog with the same key on an index * and updates all the corresponding index rows. If parameter wait is true, * then the caller wants to wait for locks. When using a nested user xaction * we want to timeout right away if the parent holds the lock. * * @param key key row * @param newRows new version of the array of rows * @param indexNumber index that key operates * @param indicesToUpdate array of booleans, one for each index on the catalog. * if a boolean is true, that means we must update the * corresponding index because changes in the newRow * affect it. * @param colsToUpdate array of ints indicating which columns (1 based) * to update. If null, do all. * @param tc transaction controller * @param wait If true, then the caller wants to wait for locks. When * using a nested user xaction we want to timeout right away * if the parent holds the lock. (bug 4821) * * @exception StandardException Thrown on failure */ public void updateRow( ExecIndexRow key, ExecRow[] newRows, int indexNumber, boolean[] indicesToUpdate, int[] colsToUpdate, TransactionController tc, boolean wait) throws StandardException { ConglomerateController heapCC; ScanController drivingScan; ExecIndexRow drivingIndexRow; RowLocation baseRowLocation; ExecIndexRow templateRow; ExecRow baseRow = crf.makeEmptyRow(); if (SanityManager.DEBUG) { SanityManager.ASSERT( indicesToUpdate.length == crf.getNumIndexes(), "Wrong number of indices." ); } RowChanger rc = getRowChanger( tc, colsToUpdate,baseRow ); // Row level locking rc.openForUpdate(indicesToUpdate, TransactionController.MODE_RECORD, wait); /* Open the heap conglomerate */ heapCC = tc.openConglomerate( getHeapConglomerate(), false, (TransactionController.OPENMODE_FORUPDATE | ((wait) ? 0 : TransactionController.OPENMODE_LOCK_NOWAIT)), TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ); drivingScan = tc.openScan( getIndexConglomerate(indexNumber), // conglomerate to open false, // don't hold open across commit (TransactionController.OPENMODE_FORUPDATE | ((wait) ? 0 : TransactionController.OPENMODE_LOCK_NOWAIT)), TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ, (FormatableBitSet) null, // all fields as objects key.getRowArray(), // start position - first row ScanController.GE, // startSearchOperation null, //scanQualifier key.getRowArray(), // stop position - through last row ScanController.GT); // stopSearchOperation // Get an index row based on the base row drivingIndexRow = getIndexRowFromHeapRow( getIndexRowGenerator( indexNumber ), heapCC.newRowLocationTemplate(), crf.makeEmptyRow()); int rowNum = 0; while (drivingScan.next()) { drivingScan.fetch(drivingIndexRow.getRowArray()); baseRowLocation = (RowLocation) drivingIndexRow.getColumn(drivingIndexRow.nColumns()); boolean base_row_exists = heapCC.fetch( baseRowLocation, baseRow.getRowArray(), (FormatableBitSet) null); if (SanityManager.DEBUG) { // it can not be possible for heap row to disappear while // holding scan cursor on index at ISOLATION_REPEATABLE_READ. SanityManager.ASSERT(base_row_exists, "base row not found"); } rc.updateRow(baseRow, (rowNum == newRows.length - 1) ? newRows[rowNum] : newRows[rowNum++], baseRowLocation ); } rc.finish(); heapCC.close(); drivingScan.close(); rc.close(); } /** * Get the Properties associated with creating the heap. * * @return The Properties associated with creating the heap. */ public Properties getCreateHeapProperties() { return crf.getCreateHeapProperties(); } /** * Get the Properties associated with creating the specified index. * * @param indexNumber The specified index number. * * @return The Properties associated with creating the specified index. */ public Properties getCreateIndexProperties(int indexNumber) { return crf.getCreateIndexProperties(indexNumber); } /** * Gets a row changer for this catalog. * * @param tc transaction controller * @param changedCols the columns to change (1 based), may be null * @param baseRow used to detemine column types at creation time * only. The row changer does ***Not*** keep a referance to * this row or change it in any way. * * @return a row changer for this catalog. * @exception StandardException Thrown on failure */ private RowChanger getRowChanger( TransactionController tc, int[] changedCols, ExecRow baseRow) throws StandardException { RowChanger rc; int indexCount = crf.getNumIndexes(); IndexRowGenerator[] irgs = new IndexRowGenerator[ indexCount ]; long[] cids = new long[ indexCount ]; if (SanityManager.DEBUG) { if (changedCols != null) { for (int i = changedCols.length - 1; i >= 0; i--) { SanityManager.ASSERT(changedCols[i] != 0, "Column id is 0, but should be 1 based"); } } } for ( int ictr = 0; ictr < indexCount; ictr++ ) { irgs[ictr] = getIndexRowGenerator(ictr); cids[ictr] = getIndexConglomerate(ictr); } rc = executionFactory.getRowChanger(getHeapConglomerate(), (StaticCompiledOpenConglomInfo) null, (DynamicCompiledOpenConglomInfo) null, irgs, cids, (StaticCompiledOpenConglomInfo[]) null, (DynamicCompiledOpenConglomInfo[]) null, crf.getHeapColumnCount(), tc, changedCols, getStreamStorableHeapColIds(baseRow), (Activation) null); return rc; } private boolean computedStreamStorableHeapColIds = false; private int[] streamStorableHeapColIds; private int[] getStreamStorableHeapColIds(ExecRow baseRow) throws StandardException { if (!computedStreamStorableHeapColIds) { int sshcidLen = 0; // //Compute the length of streamStorableHeapColIds //One entry for each column id. DataValueDescriptor[] ra = baseRow.getRowArray(); for(int ix=0;ix<ra.length;ix++) if (ra[ix] instanceof StreamStorable) sshcidLen++; // //If we have some streamStorableHeapColIds we //allocate an array to remember them and fill in //the array with the 0 based column ids. If we //have none leave streamStorableHeapColIds Null. if (sshcidLen > 0) { streamStorableHeapColIds = new int[sshcidLen]; int sshcidOffset=0; for(int ix=0;ix<ra.length;ix++) if (ra[ix] instanceof StreamStorable) streamStorableHeapColIds[sshcidOffset++] = ix; } computedStreamStorableHeapColIds = true; } return streamStorableHeapColIds; } /** * Get an index row based on a row from the heap. * * @param irg IndexRowGenerator to use * @param rl RowLocation for heap * @param heapRow Row from the heap * * @return ExecIndexRow Index row. * * @exception StandardException Thrown on error */ private ExecIndexRow getIndexRowFromHeapRow(IndexRowGenerator irg, RowLocation rl, ExecRow heapRow) throws StandardException { ExecIndexRow indexRow; indexRow = irg.getIndexRowTemplate(); // Get an index row based on the base row irg.getIndexRow(heapRow, rl, indexRow, (FormatableBitSet) null); return indexRow; } public String toString() { if (SanityManager.DEBUG) { return "name: " + name + "\n\theapCongolomerate: "+heapConglomerate + "\n\tnumIndexes: " + ((indexes != null) ? indexes.length : 0) + "\n\tnumIndexesSet: " + numIndexesSet + "\n\theapSet: " + heapSet + "\n\tuuid: " + uuid; } else { return ""; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -