Apache Ignite SqlFieldsQuery游标问题
问题描述:
我正在使用SqlFieldsQuery缓存〜1_000_000行。Apache Ignite SqlFieldsQuery游标问题
QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery("select num from some_cache"))
我读过有关查询光标懒惰本性(http://apacheignite.gridgain.org/docs/cache-queries#section-querycursor)。但似乎来自缓存的所有数据都立即加载。因为我的查询需要很长时间,并且cursor.getAll()立即返回包含所有数据的集合。
这是缺乏一些配置或它的预期行为?
答
getAll
确实一次返回所有行。
QueryCursor
延伸Iterable
,使用迭代器来利用懒惰。
QueryCursor<List> cursor = cache.query(new SqlFieldsQuery("select num from some_cache"))
for (List l : cursor)
doSomething(l);
我用'getAll'只是为了测试数据已经加载。我想说的是,似乎所有的数据已经在'cache.query'期间被加载(不调用'getAll') –
好吧,看起来查询花费的时间比结果检索要多。这并不意味着延迟加载不起作用。 –