Search in sources :

Example 1 with XPLAINSortPropsDescriptor

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);
}
Also used : XPLAINResultSetDescriptor(org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor) XPLAINScanPropsDescriptor(org.apache.derby.impl.sql.catalog.XPLAINScanPropsDescriptor) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) XPLAINResultSetTimingsDescriptor(org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor) XPLAINSortPropsDescriptor(org.apache.derby.impl.sql.catalog.XPLAINSortPropsDescriptor)

Example 2 with XPLAINSortPropsDescriptor

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);
}
Also used : XPLAINSortPropsDescriptor(org.apache.derby.impl.sql.catalog.XPLAINSortPropsDescriptor) XPLAINScanPropsDescriptor(org.apache.derby.impl.sql.catalog.XPLAINScanPropsDescriptor) UUID(org.apache.derby.catalog.UUID)

Example 3 with XPLAINSortPropsDescriptor

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);
}
Also used : XPLAINSortPropsDescriptor(org.apache.derby.impl.sql.catalog.XPLAINSortPropsDescriptor) FormatableProperties(org.apache.derby.iapi.services.io.FormatableProperties)

Example 4 with XPLAINSortPropsDescriptor

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);
}
Also used : XPLAINSortPropsDescriptor(org.apache.derby.impl.sql.catalog.XPLAINSortPropsDescriptor) Properties(java.util.Properties)

Example 5 with XPLAINSortPropsDescriptor

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);
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) XPLAINSortPropsDescriptor(org.apache.derby.impl.sql.catalog.XPLAINSortPropsDescriptor) XPLAINStatementDescriptor(org.apache.derby.impl.sql.catalog.XPLAINStatementDescriptor) XPLAINResultSetDescriptor(org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor) LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) XPLAINScanPropsDescriptor(org.apache.derby.impl.sql.catalog.XPLAINScanPropsDescriptor) XPLAINStatementTimingsDescriptor(org.apache.derby.impl.sql.catalog.XPLAINStatementTimingsDescriptor) TransactionController(org.apache.derby.iapi.store.access.TransactionController) XPLAINResultSetTimingsDescriptor(org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor)

Aggregations

XPLAINSortPropsDescriptor (org.apache.derby.impl.sql.catalog.XPLAINSortPropsDescriptor)5 XPLAINScanPropsDescriptor (org.apache.derby.impl.sql.catalog.XPLAINScanPropsDescriptor)3 XPLAINResultSetDescriptor (org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor)2 XPLAINResultSetTimingsDescriptor (org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor)2 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 Properties (java.util.Properties)1 UUID (org.apache.derby.catalog.UUID)1 FormatableProperties (org.apache.derby.iapi.services.io.FormatableProperties)1 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)1 TransactionController (org.apache.derby.iapi.store.access.TransactionController)1 XPLAINStatementDescriptor (org.apache.derby.impl.sql.catalog.XPLAINStatementDescriptor)1 XPLAINStatementTimingsDescriptor (org.apache.derby.impl.sql.catalog.XPLAINStatementTimingsDescriptor)1 StandardException (org.apache.derby.shared.common.error.StandardException)1