问题
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