private JobDefinition getJobDefinition(TuningInput tuningInput) {

    String jobDefId = tuningInput.getJobDefId();

    TuningJobDefinition tuningJobDefinition = TuningJobDefinition.find.select("*")
        .fetch(TuningJobDefinition.TABLE.job, "*")
        .where()
        .eq(TuningJobDefinition.TABLE.job + "." + JobDefinition.TABLE.jobDefId, jobDefId)
        .setMaxRows(1)
        .orderBy(TuningJobDefinition.TABLE.createdTs + " desc")
        .findUnique();

    if (tuningJobDefinition == null) {
      // Job new to tuning
      logger.debug("Registering job: " + tuningInput.getJobName() + " for auto tuning tuning");
      AutoTuningMetricsController.markNewAutoTuningJob();
      tuningJobDefinition = addNewJobForTuning(tuningInput);
    }
    return tuningJobDefinition.job;
  }
Returns the job definition corresponding to the given tuning input if it exists, else creates one and returns it
@param tuningInput Tuning Input corresponding to which job definition is to be returned
@return JobDefinition corresponding to the given tuning input
app/com/linkedin/drelephant/tuning/AutoTuningAPIHelper.java