【问题标题】:Apache Spark with Scala Merge streaming textApache Spark 与 Scala 合并流式文本
【发布时间】:2017-12-17 23:39:45
【问题描述】:

我想合并流数据

val contents = tweets.map(status => status.getText())
val tSender = tweets.map(status => status.getUser().getScreenName())
tSender.print() 
contents.print()

此代码有效,但我需要 tSender + 内容格式。 我试过了

println(tSender + contents) 

但它不起作用。 如果有人知道某事可以帮助我吗?

【问题讨论】:

    标签: scala apache-spark spark-streaming


    【解决方案1】:

    只需将你想要的所有字段提取到一起:

    tweets.map(status => 
      s"${ status.getUser().getScreenName()} ${status.getText()}"
    ).print
    

    【讨论】:

      猜你喜欢
      • 2015-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-17
      • 2016-04-27
      • 2015-11-28
      • 2021-02-21
      • 2016-09-28
      相关资源
      最近更新 更多