Size of Predicate results in Hazelcast

﹥>﹥吖頭↗ 提交于 2019-12-11 05:06:45

问题


What is the best way of finding size of a predicate results in hazelcast IMap?

There is no direct size support in MapProxyImpl.java and size() will be calculated on returned collection which in undesired in this case.

Do you have any recommendations ?

Thanks.


回答1:


You're probably looking for an IMap::size(Predicate) overload which is not yet available, anyhow it sounds like a nice feature. Would you like to create a feature request for that?

To solve the problem at the moment, I guess the best workaround is using an EntryProcessor, running against all keys, basically executing your predicate and returning 1 or 0 for each key and just sum the result up on the caller. Sorry for not having a better solution but maybe someone else has an amazing idea :)




回答2:


there is an answer on the ticket

Since 3.8 you can use map.aggregate(Aggregators.count());

i have not tested it yet



来源:https://stackoverflow.com/questions/38474000/size-of-predicate-results-in-hazelcast

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!