Hello!

Even if you had two affinity keys, you would not be able to do collocated
joins with tables employing different affinity keys.

I.e., if you had a table with affinity key (city_id, country_id) you will
only be able to collocate it with another table of affinity key (city_id,
country_id), but NOT with tables using affinity keys (city_id),
(country_id) or (country_id, city_id).

You will have to think around this limitation by choosing the most
important criteria to collocate data on, and doing the rest via lookup
tables or distributed joins.

Regards,
-- 
Ilya Kasnacheev


пн, 20 янв. 2020 г. в 21:48, narges saleh <[email protected]>:

> Thanks Stephan,
>
> I don't want to use POJO classes if I can help it.
> I want to mimic the following in my configuration file:
>
> CREATE TABLE IF NOT EXISTS Person (
>   id int,
>   city_id int,
>   name varchar,
>   age int,
>   company varchar,
>   PRIMARY KEY (id, city_id)) WITH "template=partitioned,affinity_key=city_id";
>
> Furthermore, I want to see if it is possible to define affinity over multiple 
> keys, for example, have the above as
>
> CREATE TABLE IF NOT EXISTS Person (
>   id int,
>   city_id int,
>   name varchar,
>   age int,
>   company varchar,
>   PRIMARY KEY (id, city_id)) WITH 
> "template=partitioned,*affinity_key=city_id, country_id"*
>
> *;*
>
> I have many caches and the relationship between them imply different set of 
> affinity keys. All are defined within the same configuration file.
>
>
> On Mon, Jan 20, 2020 at 12:40 PM narges saleh <[email protected]>
> wrote:
>
>> Thanks Stephan,
>>
>> I don't want to use POJO classes if I can help it.
>> I want to mimic the following in my configuration file:
>>
>>
>> On Mon, Jan 20, 2020 at 10:30 AM Stephen Darlington <
>> [email protected]> wrote:
>>
>>> Details on how to configure affinity colocation can be found in the
>>> documentation:
>>> https://www.gridgain.com/docs/latest/developers-guide/data-modeling/affinity-collocation
>>>
>>>
>>> In short, use the “indexedTypes” property in the XML file and the
>>> @AffinityKeyMapped annotation in your POJO key,
>>>
>>> Regards,
>>> Stephen
>>>
>>> On 18 Jan 2020, at 12:28, narges saleh <[email protected]> wrote:
>>>
>>> Hi All,
>>>
>>> I understand that CacheKeyConfiguration is defined at ignite
>>> configuration level. That being the case, how do you tie the affinity key
>>> to a particular cache, within the XML config file?
>>> The following code snippet shows how to do in java code.
>>>
>>>   CacheConfiguration<PersonKey, Person> personCfg = new 
>>> CacheConfiguration<PersonKey, Person>("persons");
>>>
>>>     //configure the affinity key
>>>     personCfg.setKeyConfiguration(new CacheKeyConfiguration("Person", 
>>> "companyId"));
>>>
>>> Also, how do you define an affinity key with multiple fields, using 
>>> CacheKeyConfiguration, say SSN and company id are both part of the affinity 
>>> key.
>>>
>>> thanks.
>>>
>>>
>>>
>>>

Reply via email to