【问题标题】:scala code special syntax [duplicate]scala代码特殊语法[重复]
【发布时间】:2019-01-20 12:26:43
【问题描述】:

谁能向我解释一下 private[streaming] 的使用以及 _ssc 的含义(为什么下面代码的 sn-p 中使用了下划线):

private[streaming]
class PubsubInputDStream(
                          _ssc: StreamingContext,
                          val project: String,
                          val topic: Option[String],
                          val subscription: String,
                          val credential: SparkGCPCredentials,
                          val _storageLevel: StorageLevel
                        ) extends ReceiverInputDStream[SparkPubsubMessage](_ssc) {

  override def getReceiver(): Receiver[SparkPubsubMessage] = {
    new PubsubReceiver(project, topic, subscription, credential, _storageLevel)
  }
}

【问题讨论】:

  • 下划线没有特殊含义——我怀疑它只是流包的内部名称簿记

标签: scala apache-spark


【解决方案1】:

将某些东西设置为私有[steaming] 意味着它对于包流式传输是私有的(即它对子包也是可见的)。

下划线对于Scala语言来说是没有意义的,它可能是包作者命名约定的一部分(表示它是私有的)

【讨论】:

    猜你喜欢
    • 2013-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多