📄 tablescanresultset.java
字号:
return null; } else { throw se; } } setCurrentRow(result); return currentRow; } /** * Print the parameters that constructed this result set to the * trace stream. *//* private final void traceScanParameters() { if (SanityManager.DEBUG) { HeaderPrintWriter traceStream = SanityManager.GET_DEBUG_STREAM(); traceStream.println(""); traceStream.println("TableScanResultSet number " + resultSetNumber + " parameters:"); traceStream.println(""); traceStream.println("\tTable name: " + tableName); if (indexName != null) { traceStream.println("\tIndex name: " + indexName); } traceStream.println(""); traceStream.println("\tStart position is: "); tracePrintPosition(traceStream, startSearchOperator, startKeyGetter); traceStream.println(""); traceStream.println("\tStop position is: " ); tracePrintPosition(traceStream, stopSearchOperator, stopKeyGetter); traceStream.println(""); traceStream.println("\tQualifiers are: "); tracePrintQualifiers(traceStream, qualifiers, 2); traceStream.println(""); } }*/ /** * Print I/O statistics about a scan when it closes. *//* private final void traceClose() { if (SanityManager.DEBUG) { InfoStreams infoStreams; HeaderPrintWriter traceStream; traceStream = SanityManager.GET_DEBUG_STREAM(); traceStream.println("TableScanResultSet number " + resultSetNumber + " closed."); if (isKeyed) { traceStream.println("\t" + rowCount() + " row(s) qualified from " + "keyed" + " table " + tableName + " using index " + indexName); } else { traceStream.println("\t" + rowCount() + " row(s) qualified from " + "non-keyed" + " table " + tableName); } traceStream.println(""); } }*/ /** * Print a start or stop positioner to the trace stream. *//* private final void tracePrintPosition(HeaderPrintWriter traceStream, int searchOperator, GeneratedMethod positionGetter) { if (SanityManager.DEBUG) { if (positionGetter == null) { traceStream.println("\t\tNone"); return; } ExecIndexRow positioner = null; try { positioner = (ExecIndexRow) positionGetter.invoke(activation); } catch (StandardException e) { traceStream.println("\t\tUnexpected exception " + e + " getting positioner."); e.printStackTrace(traceStream.getPrintWriter()); return; } if (positioner == null) { traceStream.println("\t\tNone"); return; } String searchOp = null; switch (searchOperator) { case ScanController.GE: searchOp = "GE"; break; case ScanController.GT: searchOp = "GT"; break; default: searchOp = "unknown value (" + searchOperator + ")"; break; } traceStream.println("\t\t" + searchOp + " on first " + positioner.nColumns() + " column(s)."); traceStream.print( "\t\tOrdered null semantics on the following columns: "); for (int position = 0; position < positioner.nColumns(); position++) { if (positioner.areNullsOrdered(position)) { traceStream.print(position + " "); } } traceStream.println(""); } }*/ /** * Print an array of Qualifiers to the trace stream. *//* private final void tracePrintQualifiers(HeaderPrintWriter traceStream, Qualifier[][] qualifiers, int depth) { if (SanityManager.DEBUG) { char[] indentchars = new char[depth]; /* ** Form an array of tab characters for indentation. * while (depth > 0) { indentchars[depth - 1] = '\t'; depth--; } String indent = new String(indentchars); if (qualifiers == null) { traceStream.println(indent + MessageService.getTextMessage( SQLState.LANG_NONE) ); return; } // RESOLVE (mikem) We don't support 2-d qualifiers yet. if (SanityManager.DEBUG) { SanityManager.ASSERT(qualifiers.length == 1); } for (int i = 0; i < qualifiers[0].length; i++) { Qualifier qual = qualifiers[0][i]; traceStream.println(""); traceStream.println(indent + "Column Id: " + qual.getColumnId()); int operator = qual.getOperator(); String opString = null; switch (operator) { case Orderable.ORDER_OP_EQUALS: opString = "="; break; case Orderable.ORDER_OP_LESSOREQUALS: opString = "<="; break; case Orderable.ORDER_OP_LESSTHAN: opString = "<"; break; default: opString = "unknown value (" + operator + ")"; break; } traceStream.println(indent + "Operator: " + opString); traceStream.println(indent + "Ordered nulls: " + qual.getOrderedNulls()); traceStream.println(indent + "Unknown return value: " + qual.getUnknownRV()); traceStream.println(indent + "Negate comparison result: " + qual.negateCompareResult()); traceStream.println(""); } } }*/ public String printStartPosition() { return printPosition(startSearchOperator, startKeyGetter, startPosition); } public String printStopPosition() { if (sameStartStopPosition) { return printPosition(stopSearchOperator, startKeyGetter, startPosition); } else { return printPosition(stopSearchOperator, stopKeyGetter, stopPosition); } } /** * Return a start or stop positioner as a String. * * If we already generated the information, then use * that. Otherwise, invoke the activation to get it. */ private String printPosition(int searchOperator, GeneratedMethod positionGetter, ExecIndexRow positioner) { String idt = ""; String output = ""; if (positionGetter == null) { return "\t" + MessageService.getTextMessage(SQLState.LANG_NONE) + "\n"; } if (positioner == null) { try { positioner = (ExecIndexRow)positionGetter.invoke(activation); } catch (StandardException e) { // the positionGetter will fail with a NullPointerException // if the outer table is empty // (this isn't a problem since we won't call it on the inner // table if there are no rows on the outer table) if (e.getSQLState() == SQLState.LANG_UNEXPECTED_USER_EXCEPTION ) return "\t" + MessageService.getTextMessage( SQLState.LANG_POSITION_NOT_AVAIL); return "\t" + MessageService.getTextMessage( SQLState.LANG_UNEXPECTED_EXC_GETTING_POSITIONER, e.toString()); } } if (positioner == null) { return "\t" + MessageService.getTextMessage(SQLState.LANG_NONE) + "\n"; } String searchOp = null; switch (searchOperator) { case ScanController.GE: searchOp = ">="; break; case ScanController.GT: searchOp = ">"; break; default: if (SanityManager.DEBUG) { SanityManager.THROWASSERT("Unknown search operator " + searchOperator); } // NOTE: This does not have to be internationalized because // this code should never be reached. searchOp = "unknown value (" + searchOperator + ")"; break; } output = output + "\t" + MessageService.getTextMessage( SQLState.LANG_POSITIONER, searchOp, String.valueOf(positioner.nColumns())) + "\n"; output = output + "\t" + MessageService.getTextMessage( SQLState.LANG_ORDERED_NULL_SEMANTICS) + "\n"; for (int position = 0; position < positioner.nColumns(); position++) { if (positioner.areNullsOrdered(position)) { output = output + position + " "; } } return output + "\n"; } public Properties getScanProperties() { if (scanProperties == null) { scanProperties = new Properties(); } try { if (scanController != null) { scanController.getScanInfo().getAllScanInfo(scanProperties); /* Did we get a coarser lock due to * a covering lock, lock escalation * or configuration? */ coarserLock = scanController.isTableLocked() && (lockMode == TransactionController.MODE_RECORD); } } catch(StandardException se) { // ignore } return scanProperties; } /** * @see NoPutResultSet#getScanIsolationLevel */ public int getScanIsolationLevel() { return isolationLevel; } /** * @see NoPutResultSet#requiresRelocking */ public boolean requiresRelocking() { return( isolationLevel == TransactionController.ISOLATION_READ_COMMITTED_NOHOLDLOCK); } /** * Update the number of rows in the scan controller. * * NOTE: It would be more efficient to only update the * scan controller if the optimizer's estimated number of * rows were wrong by more than some threshold (like 10%). * This would require a little more work than I have the * time for now, however, as the row estimate that is given * to this result set is the total number of rows for all * scans, not the number of rows per scan. * * * @param rowsThisScan The number of rows to update the scanController to * * @exception StandardException Thrown on error */ protected final void setRowCountIfPossible(long rowsThisScan) throws StandardException { /* ** Is it a heap scan with no qualifiers (full table scan?) ** and is it not for update (we don't want to count rows we're ** about to delete. */ if ( ( ! scanController.isKeyed() ) && (qualifiers == null || qualifiers.length == 0) && ( ! forUpdate ) ) { // Only update rows if different by more than 10% long diff = rowsThisScan - estimatedRowCount; long tenPerCent = estimatedRowCount / 10; if (diff < 0) diff = -diff; if (diff > tenPerCent) scanController.setEstimatedRowCount(rowsThisScan); } } /** * Can we get instantaneous locks when getting share row * locks at READ COMMITTED. */ protected boolean canGetInstantaneousLocks() { return false; } /** * Is this ResultSet or it's source result set for update * * @return Whether or not the result set is for update. */ public boolean isForUpdate() { return forUpdate; } /** * Shallow clone this result set. Used in trigger reference. * beetle 4373. */ public Object clone() { Object clo = null; try { clo = super.clone(); } catch (CloneNotSupportedException e) {} return clo; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -