【问题标题】:In memory cache persisted between batches spark structured streaming在批次之间持久存在的内存缓存中激发结构化流式传输
【发布时间】:2019-03-10 21:14:22
【问题描述】:

在 Scala 应用程序中拥有内存中 LRU 缓存的正确方法是什么?

我尝试使用 Guava 缓存,但我认为因为即使我将其用作单例,它也无法序列化,因此每个微批处理都会实例化一个新缓存。

为了处理事件,我需要在外部数据源中查找一些元数据,因此我希望避免每次调用都通过网络,而是在本地缓存一段时间。

【问题讨论】:

    标签: scala caching guava spark-structured-streaming


    【解决方案1】:

    您可以尝试在 mapGroupsWithState 或 flatMapGroupsWithState 中编写自己的逻辑

    这是一个有状态的存储,可以保存用于查找的计算值

    查看此链接: https://databricks.com/blog/2017/10/17/arbitrary-stateful-processing-in-apache-sparks-structured-streaming.html

    【讨论】:

      猜你喜欢
      • 2016-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-05
      • 2017-11-28
      • 1970-01-01
      • 1970-01-01
      • 2012-06-13
      相关资源
      最近更新 更多