use of org.apache.derby.impl.sql.catalog.XPLAINSortPropsDescriptor in project derby by apache.
the class XPLAINSystemTableVisitor method addArraysToSystemCatalogs.
/**
* This method writes the created descriptor arrays
* to the cooresponding system catalogs.
*/
private void addArraysToSystemCatalogs() throws StandardException, SQLException {
boolean statsSave = lcc.getRunTimeStatisticsMode();
lcc.setRunTimeStatisticsMode(false);
Connection conn = getDefaultConn();
PreparedStatement ps = conn.prepareStatement((String) lcc.getXplainStatement("SYSXPLAIN_RESULTSETS"));
Iterator<XPLAINResultSetDescriptor> rsetsiter = rsets.iterator();
while (rsetsiter.hasNext()) {
XPLAINResultSetDescriptor rset = rsetsiter.next();
rset.setStatementParameters(ps);
ps.executeUpdate();
}
ps.close();
// add the resultset timings descriptors, if timing is on
if (considerTimingInformation) {
ps = conn.prepareStatement((String) lcc.getXplainStatement("SYSXPLAIN_RESULTSET_TIMINGS"));
Iterator<Object> timingsiter = rsetsTimings.iterator();
while (timingsiter.hasNext()) {
XPLAINResultSetTimingsDescriptor rsetT = (XPLAINResultSetTimingsDescriptor) timingsiter.next();
rsetT.setStatementParameters(ps);
ps.executeUpdate();
}
ps.close();
}
ps = conn.prepareStatement((String) lcc.getXplainStatement("SYSXPLAIN_SCAN_PROPS"));
Iterator<XPLAINScanPropsDescriptor> scaniter = scanrsets.iterator();
while (scaniter.hasNext()) {
XPLAINScanPropsDescriptor scanProps = scaniter.next();
scanProps.setStatementParameters(ps);
ps.executeUpdate();
}
ps.close();
ps = conn.prepareStatement((String) lcc.getXplainStatement("SYSXPLAIN_SORT_PROPS"));
Iterator<XPLAINSortPropsDescriptor> sortiter = sortrsets.iterator();
while (sortiter.hasNext()) {
XPLAINSortPropsDescriptor sortProps = sortiter.next();
sortProps.setStatementParameters(ps);
ps.executeUpdate();
}
ps.close();
conn.close();
lcc.setRunTimeStatisticsMode(statsSave);
}
use of org.apache.derby.impl.sql.catalog.XPLAINSortPropsDescriptor in project derby by apache.
the class XPLAINSystemTableVisitor method visit.
/**
* Visit this node, calling back to it to get details.
*
* This method visits the RS Statisitcs node, calling back to the
* node to get detailed descriptor information about it.
*/
public void visit(ResultSetStatistics statistics) {
UUID timingID = null;
if (considerTimingInformation) {
timingID = dd.getUUIDFactory().createUUID();
rsetsTimings.add(statistics.getResultSetTimingsDescriptor(timingID));
}
UUID sortID = dd.getUUIDFactory().createUUID();
XPLAINSortPropsDescriptor sortRSDescriptor = (XPLAINSortPropsDescriptor) statistics.getSortPropsDescriptor(sortID);
if (sortRSDescriptor != null)
sortrsets.add(sortRSDescriptor);
else
sortID = null;
UUID scanID = dd.getUUIDFactory().createUUID();
XPLAINScanPropsDescriptor scanRSDescriptor = (XPLAINScanPropsDescriptor) statistics.getScanPropsDescriptor(scanID);
if (scanRSDescriptor != null)
scanrsets.add(scanRSDescriptor);
else
scanID = null;
UUID rsID = dd.getUUIDFactory().createUUID();
rsets.add((XPLAINResultSetDescriptor) statistics.getResultSetDescriptor(rsID, UUIDStack.empty() ? (UUID) null : UUIDStack.pop(), scanID, sortID, stmtUUID, timingID));
pushUUIDnoChildren(rsID);
}
use of org.apache.derby.impl.sql.catalog.XPLAINSortPropsDescriptor in project derby by apache.
the class RealSortStatistics method getSortPropsDescriptor.
public Object getSortPropsDescriptor(Object sortPropsID) {
FormatableProperties props = this.sortProperties;
// create new scan info descriptor with some basic information
XPLAINSortPropsDescriptor sortRSDescriptor = new XPLAINSortPropsDescriptor(// the sort props UUID
(UUID) sortPropsID, // the sort type, either (C)onstraint, (I)ndex or (T)able
null, // the number of input rows
null, // the number of output rows
null, // the number of merge runs
null, // merge run details
null, XPLAINUtil.getYesNoCharFromBoolean(// eliminate duplicates
this.eliminateDuplicates), XPLAINUtil.getYesNoCharFromBoolean(// in sorted order
this.inSortedOrder), // distinct_aggregate
null);
// fill additional information from scan properties
return XPLAINUtil.extractSortProps(sortRSDescriptor, props);
}
use of org.apache.derby.impl.sql.catalog.XPLAINSortPropsDescriptor in project derby by apache.
the class RealGroupedAggregateStatistics method getSortPropsDescriptor.
public Object getSortPropsDescriptor(Object sortPropsID) {
Properties props = this.sortProperties;
// create new scan info descriptor with some basic information
XPLAINSortPropsDescriptor sortRSDescriptor = new XPLAINSortPropsDescriptor(// the sort props UUID
(UUID) sortPropsID, // the sort type, either (C)onstraint, (I)ndex or (T)able
null, // the number of input rows
null, // the number of output rows
null, // the number of merge runs
null, // merge run details
null, // eliminate duplicates
null, XPLAINUtil.getYesNoCharFromBoolean(// in sorted order
this.inSortedOrder), XPLAINUtil.getYesNoCharFromBoolean(// distinct_aggregate
this.hasDistinctAggregate));
// fill additional information from scan properties
return XPLAINUtil.extractSortProps(sortRSDescriptor, props);
}
use of org.apache.derby.impl.sql.catalog.XPLAINSortPropsDescriptor in project derby by apache.
the class SystemProcedures method SYSCS_SET_XPLAIN_SCHEMA.
/**
* This procedure sets the current xplain schema.
* If the schema is not set, runtime statistics are captured as a
* textual stream printout. If it is set, statisitcs information is
* stored in that schema in user tables.
* @param schemaName May be an empty string.
* @throws SQLException
*/
public static void SYSCS_SET_XPLAIN_SCHEMA(String schemaName) throws SQLException, StandardException {
try {
// make sure that application code doesn't bypass security checks
// by calling this public entry point
SecurityUtil.authorize(Securable.SET_XPLAIN_SCHEMA);
} catch (StandardException se) {
throw PublicAPI.wrapStandardException(se);
}
LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
TransactionController tc = lcc.getTransactionExecute();
if (schemaName == null || schemaName.trim().length() == 0) {
lcc.setXplainSchema(null);
return;
}
boolean statsSave = lcc.getRunTimeStatisticsMode();
lcc.setRunTimeStatisticsMode(false);
createXplainSchema(schemaName);
createXplainTable(lcc, schemaName, new XPLAINStatementDescriptor());
createXplainTable(lcc, schemaName, new XPLAINStatementTimingsDescriptor());
createXplainTable(lcc, schemaName, new XPLAINResultSetDescriptor());
createXplainTable(lcc, schemaName, new XPLAINResultSetTimingsDescriptor());
createXplainTable(lcc, schemaName, new XPLAINScanPropsDescriptor());
createXplainTable(lcc, schemaName, new XPLAINSortPropsDescriptor());
lcc.setRunTimeStatisticsMode(statsSave);
lcc.setXplainSchema(schemaName);
}
Aggregations