从Java Thin客户端获取Apache Ignite缓存中的所有键。

huangapple go评论125阅读模式
英文:

Getting All keys from Apache Ignite cache from Java Thin client

问题

现在我正在使用 Apache Ignite 2.8.0。

public void run() {
    for (int i = 0; i < 100000; i++) {
        c.put(i, s);
    }
}

我已经通过上面的代码放入了所有的值,现在我想从 Java Thin Client 中获取缓存中的所有键,我应该如何获取所有键?

英文:

> Now i am using apache ignite 2.8.0.

  public void run(){  
 
        for(int i=0;i&lt;100000;i++)
        {
		 c.put(i,s);  
        }}

> I was put all the values by above code, now i want to get all the keys in that cache, how can i get all the keys from java thin client?

答案1

得分: 2

你可以使用扫描查询来实现这个。可以针对整个缓存或每个分区进行扫描。关于如何使用查询的文档中有说明(主要涉及SQL,也适用于扫描查询)。

最简单的方法是
cache.query(new ScanQuery()).getAll(); // 返回一个键值对集合。

英文:

You can use Scan Query to do that. Scan the whole cache or on per partition basis. There's a documentation on using queries with thin client (it mostly concerns SQL, should work with ScanQuery too).

The simplest one should be
cache.query(new ScanQuery()).getAll(); // Returns a collection of key-value pairs.

huangapple
  • 本文由 发表于 2020年3月16日 15:04:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/60701597.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定