code: private Map<String, String> mergeSparkParamsFromSettings(Map<String, String> params) {
      if (params == null) params = new HashMap<String, String>();
  
      Map<String, String> env = System.getenv();
  
      for (String[] varPair : SPARK_ENV_VARS) {
        if (params.containsKey(varPair[0])) continue; // already set in params
  
        // Read setting either from System Properties, or environment variable.
        // Env variable has lower priority if both are set.
        String value = System.getProperty(varPair[1], env.get(varPair[0]));
        if (value != null && value.length() > 0) params.put(varPair[0], value);
      }
  
      // Some well-known defaults
      if (!params.containsKey("SPARK_MASTER")) params.put("SPARK_MASTER", DEFAULT_SPARK_MASTER);
      if (!params.containsKey("SPARK_APPNAME")) params.put("SPARK_APPNAME", DEFAULT_SPARK_APPNAME);
      params.put("SPARK_SERIALIZER", "io.spark.content.KryoRegistrator");
      Gson gson = new Gson();
  
      mLog.info(String.format(">>>>>>> params = %s", gson.toJson(params)));
  
      return params;
    }
docs: /* merge priority is as follows: (1) already set in params, (2) in system properties (e.g., -Dspark.home=xxx), (3) in
  environment variables (e.g., export SPARK_HOME=xxx)
  
  @param params
  @return