zoukankan      html  css  js  c++  java
  • Scala 中object和class的区别

    Scala中没有静态类型,但是有有“伴侣对象”,起到类似的作用。

    Scala中类对象中不可有静态变量和静态方法,但是提供了“伴侣对象”的功能:在和类的同一个文件中定义同名的Object对象:(须在同一文件中;main方法定义在Object对象中)

    private[spark] class Client(
        val args: ClientArguments,
        val hadoopConf: Configuration,
        val sparkConf: SparkConf)
      extends Logging {...}
    
    object Client extends Logging {
      def main(argStrings: Array[String]) {
        if (!sys.props.contains("SPARK_SUBMIT")) {
          logWarning("WARNING: This client is deprecated and will be removed in a " +
            "future version of Spark. Use ./bin/spark-submit with "--master yarn"")
        }
    
        // Set an env variable indicating we are running in YARN mode.
        // Note that any env variable with the SPARK_ prefix gets propagated to all (remote) processes
        System.setProperty("SPARK_YARN_MODE", "true")
        val sparkConf = new SparkConf
    
        val args = new ClientArguments(argStrings, sparkConf)
        // to maintain backwards-compatibility
        if (!Utils.isDynamicAllocationEnabled(sparkConf)) {
          sparkConf.setIfMissing("spark.executor.instances", args.numExecutors.toString)
        }
        new Client(args, sparkConf).run()
      }
     ......
    }
  • 相关阅读:
    自动化基础知识
    第一章Google软件测试介绍
    《将博客搬至CSDN》
    二叉树的先序遍历和中序遍历分析(递归)
    java 部分快捷功能
    toString
    自增自减运算符剖析
    二进制数的直接表示
    编程中的&&和||
    npm 镜像地址设置
  • 原文地址:https://www.cnblogs.com/nele/p/5185501.html
Copyright © 2011-2022 走看看