首页 文章

尝试从apache的sharedRDD中检索数据点燃上下文

提问于
浏览
3

我正在尝试将apache点燃与火花融合,而且我是apache点燃的新手 . 我想将数据保存在分布式缓存中并检索它 .

我通过在spark中加载文件并尝试使用Apache Ignite的sharedRDD.savePairs(key,value)保存在缓存中来创建数据框 . 键的类型为string,value的类型为spark dataframe . 现在我想检索存储的数据并打印出来 . 我甚至不确定它是否实际上与类型数据帧一起保存 .

1 回答

  • 5

    要从RDD检索数据,您可以使用以下方法中的至少一种:

    1)sharedRDD.filter(...) . collect()方法 . 作为示例,下面的代码从名为“testCache”的缓存中获取包含单词“river”的所有值

    val cache = igniteContext.fromCache("testCache")
    val result = cache.filter(_._2.contains("river")).collect()
    

    Reading values using 'filter' method

    2)sharedRDD.sql(...)方法 .

    val cacheRdd = igniteContext.fromCache("personsCache")
    val result = cacheRdd.sql(
      "select name from Person where id > ? and id < ?", 10, 100)
    

    Getting values using SQL

相关问题