You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Maksim Timonin <ti...@apache.org> on 2022/08/01 07:57:59 UTC

Re: IndexQuery with Transformer!

Hi Rafael,

Thanks for your interest. Currently IndexQuery doesn't
support transformers, but I think we can try to support this as IndexQuery
uses some infrastructure of ScanQuery. I've created a ticket [1] to support
this. I will have a look during this month.

Is `Cache.Entry::getKey` a single transformer function you actually use?

> And another question: does IndexQuery support local queries
(.setLocal(true))?

Yes, it does.


[1] https://issues.apache.org/jira/browse/IGNITE-17447

On Sat, Jul 30, 2022 at 1:36 PM Troilo, Rafael <Ra...@heigit.org>
wrote:

> Hi,
>
> we were looking to use  the IndexQuery instead of ScanQuery with filter,
> to speed up our queries.
> But unfortunately it seems that IndexQuery are not a replacement for
> ScanQuery with filter (if index exist on filter criteria!),
> as IndexQuery does not support transformers.
>
> Exception in thread "main" java.lang.UnsupportedOperationException:
> Transformers are supported only for SCAN queries.
>         at
> org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl.query(IgniteCacheProxyImpl.java:871)
>
> Any ideas how we can make use of indices but  still be able to use
> transformers or is  it  planned for further releases, this would be awesome.
> Here is an example what we want to use:
>
> ```java
> var personEntity = new QueryEntity(Integer.class, Person.class)
>     .addQueryField("orgId", Integer.class.getName(), null)
>     .addQueryField("salary", Integer.class.getName(), null)
>     .setIndexes(List.of(
>         new QueryIndex("salary", QueryIndexType.SORTED)));
>
> var ccfg = new CacheConfiguration<Integer, Person>("entityCache")
>     .setQueryEntities(List.of(personEntity));
>
> var cache = ignite.getOrCreateCache(ccfg);
>
> // Get only keys for persons earning more than 1,000.
> List<Integer> keys;
>
> // scan query
> keys = cache.query(new ScanQuery<>(
>     (k, p) -> p.getSalary() > 1000),
>     (IgniteClosure<Cache.Entry<Integer, Person>, Integer>)
> Cache.Entry::getKey).getAll();
>
> // index query
> keys = cache.query(new IndexQuery<Integer, Person>(Person.class)
>     .setCriteria(gt("salery", 1000)),
>     (IgniteClosure<Cache.Entry<Integer, Person>, Integer>)
> Cache.Entry::getKey).getAll();
> ```
>
> And another question: does IndexQuery support local queries
> (.setLocal(true))?
>
> Thank you and looking forward to  hear your opinions.
>
> Best,
> Rafael
>
>
>
> --
> Rafael Troilo
> HeiGIT gGmbH
> Heidelberg Institute for Geoinformation Technology at Heidelberg University
>
> https://heigit.org | rafael.troilo@heigit.org | phone +49-6221-533 484
>
> Postal address: Schloss-Wolfsbrunnenweg 33 | 69118 Heidelberg | Germany
> Offices: Berliner Str. 45 | 69120 Heidelberg | Germany
>
> Amtsgericht Mannheim | HRB 733765
> Managing Directors: Prof. Dr. Alexander Zipf | Dr. Gesa Schönberger
>