Hi, In addition to answering Andrew
On Wed, Jul 13, 2016 at 3:08 PM, Andrey Gura <[email protected]> wrote: > Hi, > > It is responsibility of AffinityKeyMapper interface implementation. By > default Ignite uses GridCacheDefaultAffinityKeyMapper class for this > purposes. But you can provide own mapper implementation using > CacheConfiguration.setAffinityMapper() method. > > On Wed, Jul 13, 2016 at 11:58 AM, November <[email protected]> wrote: > >> Hi >> >> I have read http://apacheignite.gridgain.org/docs/affinity-collocation >> and >> java example. >> >> I don't know how AffinityKey map? Like following code in java example. >> How does ignite know EmployeeKey's organizationId should collocate with >> Organization's id (not other fields). I can't find anything map them in >> configuration. >> > Affinity key approach uses affinity function for collection. 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. > >> Another question: how to use AffinityKey in .Net. Will just replace >> @AffinityKeyMapped with [AffinityKeyMapped] work or there is other thing >> different? >> >> public class EmployeeKey { >> /** ID. */ >> private int id; >> >> /** Organization ID. */ >> @AffinityKeyMapped >> private int organizationId; >> } >> >> public class Organization { >> /** */ >> private static final AtomicLong ID_GEN = new AtomicLong(); >> >> /** Organization ID (indexed). */ >> @QuerySqlField(index = true) >> private Long id; >> >> /** Organization name (indexed). */ >> @QuerySqlField(index = true) >> private String name; >> >> /** Address. */ >> private Address addr; >> >> /** Type. */ >> private OrganizationType type; >> >> /** Last update time. */ >> private Timestamp lastUpdated; >> >> } >> >> >> >> -- >> View this message in context: >> http://apache-ignite-users.70518.x6.nabble.com/How-does-AffinityKey-mapped-tp6260.html >> Sent from the Apache Ignite Users mailing list archive at Nabble.com. >> > > > > -- > Andrey Gura > GridGain Systems, Inc. > www.gridgain.com > -- Vladislav Pyatkov
