Hi Alexey,

Thank you for the response.
I changed my code based on your recommendation and i think with all the
different options I was trying I ended up with a sub-par code!
The below code does the update very fast (few secs)


       Collection<Integer> res = ignite.compute().broadcast(
                new IgniteCallable<Integer>() {
                    /** Auto-inject ignite instance. */
                    @IgniteInstanceResource
                    private Ignite ignite;

                    @Override public Integer call() {
                        IgniteCache<FactKey, Fact> cache =
                                ignite.getOrCreateCache("Fact");
                        Iterator<Cache.Entry&lt;FactKey, Fact>> iterator =
                                cache.localEntries().iterator();

                        FactKey key;
                        Integer cnt = 0;
                        while (iterator.hasNext()) {
                            key = iterator.next().getKey();

                            cache.invoke(key, (entry, args) -> {
                                Fact val = entry.getValue();
                                // do some logic
                                val.setAmount(val.getAmt1() +
val.getAmt2());
                                return val;
                            });
                            cnt++;
                            if(cnt%100 == 0) {
                                System.out.println(">>> Update Count: " +
cnt);
                            }
                        }
                        return cnt;
                    }
                }
        );


In regards to your comment on cache will not get updated using invoke. How
do I ensure that the new computed value gets stored in the cache. 
The first goal is to iterate through the cache and update a specific data
field in the cache in the fastest way possible. 
The second goal is to - the cache has writethrough/writebehind enabled and
hence the updates will need to be propagated to the database as well.





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Reply via email to