use of org.apache.ignite.internal.processors.query.stat.messages.StatisticsObjectData 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;
}
use of org.apache.ignite.internal.processors.query.stat.messages.StatisticsObjectData in project ignite by apache.
the class IgniteStatisticsPersistenceStoreImpl method saveLocalPartitionStatistics.
/**
* {@inheritDoc}
*/
@Override
public void saveLocalPartitionStatistics(StatisticsKey key, ObjectPartitionStatisticsImpl stat) {
if (!checkMetastore("Unable to store local partition statistics %s.%s:%d", key.schema(), key.obj(), stat.partId()))
return;
String partKey = getPartKeyPrefix(key) + stat.partId();
StatisticsKeyMessage keyMsg = new StatisticsKeyMessage(key.schema(), key.obj(), null);
try {
StatisticsObjectData statsMsg = StatisticsUtils.toObjectData(keyMsg, StatisticsType.PARTITION, stat);
if (log.isTraceEnabled())
log.trace("Writing statistics by key " + partKey);
writeMeta(partKey, statsMsg);
} catch (IgniteCheckedException e) {
log.warning(String.format("Error while storing local partition statistics %s.%s:%d", key.schema(), key.obj(), stat.partId()), e);
}
}
use of org.apache.ignite.internal.processors.query.stat.messages.StatisticsObjectData in project ignite by apache.
the class IgniteStatisticsPersistenceStoreImpl method getAllLocalPartitionsStatistics.
/**
* {@inheritDoc}
*/
@Override
public Map<StatisticsKey, Collection<ObjectPartitionStatisticsImpl>> getAllLocalPartitionsStatistics(String schema) {
String prefix = (schema == null) ? STAT_DATA_PREFIX : STAT_DATA_PREFIX + META_SEPARATOR + schema;
Map<StatisticsKey, Collection<ObjectPartitionStatisticsImpl>> res = new HashMap<>();
try {
iterateMeta(prefix, (k, v) -> {
StatisticsKey key = getStatsKey(k);
StatisticsObjectData statData = (StatisticsObjectData) v;
try {
ObjectPartitionStatisticsImpl stat = StatisticsUtils.toObjectPartitionStatistics(null, statData);
res.computeIfAbsent(key, k1 -> new ArrayList<>()).add(stat);
} catch (IgniteCheckedException e) {
log.warning(String.format("Error during reading statistics %s.%s by key %s", key.schema(), key.obj(), k));
}
}, true);
} catch (IgniteCheckedException e) {
log.warning("Unable to read local partition statistcs", e);
}
return res;
}
Aggregations