use of org.apache.derby.impl.sql.execute.rts.RunTimeStatisticsImpl in project derby by apache.
the class RealResultSetStatisticsFactory method getRunTimeStatistics.
//
// ExecutionFactory interface
//
//
// ResultSetStatisticsFactory interface
//
/**
* @see ResultSetStatisticsFactory#getRunTimeStatistics
*/
public RunTimeStatistics getRunTimeStatistics(Activation activation, ResultSet rs, NoPutResultSet[] subqueryTrackingArray) throws StandardException {
PreparedStatement preStmt = activation.getPreparedStatement();
// In this case statistics should not be generated.
if (preStmt == null)
return null;
ResultSetStatistics topResultSetStatistics;
if (rs instanceof NoPutResultSet) {
topResultSetStatistics = getResultSetStatistics((NoPutResultSet) rs);
} else {
topResultSetStatistics = getResultSetStatistics(rs);
}
/* Build up the info on the materialized subqueries */
int subqueryTrackingArrayLength = (subqueryTrackingArray == null) ? 0 : subqueryTrackingArray.length;
ResultSetStatistics[] subqueryRSS = new ResultSetStatistics[subqueryTrackingArrayLength];
boolean anyAttached = false;
for (int index = 0; index < subqueryTrackingArrayLength; index++) {
if (subqueryTrackingArray[index] != null && subqueryTrackingArray[index].getPointOfAttachment() == -1) {
subqueryRSS[index] = getResultSetStatistics(subqueryTrackingArray[index]);
anyAttached = true;
}
}
if (anyAttached == false) {
subqueryRSS = null;
}
// Get the info on all of the materialized subqueries (attachment point = -1)
return new RunTimeStatisticsImpl(preStmt.getSPSName(), activation.getCursorName(), preStmt.getSource(), preStmt.getCompileTimeInMillis(), preStmt.getParseTimeInMillis(), preStmt.getBindTimeInMillis(), preStmt.getOptimizeTimeInMillis(), preStmt.getGenerateTimeInMillis(), rs.getExecuteTime(), preStmt.getBeginCompileTimestamp(), preStmt.getEndCompileTimestamp(), rs.getBeginExecutionTimestamp(), rs.getEndExecutionTimestamp(), subqueryRSS, topResultSetStatistics);
}
Aggregations