use of org.apache.ignite.internal.processors.query.stat.StatisticsKey in project ignite by apache.
the class ColumnLocalDataViewSupplier method columnLocalStatisticsViewSupplier.
/**
* Statistics column local node data view filterable supplier.
*
* @param filter Filter.
* @return Iterable with statistics column local node data views.
*/
public Iterable<StatisticsColumnLocalDataView> columnLocalStatisticsViewSupplier(Map<String, Object> filter) {
String type = (String) filter.get(StatisticsColumnPartitionDataViewWalker.TYPE_FILTER);
if (type != null && !StatisticsColumnConfigurationView.TABLE_TYPE.equalsIgnoreCase(type))
return Collections.emptyList();
String schema = (String) filter.get(StatisticsColumnLocalDataViewWalker.SCHEMA_FILTER);
String name = (String) filter.get(StatisticsColumnLocalDataViewWalker.NAME_FILTER);
String column = (String) filter.get(StatisticsColumnPartitionDataViewWalker.COLUMN_FILTER);
Map<StatisticsKey, ObjectStatisticsImpl> locStatsMap;
if (!F.isEmpty(schema) && !F.isEmpty(name)) {
StatisticsKey key = new StatisticsKey(schema, name);
ObjectStatisticsImpl objLocStat = repo.getLocalStatistics(key);
if (objLocStat == null)
return Collections.emptyList();
locStatsMap = Collections.singletonMap(key, objLocStat);
} else
locStatsMap = repo.localStatisticsMap().entrySet().stream().filter(e -> F.isEmpty(schema) || schema.equals(e.getKey().schema())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
List<StatisticsColumnLocalDataView> res = new ArrayList<>();
for (Map.Entry<StatisticsKey, ObjectStatisticsImpl> localStatsEntry : locStatsMap.entrySet()) {
StatisticsKey key = localStatsEntry.getKey();
ObjectStatisticsImpl stat = localStatsEntry.getValue();
if (column == null) {
for (Map.Entry<String, ColumnStatistics> colStat : localStatsEntry.getValue().columnsStatistics().entrySet()) {
StatisticsColumnLocalDataView colStatView = new StatisticsColumnLocalDataView(key, colStat.getKey(), stat);
res.add(colStatView);
}
} else {
ColumnStatistics colStat = localStatsEntry.getValue().columnStatistics(column);
if (colStat != null) {
StatisticsColumnLocalDataView colStatView = new StatisticsColumnLocalDataView(key, column, stat);
res.add(colStatView);
}
}
}
return res;
}
use of org.apache.ignite.internal.processors.query.stat.StatisticsKey in project ignite by apache.
the class ColumnConfigurationViewSupplier method columnConfigurationViewSupplier.
/**
* Statistics column configuration view filterable supplier.
*
* @param filter Filter.
* @return Iterable with selected statistics column configuration views.
*/
public Iterable<StatisticsColumnConfigurationView> columnConfigurationViewSupplier(Map<String, Object> filter) {
String schema = (String) filter.get(StatisticsColumnConfigurationViewWalker.SCHEMA_FILTER);
String name = (String) filter.get(StatisticsColumnConfigurationViewWalker.NAME_FILTER);
Collection<StatisticsObjectConfiguration> configs;
try {
if (!F.isEmpty(schema) && !F.isEmpty(name)) {
StatisticsKey key = new StatisticsKey(schema, name);
StatisticsObjectConfiguration keyCfg = cfgMgr.config(key);
if (keyCfg == null)
return Collections.emptyList();
configs = Collections.singletonList(keyCfg);
} else
configs = cfgMgr.getAllConfig();
} catch (IgniteCheckedException e) {
log.warning("Error while getting statistics configuration: " + e.getMessage(), e);
configs = Collections.emptyList();
}
List<StatisticsColumnConfigurationView> res = new ArrayList<>();
for (StatisticsObjectConfiguration cfg : configs) {
for (StatisticsColumnConfiguration colCfg : cfg.columnsAll().values()) {
if (!colCfg.tombstone())
res.add(new StatisticsColumnConfigurationView(cfg, colCfg));
}
}
return res;
}
use of org.apache.ignite.internal.processors.query.stat.StatisticsKey in project ignite by apache.
the class CommandProcessor method processAnalyzeCommand.
/**
* Process analyze command.
*
* @param cmd Sql analyze command.
*/
private void processAnalyzeCommand(SqlAnalyzeCommand cmd) throws IgniteCheckedException {
ctx.security().authorize(SecurityPermission.CHANGE_STATISTICS);
IgniteH2Indexing indexing = (IgniteH2Indexing) ctx.query().getIndexing();
StatisticsObjectConfiguration[] objCfgs = cmd.configurations().stream().map(t -> {
if (t.key().schema() == null) {
StatisticsKey key = new StatisticsKey(cmd.schemaName(), t.key().obj());
return new StatisticsObjectConfiguration(key, t.columns().values(), t.maxPartitionObsolescencePercent());
} else
return t;
}).toArray(StatisticsObjectConfiguration[]::new);
indexing.statsManager().collectStatistics(objCfgs);
}
use of org.apache.ignite.internal.processors.query.stat.StatisticsKey in project ignite by apache.
the class GridH2Table method tableStatistics.
/**
* Get actual table statistics if exists.
*
* @return Table statistics or {@code null} if there is no statistics available.
*/
public ObjectStatistics tableStatistics() {
GridCacheContext cacheContext = cacheInfo.cacheContext();
if (cacheContext == null)
return null;
IgniteH2Indexing indexing = (IgniteH2Indexing) cacheContext.kernalContext().query().getIndexing();
return indexing.statsManager().getLocalStatistics(new StatisticsKey(identifier.schema(), identifier.table()));
}
use of org.apache.ignite.internal.processors.query.stat.StatisticsKey in project ignite by apache.
the class ColumnPartitionDataViewSupplier method columnPartitionStatisticsViewSupplier.
/**
* Statistics column partition data view filterable supplier.
*
* @param filter Filter.
* @return Iterable with statistics column partition data views.
*/
public Iterable<StatisticsColumnPartitionDataView> columnPartitionStatisticsViewSupplier(Map<String, Object> filter) {
String type = (String) filter.get(StatisticsColumnPartitionDataViewWalker.TYPE_FILTER);
if (type != null && !StatisticsColumnConfigurationView.TABLE_TYPE.equalsIgnoreCase(type))
return Collections.emptyList();
String schema = (String) filter.get(StatisticsColumnPartitionDataViewWalker.SCHEMA_FILTER);
String name = (String) filter.get(StatisticsColumnPartitionDataViewWalker.NAME_FILTER);
Integer partId = (Integer) filter.get(StatisticsColumnPartitionDataViewWalker.PARTITION_FILTER);
String column = (String) filter.get(StatisticsColumnPartitionDataViewWalker.COLUMN_FILTER);
Map<StatisticsKey, Collection<ObjectPartitionStatisticsImpl>> partsStatsMap;
if (!F.isEmpty(schema) && !F.isEmpty(name)) {
StatisticsKey key = new StatisticsKey(schema, name);
Collection<ObjectPartitionStatisticsImpl> keyStat;
if (partId == null)
keyStat = store.getLocalPartitionsStatistics(key);
else {
ObjectPartitionStatisticsImpl partStat = store.getLocalPartitionStatistics(key, partId);
keyStat = (partStat == null) ? Collections.emptyList() : Collections.singletonList(partStat);
}
partsStatsMap = Collections.singletonMap(key, keyStat);
} else
partsStatsMap = store.getAllLocalPartitionsStatistics(schema);
List<StatisticsColumnPartitionDataView> res = new ArrayList<>();
for (Map.Entry<StatisticsKey, Collection<ObjectPartitionStatisticsImpl>> partsStatsEntry : partsStatsMap.entrySet()) {
StatisticsKey key = partsStatsEntry.getKey();
for (ObjectPartitionStatisticsImpl partStat : partsStatsEntry.getValue()) {
if (column == null) {
for (Map.Entry<String, ColumnStatistics> colStatEntry : partStat.columnsStatistics().entrySet()) res.add(new StatisticsColumnPartitionDataView(key, colStatEntry.getKey(), partStat));
} else {
ColumnStatistics colStat = partStat.columnStatistics(column);
if (colStat != null)
res.add(new StatisticsColumnPartitionDataView(key, column, partStat));
}
}
}
return res;
}
Aggregations