Hi limabean,
Can you please properly subscribe to the mailing list so that the community
receives email notifications? Here is the instruction:
http://apache-ignite-users.70518.x6.nabble.com/mailing_list/MailingListOptions.jtp?forum=1
limabean wrote
> I have a similar question to the one that is asked, except instead of a
> HashMap, I have a class that I have defined with indexes on the some of
> the properties. The code looks something like this:
>
> Ignite ignite = Ignition.start("ignite-config.xml")
> IgniteCache cache = ignite.getOrCreateCache("mycache");
>
> Map<Integer,Object> valueMap = new HashMap<Integer,Object>();
> Person p1 = new Person(1, 11, "Roger", 2000.00);
> cache.put(111, p1);
>
> Person p2 = new Person(2, 11, "Doger", 2500.00);
> cache.put(222, p2);
>
> I can run a SQL query like this:
> SqlQuery<AffinityKey<Integer>, Person> qry1 =
> new SqlQuery<>(Person.class, "select * from Person
> where salary < ?");
> qry1.setArgs(3000);
>
> But is there a way other than SQL to reference the fields in the Person
> class without
> first going through the cache.get(
> <some cache id here>
> ) on each entry ?
>
> For example, is it possible to find all Person objects that have 11 in
> that second field just using Java syntax on a client ?
>
> Thank you,
You can use predicate-based scan queries [1]. But note that it will have to
iterate through all the entries in cache, while with SQL you can create
indexes for fields you're querying by and the lookup will be much faster.
[1] https://apacheignite.readme.io/docs/cache-queries#scan-queries
-Val
--
View this message in context:
http://apache-ignite-users.70518.x6.nabble.com/Querying-HashMap-stored-as-value-in-IgniteCache-tp3507p3550.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.