Hello,

>> From the example it doesnt appear that we can put it in different caches.
Yes, from the example in Java is not clear, but see example on Scala. This
should work well (in different caches), it clear from implementation.

>> how does Ignite figure out colocation in that case?
Ignite does this with the affinity function. Annotation @AffinitiKeyMapped
means that the evaluation of the partition (for store key-value pair) will
be on a particular field and not on the whole key.

>>how do you configure partitions for a cache?
You can set the number of partitions to the constructor affinity function
for a particular cache.

<property name="affinity">
    <bean 
class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
        <constructor-arg value="true"/>
        <constructor-arg value="1024"/>
    </bean>
</property>


On Fri, May 27, 2016 at 6:33 AM, amitpa <[email protected]> wrote:

> Hey Thanks for the reply.
>
> I am copying the example here :-
>
> / Instantiate person keys with the same company ID which is used as
> affinity
> key.
> Object personKey1 = new PersonKey("myPersonId1", "myCompanyId");
> Object personKey2 = new PersonKey("myPersonId2", "myCompanyId");
>
> Person p1 = new Person(personKey1, ...);
> Person p2 = new Person(personKey2, ...);
>
> // Both, the company and the person objects will be cached on the same
> node.
> cache.put("myCompanyId", new Company(...));
> cache.put(personKey1, p1);
> cache.put(personKey2, p2);
>
> From the example it doesnt appear that we can put it in different caches.
> See both are putting to the same cache.
>
> Is there any exampel of using different caches for storing related domain
> objects, how does Ignite figure out colocation in that case? Sorry for the
> questions, but it got me confused.
>
> Also how do you configure partitions for a cache?
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/Affinity-Key-Mapping-tp5212p5265.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>

Reply via email to