use of org.apache.ignite.internal.processors.query.stat.config.StatisticsObjectConfiguration in project ignite by apache.
the class StatisticsAbstractTest method makeStatistics.
/**
* Collect or refresh statistics.
*
* @param collect If {@code true} - collect new statistics, if {@code false} - update existing.
* @param targets
*/
private void makeStatistics(boolean collect, StatisticsTarget... targets) {
try {
Map<StatisticsTarget, Long> expectedVersion = new HashMap<>();
IgniteStatisticsManagerImpl statMgr = statisticsMgr(0);
for (StatisticsTarget target : targets) {
StatisticsObjectConfiguration currCfg = statMgr.statisticConfiguration().config(target.key());
Predicate<StatisticsColumnConfiguration> pred;
if (F.isEmpty(target.columns()))
pred = c -> true;
else {
Set<String> cols = Arrays.stream(target.columns()).collect(Collectors.toSet());
pred = c -> cols.contains(c.name());
}
Long expVer = (currCfg == null) ? 1L : currCfg.columnsAll().values().stream().filter(pred).mapToLong(StatisticsColumnConfiguration::version).min().orElse(0L) + 1;
expectedVersion.put(target, expVer);
}
if (collect)
statisticsMgr(0).collectStatistics(buildDefaultConfigurations(targets));
else
statisticsMgr(0).refreshStatistics(targets);
awaitStatistics(TIMEOUT, expectedVersion);
} catch (Exception ex) {
throw new IgniteException(ex);
}
}
use of org.apache.ignite.internal.processors.query.stat.config.StatisticsObjectConfiguration in project ignite by apache.
the class IgniteStatisticsHelper method buildDefaultConfigurations.
/**
* Build object configurations array with all default parameters from specified targets.
*
* @param targets Targets to build configurations from.
* @return StatisticsObjectConfiguration array.
*/
public static StatisticsObjectConfiguration[] buildDefaultConfigurations(StatisticsTarget... targets) {
StatisticsObjectConfiguration[] res = Arrays.stream(targets).map(t -> {
List<StatisticsColumnConfiguration> colCfgs;
if (t.columns() == null)
colCfgs = Collections.emptyList();
else
colCfgs = Arrays.stream(t.columns()).map(name -> new StatisticsColumnConfiguration(name, null)).collect(Collectors.toList());
return new StatisticsObjectConfiguration(t.key(), colCfgs, StatisticsObjectConfiguration.DEFAULT_OBSOLESCENCE_MAX_PERCENT);
}).toArray(StatisticsObjectConfiguration[]::new);
return res;
}
Aggregations