Hello Jamal, I think so, It not possible, because data store in particular partition, which determine only by affinityKey.
More useful case, when you are not know fullKey, use ScanQuery(1) or use cache iterator. (1): https://apacheignite.readme.io/docs/cache-queries On Jun 6, 2016 3:34 PM, "Kamal" <[email protected]> wrote: > Hi, > > I've gone through the affinity collocation[1] example to understand how > data gets collocated across caches. In my example, I found that I'm not > able > to retrieve data from collocated cache with simple key. > > I mean. > > Cache<AffinityKey<String>, Person> personCache = ..; > personCache.get(new AffinityKey<>(key, affKey)); // returns value > personCache.get(new AffinityKey<>(key)); // throws NPE > > Exception in thread "main" java.lang.NullPointerException > at > > org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction.partition(RendezvousAffinityFunction.java:428) > at > > org.apache.ignite.internal.processors.cache.GridCacheAffinityManager.partition(GridCacheAffinityManager.java:206) > at > > org.apache.ignite.internal.processors.cache.GridCacheContext.toCacheKeyObject(GridCacheContext.java:1801) > at > > org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.get(GridDhtAtomicCache.java:339) > at > > org.apache.ignite.internal.processors.cache.GridCacheAdapter.get(GridCacheAdapter.java:4650) > at > > org.apache.ignite.internal.processors.cache.GridCacheAdapter.get(GridCacheAdapter.java:1391) > at > > org.apache.ignite.internal.processors.cache.IgniteCacheProxy.get(IgniteCacheProxy.java:907) > at > > my.apache.ignite.examples.collocation.CacheCollocationExample.main(CacheCollocationExample.java:69) > > In some scenarios, I have to fetch data from cache by simple key. > > [1]: https://apacheignite.readme.io/docs/affinity-collocation > CacheCollocationExample.java > < > http://apache-ignite-users.70518.x6.nabble.com/file/n5452/CacheCollocationExample.java > > > Company.java > <http://apache-ignite-users.70518.x6.nabble.com/file/n5452/Company.java> > Person.java > <http://apache-ignite-users.70518.x6.nabble.com/file/n5452/Person.java> > > > > > -- > View this message in context: > http://apache-ignite-users.70518.x6.nabble.com/How-to-retrieve-data-from-Collocated-Cache-with-Simple-Key-tp5452.html > Sent from the Apache Ignite Users mailing list archive at Nabble.com. >
