I want to get the data from multiple caches using SELECT query from client
node. The affinity key for all the caches is same.

Since I know that the data in all caches is collocated, I just want make
sure that sql gets executed only on one of the node(which is primary or
secondary for that data) and not *on all nodes.*

The way we submit the tasks using affinity key, can we submit the sql using
a affinity key so that it gets executed only on a node which owns that data?

Thanks,
Prasad


On Wed, Jul 25, 2018 at 3:01 PM Stanislav Lukyanov <stanlukya...@gmail.com>
wrote:

> What do you mean by “execute select query on cache using affinity key”
>
> and what is the problem you’re trying to solve?
>
>
>
> Stan
>
>
>
> *From: *Prasad Bhalerao <prasadbhalerao1...@gmail.com>
> *Sent: *25 июля 2018 г. 10:03
> *To: *user@ignite.apache.org
> *Subject: ****UNCHECKED*** Executing SQL on cache using affinnity key
>
>
>
> Hi,
>
>
>
> Is there any way to execute select query on cache using affinity key?
>
>
>
> As per this link:
> https://apacheignite.readme.io/docs/collocate-compute-and-data#section-affinity-call-and-run-methods
>
>
>
> It can be done as follows:
>
>
>
> compute.affinityCall(*CACHE_NAME*, *affinityKey*, () -> {
>
>   SqlFieldsQuery sqlFieldsQuery = *new 
> *SqlFieldsQuery(SELECT_STATEMENT).setArgs(args);
>   sqlFieldsQuery.setDistributedJoins(*false*);
>   sqlFieldsQuery.setLocal(*true*);
>   sqlFieldsQuery.setCollocated(*true*);
>   *return *cache().query(sqlFieldsQuery);
> });
>
> Is there any other way to do it?
>
>
>
> Thanks,
>
> Prasad
>
>
>

Reply via email to