Spark:从单个DStream中获取多个DStream

编程入门 行业动态 更新时间:2024-10-18 01:36:05
本文介绍了Spark:从单个DStream中获取多个DStream的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有可能在spark中从单个DStream中获取多个DStream.我的用例如下:我正在从HDFS文件获取日志数据流.日志行包含一个id(id = xyz).我需要根据ID对日志行进行不同的处理.因此,我尝试为输入Dstream中的每个ID设置不同的Dstream.我在文档中找不到任何相关内容.有谁知道如何在Spark中实现此目标,或指向此目标的任何链接.

Is is possible to get multiple DStream out of a single DStream in spark. My use case is follows: I am getting Stream of log data from HDFS file. The log line contains an id (id=xyz). I need to process log line differently based on the id. So I was trying to different Dstream for each id from input Dstream. I couldnt find anything related in documentation. Does anyone know how this can be achieved in Spark or point to any link for this.

谢谢

推荐答案

您不能从单个DStream中拆分多个DStream.您可以做的最好的事情是:-

You cannot Split multiple DStreams from Single DStreams. The best you can do is: -

  • 修改您的源系统以具有用于不同ID的不同流,然后您可以具有不同的作业来处理不同的流
  • 如果您的源无法更改并向您提供ID混合的流,那么您需要编写自定义逻辑来识别ID,然后执行适当的操作.
  • 我总是更喜欢#1,因为这是更清洁的解决方案,但是有些例外需要实现#2.

    I would always prefer #1 as that is cleaner solution but there are exceptions for which #2 needs to be implemented.

    更多推荐

    Spark:从单个DStream中获取多个DStream

    本文发布于:2023-11-25 23:01:17,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1631690.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:多个   Spark   DStream

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!