private void updateBaselineForJob(TuningJobDefinition tuningJobDefinition) {

    logger.info("Computing and updating baseline metric values for job: " + tuningJobDefinition.job.jobName);

    String sql = "SELECT AVG(resource_used) AS resource_used, AVG(execution_time) AS execution_time FROM "
        + "(SELECT job_exec_id, SUM(resource_used/(1024 * 3600)) AS resource_used, "
        + "SUM((finish_time - start_time - total_delay)/(1000 * 60))  AS execution_time, "
        + "MAX(start_time) AS start_time " + "FROM yarn_app_result WHERE job_def_id=:jobDefId "
        + "GROUP BY job_exec_id " + "ORDER BY start_time DESC " + "LIMIT :num) temp";

    logger.debug("Running query for baseline computation " + sql);

    SqlRow baseline = Ebean.createSqlQuery(sql)
        .setParameter("jobDefId", tuningJobDefinition.job.jobDefId)
        .setParameter("num", _numJobsForBaseline)
        .findUnique();

    Double avgResourceUsage = 0D;
    Double avgExecutionTime = 0D;
    avgResourceUsage = baseline.getDouble("resource_used");
    avgExecutionTime = baseline.getDouble("execution_time");
    tuningJobDefinition.averageExecutionTime = avgExecutionTime;
    tuningJobDefinition.averageResourceUsage = avgResourceUsage;
    tuningJobDefinition.averageInputSizeInBytes = getAvgInputSizeInBytes(tuningJobDefinition.job.jobDefId);

    logger.debug("Baseline metric values: Average resource usage=" + avgResourceUsage + " and Average execution time="
        + avgExecutionTime);
    tuningJobDefinition.update();
    logger.info("Updated baseline metric value for job: " + tuningJobDefinition.job.jobName);
  }
Adds baseline metric values for a job
@param tuningJobDefinition Job for which baseline is to be added
app/com/linkedin/drelephant/tuning/BaselineComputeUtil.java