public static void main(String[] args) throws Exception {
    OptimizerConfig config = new OptimizerConfig(args);
    SparkSession spark =
        SparkSession.builder()
            .appName(String.format(APP_NAME_FORMAT, config.getResourceId()))
            .getOrCreate();
    JavaSparkContext jsc = new JavaSparkContext(spark.sparkContext());
    if (!jsc.getConf().getBoolean("spark.dynamicAllocation.enabled", false)) {
      LOG.warn(
          "To better utilize computing resources, it is recommended to enable 'spark.dynamicAllocation.enabled' "
              + "and set 'spark.dynamicAllocation.maxExecutors' equal to 'OPTIMIZER_EXECUTION_PARALLEL'");
    }

    // calculate optimizer memory allocation
    int driverMemory = Utils.memoryStringToMb(jsc.getConf().get("spark.driver.memory", "1g"));
    int executorMemory = Utils.memoryStringToMb(jsc.getConf().get("spark.executor.memory", "1g"));
    config.setMemorySize(driverMemory + config.getExecutionParallel() * executorMemory);

    SparkOptimizer optimizer = new SparkOptimizer(config, jsc);
    OptimizerToucher toucher = optimizer.getToucher();
    toucher.withRegisterProperty(Resource.PROPERTY_JOB_ID, spark.sparkContext().applicationId());

    LOG.info("Starting the spark optimizer with configuration:{}", config);
    optimizer.startOptimizing();
  }
The {@code SparkOptimizer} acts as an entrypoint of the spark program
amoro-optimizer/amoro-optimizer-spark/src/main/java/org/apache/amoro/optimizer/spark/SparkOptimizer.java