4 Replies Latest reply on Nov 4, 2012 5:33 AM by Srinivas Narayanan

    Using DistributedCallable for search/filtering

    Srinivas Narayanan Newbie

      I am trying to use Distributed Callable approach for doing search/filtering for my Infinispan Proof of Concept.

       

      I will provide an example:

       

      I have Person objects stored across the grid and I want to find number of Person objects which hail from a specific city (assuming city is a attribute of Person). So I create a DistributedCallable filter. The filter object is sent across to all nodes. Now since I have to search across all the Person objects in the system, in each node I get the cache.keyset() and do the filtering to get the count. The keyset() ofcourse gives me a set of local entries (which would contain duplicates because I have a replication factor of two). Now from the outputs of these callables, I do an addition and then divide it by number of replicas (something close to that).

       

      While this is doable, it is not very nice. First I am using keyset() which is considered a bad practice in production (according to the javadoc). Also the division of number of replicas seems non-intuitive. Is there a better way?

       

      I initially tried using hibernate/lucene query based stuff but somehow the setting up the index was complex (it always gave me wrong results) and hence I tried using the DIstributedCallable approach.

       

      Any help will be appreciated.

       

      Thanks

       

      Best Regards

      Srini