Hi,
I'm trying to figure out a more performant way of querying objects using Predicates in Hazelcast as I'm sure how I'm doing it isn't the most efficient.
Say, I have a Person object that has, FirstName (string), LastName (string), Address (Object) (stored in the Person Map). Address is another object (stored in the Address Map) and this has elements City (string) and PostCode (string).
I want to retruen all Person objects with Address.City = "New York".
How my querying currently works is I first of all get all Person objects. As I have no predicate for the Person object I get all Persons stored in the Map returned. then I iterate of all Person objects, do an "AddressMap".keySet(predicate) where Predicate is "City = 'New York" and then check that returned value equals to my Person.Address.City. If true, add that Person object to return list, if not continue to the next Person.
So in Pseudo...
Collection<Person> persons = getMap("Person").values();
for each Person {
Set<String> filteredKeys = getMap("Address").keySet(predicate); // predicate is City="New York"
if filteredKey contains Person.City
add Person to return set.
}
So my question, is there any way of "nesting" the queries. This is very slow, especially if I have a large number of Persons (say 2000) as it gets and iterates over them all (no predicate on Person object) and then does the check for City.Address.
I feel like I'm missing something so any help would be appreicated.
Cheers