You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by tomk <rr...@gmail.com> on 2016/05/11 16:55:34 UTC

Affinity Collocation - more details

Hello,  
I am caching underlying database.   These data contains: CountryID, TID.
Is it possible to use affinity collocation in following way:   
1. Rows with the same CountryID are on the same cache node.
2. Rows with the same CounryID and TID (as second priority) are loaded on
the same cache node.
3. What about keyCache ? What is relation between affinity collocation and
key cache ?1



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Affinity-Collocation-more-details-tp4876.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Affinity Collocation - more details

Posted by vdpyatkov <vl...@gmail.com>.
Hello,

Affinity collocation what you need exactly.

Affinity function this is a mapping keys to partitions. 
In other word when you are explicitly calling put(key, value), you are
implicitly assigning partition and node, where data will store.
But in many cases you want to store some data entries on same node. In this
case you can to use key with annotation @AffinityKeyMapped (or special class
AffinityKey), it means, what affinity-function took annotated property for
mapping key to partition.  

For example:

Country
TID is pk

Department
CountryID is fk to Country
DID is pk

You can use new AffinityKey("entryID", "TID"); and put entries as this:
Country c1 = new Country (1);
Department d1 = new Department(1,1);
Department d2 = new Department(1,2);

Object ak1 = new AffinityKey(1, 1);
Object ak2 = new AffinityKey(2, 1);

countryCache.put(1, c1);

departmentCache.put(ak1, d1);
departmentCache.put(ak2, d2);

Also you can read this article:
https://apacheignite.readme.io/docs/affinity-collocation



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Affinity-Collocation-more-details-tp4876p4894.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.