【问题标题】:What is a supported streaming datasource to persist result?什么是支持的流数据源来持久化结果?
【发布时间】:2016-06-29 10:44:37
【问题描述】:

我正在尝试将新的流式写入功能与 spark 2.0.1-SNAPSHOT 一起使用。实际上支持哪个输出数据源来持久化结果? 我能够通过以下方式在控制台上显示输出:

Dataset<Event> testData = sqlContext
    .readStream()
    .schema(schema)
    .format("json")
    .load("s3://......")
    .as(encoder);

Dataset<Row> result = testData.filter("eventType = 'playerLoad'")
    .groupBy(col("country"), window(col("timestamp"), "10 minutes"))
    .agg(sum("startupTime").alias("tot"));

result.writeStream()  
      .outputMode(OutputMode.Complete())
      .format("console")
      .start()
      .awaitTermination();

但如果我尝试将 .format("console") 更改为 "json" 或 "jdbc",则会收到消息:数据源 xxx 不支持流式写入。

【问题讨论】:

    标签: java apache-spark apache-spark-sql spark-streaming apache-spark-dataset


    【解决方案1】:

    目前(截至 2016 年 7 月 9 日)有四个可用的流式接收器:

    • ConsoleSinkconsole 格式。
    • FileStreamSinkparquet 格式。
    • ForeachSink 用于 foreach 运算符。
    • MemorySinkmemory

    您可以创建自己的流格式实现StreamSinkProvider

    【讨论】:

      猜你喜欢
      • 2019-10-17
      • 1970-01-01
      • 2019-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多