3

我正在尝试将 apache ignite 与 spark 集成,我是 apache ignite 的新手。我想将数据保存在分布式缓存中并检索它。

我通过在 spark 中加载文件并尝试使用 Apache Ignite 的 sharedRDD.savePairs(key,value) 保存在缓存中创建了一个数据框。键是字符串类型,值是火花数据帧类型。现在我想检索存储的数据并打印它。我什至不确定它是否真的与类型数据框一起保存。

4

1 回答 1

5

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

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

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

使用“过滤器”方法读取值

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

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

使用 SQL 获取值

于 2015-12-17T15:59:14.077 回答