Search in sources :

Example 1 with Statistics

use of org.apache.derby.catalog.Statistics in project derby by apache.

the class SYSSTATISTICSRowFactory method buildDescriptor.

public TupleDescriptor buildDescriptor(ExecRow row, TupleDescriptor parentDesc, DataDictionary dd) throws StandardException {
    if (SanityManager.DEBUG) {
        SanityManager.ASSERT(row.nColumns() == SYSSTATISTICS_COLUMN_COUNT, "Wrong number of columns for a SYSSTATISTICS row");
    }
    DataValueDescriptor col;
    String scratch;
    UUIDFactory uuidFactory = getUUIDFactory();
    UUID statUUID, statReferenceUUID, statTableUUID;
    String statName;
    /* 1st column is UUID */
    col = row.getColumn(SYSSTATISTICS_ID);
    scratch = col.getString();
    statUUID = uuidFactory.recreateUUID(scratch);
    /* 2nd column is reference UUID */
    col = row.getColumn(SYSSTATISTICS_REFERENCEID);
    scratch = col.getString();
    statReferenceUUID = uuidFactory.recreateUUID(scratch);
    /* 3rd column is table UUID */
    col = row.getColumn(SYSSTATISTICS_TABLEID);
    scratch = col.getString();
    statTableUUID = uuidFactory.recreateUUID(scratch);
    /* 4th column is timestamp */
    col = row.getColumn(SYSSTATISTICS_TIMESTAMP);
    Timestamp updateTime = (Timestamp) col.getObject();
    /* 5th column is stat type -- string */
    col = row.getColumn(SYSSTATISTICS_TYPE);
    String statType = col.getString();
    /* 6th column is stat valid -- boolean */
    col = row.getColumn(SYSSTATISTICS_VALID);
    boolean valid = col.getBoolean();
    /* 7th column is column count */
    col = row.getColumn(SYSSTATISTICS_COLCOUNT);
    int columnCount = col.getInt();
    /* 8th column is statistics itself */
    col = row.getColumn(SYSSTATISTICS_STAT);
    Statistics stat = (Statistics) col.getObject();
    return new StatisticsDescriptor(dd, statUUID, statReferenceUUID, // statName, colMap,
    statTableUUID, statType, stat, columnCount);
}
Also used : StatisticsDescriptor(org.apache.derby.iapi.sql.dictionary.StatisticsDescriptor) UUIDFactory(org.apache.derby.iapi.services.uuid.UUIDFactory) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UUID(org.apache.derby.catalog.UUID) Timestamp(java.sql.Timestamp) Statistics(org.apache.derby.catalog.Statistics)

Example 2 with Statistics

use of org.apache.derby.catalog.Statistics in project derby by apache.

the class SYSSTATISTICSRowFactory method makeRow.

/**
 * Make a SYSSTATISTICS row
 *
 * @return	Row suitable for inserting into SYSSTATISTICS.
 *
 * @exception   StandardException thrown on failure
 */
public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
    String myID = null, referenceID = null, tableID = null;
    String statName = null, colMap = null, statType = null;
    Timestamp updateTime = null;
    int columnCount = 0;
    Statistics statisticsObject = null;
    boolean validStat = false;
    ExecRow row = getExecutionFactory().getValueRow(SYSSTATISTICS_COLUMN_COUNT);
    if (td != null) {
        StatisticsDescriptor statDesc = (StatisticsDescriptor) td;
        myID = statDesc.getUUID().toString();
        tableID = statDesc.getTableUUID().toString();
        referenceID = statDesc.getReferenceID().toString();
        updateTime = statDesc.getUpdateTimestamp();
        statType = statDesc.getStatType();
        validStat = statDesc.isValid();
        statisticsObject = statDesc.getStatistic();
        columnCount = statDesc.getColumnCount();
    }
    row.setColumn(1, new SQLChar(myID));
    row.setColumn(2, new SQLChar(referenceID));
    row.setColumn(3, new SQLChar(tableID));
    row.setColumn(4, new SQLTimestamp(updateTime));
    row.setColumn(5, new SQLChar(statType));
    row.setColumn(6, new SQLBoolean(validStat));
    row.setColumn(7, new SQLInteger(columnCount));
    row.setColumn(8, new UserType(statisticsObject));
    return row;
}
Also used : StatisticsDescriptor(org.apache.derby.iapi.sql.dictionary.StatisticsDescriptor) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) Timestamp(java.sql.Timestamp) Statistics(org.apache.derby.catalog.Statistics) UserType(org.apache.derby.iapi.types.UserType)

Aggregations

Timestamp (java.sql.Timestamp)2 Statistics (org.apache.derby.catalog.Statistics)2 StatisticsDescriptor (org.apache.derby.iapi.sql.dictionary.StatisticsDescriptor)2 UUID (org.apache.derby.catalog.UUID)1 UUIDFactory (org.apache.derby.iapi.services.uuid.UUIDFactory)1 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)1 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)1 UserType (org.apache.derby.iapi.types.UserType)1