Stamatis Zampetakis created HIVE-24402:
------------------------------------------

             Summary: Refactor AbstractCliConfig to be final, immutable, and 
initialisable using a builder
                 Key: HIVE-24402
                 URL: https://issues.apache.org/jira/browse/HIVE-24402
             Project: Hive
          Issue Type: Task
            Reporter: Stamatis Zampetakis
            Assignee: Stamatis Zampetakis


The fact that the class is abstract indicates that it is meant to be subclassed 
but going over the existing use-cases there does not seem a valid reason for 
this design. Moreover, the class is mutable while in practice there is no 
reason for this.

Roughly the idea is to replace the subclasses in 
[CliConfigs|https://github.com/apache/hive/blob/master/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CliConfigs.java]
 with simple instanciations using a builder while at the same time in an 
attempt to limit the extension points and simplify the code.

+Before+
{code:java}
  public static class MinimrCliConfig extends AbstractCliConfig {
    public MinimrCliConfig() {
      super(CoreCliDriver.class);
      try {
        setQueryDir("ql/src/test/queries/clientpositive");
        includesFrom(testConfigProps, "minimr.query.files");
        setResultsDir("ql/src/test/results/clientpositive");
        setLogDir("itests/qtest/target/qfile-results/clientpositive");
        setInitScript("q_test_init_for_minimr.sql");
        setCleanupScript("q_test_cleanup.sql");
        setHiveConfDir("");
        setClusterType(MiniClusterType.MR);
      } catch (Exception e) {
        throw new RuntimeException("can't construct cliconfig", e);
      }
    }
  }
{code}
+After+
{code:java}
  public static final CliConfig MINI_MR = new 
CliConfig.Builder(CoreCliDriver.class)
      .queryDir("ql/src/test/queries/clientpositive")
      .resultDir("ql/src/test/results/clientpositive")
      .logDir("itests/qtest/target/qfile-results/clientpositive")
      .addQueryFiles(testConfigProps, "minimr.query.files")
      .initScriptFile("q_test_init_for_minimr.sql")
      .cleanupScriptFile("q_test_cleanup.sql")
      .cluster(MiniClusterType.MR)
      .build();
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to