Search in sources :

Example 1 with StatisticsColumnData

use of org.apache.ignite.internal.processors.query.stat.messages.StatisticsColumnData in project ignite by apache.

the class StatisticsUtils method toMessage.

/**
 * Convert ColumnStatistics to StaticColumnData message.
 *
 * @param stat Column statistics to convert.
 * @return Converted stats column data message.
 * @throws IgniteCheckedException In case of errors.
 */
public static StatisticsColumnData toMessage(ColumnStatistics stat) throws IgniteCheckedException {
    GridH2ValueMessage msgMin = stat.min() == null ? null : GridH2ValueMessageFactory.toMessage(stat.min());
    GridH2ValueMessage msgMax = stat.max() == null ? null : GridH2ValueMessageFactory.toMessage(stat.max());
    return new StatisticsColumnData(msgMin, msgMax, stat.nulls(), stat.distinct(), stat.total(), stat.size(), stat.raw(), stat.version(), stat.createdAt());
}
Also used : GridH2ValueMessage(org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2ValueMessage) StatisticsColumnData(org.apache.ignite.internal.processors.query.stat.messages.StatisticsColumnData)

Example 2 with StatisticsColumnData

use of org.apache.ignite.internal.processors.query.stat.messages.StatisticsColumnData in project ignite by apache.

the class StatisticsUtils method toObjectData.

/**
 * Build statistics object data from values.
 *
 * @param keyMsg Statistics key.
 * @param type Statistics type.
 * @param stat Object statistics to convert.
 * @return Converted StatsObjectData message.
 * @throws IgniteCheckedException In case of errors.
 */
public static StatisticsObjectData toObjectData(StatisticsKeyMessage keyMsg, StatisticsType type, ObjectStatisticsImpl stat) throws IgniteCheckedException {
    Map<String, StatisticsColumnData> colData = new HashMap<>(stat.columnsStatistics().size());
    for (Map.Entry<String, ColumnStatistics> ts : stat.columnsStatistics().entrySet()) colData.put(ts.getKey(), toMessage(ts.getValue()));
    StatisticsObjectData data;
    if (stat instanceof ObjectPartitionStatisticsImpl) {
        ObjectPartitionStatisticsImpl partStats = (ObjectPartitionStatisticsImpl) stat;
        data = new StatisticsObjectData(keyMsg, stat.rowCount(), type, partStats.partId(), partStats.updCnt(), colData);
    } else
        data = new StatisticsObjectData(keyMsg, stat.rowCount(), type, 0, 0, colData);
    return data;
}
Also used : StatisticsObjectData(org.apache.ignite.internal.processors.query.stat.messages.StatisticsObjectData) HashMap(java.util.HashMap) StatisticsColumnData(org.apache.ignite.internal.processors.query.stat.messages.StatisticsColumnData) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

StatisticsColumnData (org.apache.ignite.internal.processors.query.stat.messages.StatisticsColumnData)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 GridH2ValueMessage (org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2ValueMessage)1 StatisticsObjectData (org.apache.ignite.internal.processors.query.stat.messages.StatisticsObjectData)1