use of org.apache.hadoop.hive.ql.plan.mapper.StatsSource in project hive by apache.
the class StatsRulesProcFactory method applyRuntimeStats.
private static Statistics applyRuntimeStats(Context context, Statistics stats, Operator<?> op) {
if (!((HiveConf) context.getConf()).getBoolVar(ConfVars.HIVE_QUERY_REEXECUTION_ENABLED)) {
return stats;
}
PlanMapper pm = context.getPlanMapper();
OpTreeSignature treeSig = pm.getSignatureOf(op);
pm.link(op, treeSig);
StatsSource statsSource = context.getStatsSource();
if (!statsSource.canProvideStatsFor(op.getClass())) {
return stats;
}
Optional<OperatorStats> os = statsSource.lookup(treeSig);
if (!os.isPresent()) {
return stats;
}
LOG.debug("using runtime stats for {}; {}", op, os.get());
Statistics outStats = stats.clone();
outStats = outStats.scaleToRowCount(os.get().getOutputRecords(), false);
outStats.setRuntimeStats(true);
return outStats;
}
use of org.apache.hadoop.hive.ql.plan.mapper.StatsSource in project hive by apache.
the class HiveRelMdRuntimeRowCount method getRuntimeRowCount.
public Optional<Long> getRuntimeRowCount(RelNode rel) {
RelOptCluster cluster = rel.getCluster();
Context context = cluster.getPlanner().getContext();
if (context instanceof HivePlannerContext) {
StatsSource ss = ((HivePlannerContext) context).unwrap(StatsSource.class);
if (ss.canProvideStatsFor(rel.getClass())) {
Optional<OperatorStats> os = ss.lookup(RelTreeSignature.of(rel));
if (os.isPresent()) {
long outputRecords = os.get().getOutputRecords();
return Optional.of(outputRecords);
}
}
}
return Optional.empty();
}
Aggregations