Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 01EB9200B17 for ; Tue, 7 Jun 2016 06:40:52 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 006B9160A55; Tue, 7 Jun 2016 04:40:52 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1DBF5160A24 for ; Tue, 7 Jun 2016 06:40:50 +0200 (CEST) Received: (qmail 23773 invoked by uid 500); 7 Jun 2016 04:40:50 -0000 Mailing-List: contact user-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@ignite.apache.org Delivered-To: mailing list user@ignite.apache.org Received: (qmail 23763 invoked by uid 99); 7 Jun 2016 04:40:50 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Jun 2016 04:40:50 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id C18771A0574 for ; Tue, 7 Jun 2016 04:40:49 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.198 X-Spam-Level: * X-Spam-Status: No, score=1.198 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id d4oL8395Ps-L for ; Tue, 7 Jun 2016 04:40:47 +0000 (UTC) Received: from mail-oi0-f43.google.com (mail-oi0-f43.google.com [209.85.218.43]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 16FE15FACD for ; Tue, 7 Jun 2016 04:40:47 +0000 (UTC) Received: by mail-oi0-f43.google.com with SMTP id k23so259050140oih.0 for ; Mon, 06 Jun 2016 21:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=9hiOWRCH52r11a2qiEmqWjXVjw3MP/B5BhAqwl8HjU0=; b=T0ycEjN4NvJYl18pMmn5I8uTwU1GM2t+9AtS0UFkYgKEfAYE1yBXnjeuWULTFNCLmk miikzXqDlF4Lo7I8034SFvXzb2OplEj06dtX6Zb+96ajCf2FDT+kBl/89CqdXHlKdMyC +oKl1OR8nlqdmW/XBhGpm8hNY19cRYD9yTu7wSrGHxetw9kODOvqBRPUszA+KiHXrXZx jY9P/NjPzuy0QCngMOSmnPkayT9NzFvVnfiWX973mGg8smdhE07K3pIfFVoLXT8XKFeG p9givTavJmwX22IIF++xa6cTQiaAWuLSW1dDeRZdfqy0T8Pr3pI1cbBPfAnZ2/ZVdJjx a+OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=9hiOWRCH52r11a2qiEmqWjXVjw3MP/B5BhAqwl8HjU0=; b=FnAqc53wGIdMVEjSwgCJhaYLwuW8Gz3EPwOy6d8k1bwrHnQE6aJFkw3rWz6uVt7nK4 9bLlgf1p0LHcnAN+DX+u9viqD57WNnoPQCUF74exfU+XBUzrVhxHe7G74CYowoR857T6 zmoNoh8yZpGx9B4KEVPNb4uV0xvUfX7b4edOWQ5cXrwEPdOz7s5PRhlEFqkckUW96Alu 0OJBS3Qexf5T/k+3AdQmc93kWv1893Br0dLRN/gL8cTS2+aAZ9FlxWbtd7RLt/v4uy44 yKBOLQM30LkDaVU5mMQ4XaI9oDCBP0H6Ehkdnaw/OmqOWO5DUU/U/nL/+nBCbP3HXBio feWQ== X-Gm-Message-State: ALyK8tKOL8lVxFTiCJC+ed7qgl+6DvqP1PNastok1Q+aJl0pdcOmAipwF1A/0sc4xBy+my9i3yO5/1An0hJw3g== X-Received: by 10.202.252.137 with SMTP id a131mr7017092oii.58.1465274445941; Mon, 06 Jun 2016 21:40:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.186.85 with HTTP; Mon, 6 Jun 2016 21:40:45 -0700 (PDT) In-Reply-To: References: <1465215545429-5452.post@n6.nabble.com> From: Kamal C Date: Tue, 7 Jun 2016 10:10:45 +0530 Message-ID: Subject: Re: How to retrieve data from Collocated Cache with Simple Key To: user@ignite.apache.org Content-Type: multipart/alternative; boundary=001a113cd768d951780534a8ca68 archived-at: Tue, 07 Jun 2016 04:40:52 -0000 --001a113cd768d951780534a8ca68 Content-Type: text/plain; charset=UTF-8 Thanks for your response Vladislav. Both ScanQuery and Iterator traverses the whole cache to find the value. It may not be suitable in my environment as there can be huge number of hits. I understand that for fast retrieval `key-to-partition` mapping is done. But, In AffinityKey documentation, it's specified that hashcode and equals methods are implemented based on simple key. *

> * Note that the {@link #equals(Object)} and {@link #hashCode()} methods > * delegate directly to the wrapped cache key provided by {@link #key()} > * method. > *

> On Mon, Jun 6, 2016 at 10:44 PM, Vladislav Pyatkov wrote: > I am sorry for mistake Kamal... > On Jun 6, 2016 3:34 PM, "Kamal" 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, 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 >> >> 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. >> > --001a113cd768d951780534a8ca68 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Thanks for your response Vladisla= v.

Both ScanQuery and Iterator traverses the whole cache to f= ind the value.
It may not be suitable in my environment as there = can be huge number of
hits.

I understand that fo= r fast retrieval `key-to-partition` mapping is done.
But, In AffinityKe= y documentation, it's specified that hashcode and equals
metho= ds are implemented based on simple key.

* <p>
=C2=A0* Note that the= {@link #equals(Object)} and {@link #hashCode()} methods
=C2=A0* delegat= e directly to the wrapped cache key provided by {@link #key()}
=C2=A0* m= ethod.
=C2=A0* <p>

On Mon, Jun 6, 2016 at 10:44 P= M, Vladislav Pyatkov <vpyatkov@gridgain.com> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex">

I am sorry for mistake Kamal..= .

On Jun 6, 2016 3:34 PM, "K= amal" <k= amaltarget@gmail.com> wrote:
Hi,

=C2=A0 =C2=A0 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&lt;String>, Person> personCache =3D ..;
personCache.get(new AffinityKey<>(key, affKey)); // returns value
personCache.get(new AffinityKey<>(key)); // throws NPE

Exception in thread "main" java.lang.NullPointerException
=C2=A0 =C2=A0 =C2=A0 =C2=A0 at
org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction.part= ition(RendezvousAffinityFunction.java:428)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 at
org.apache.ignite.internal.processors.cache.GridCacheAffinityManager.partit= ion(GridCacheAffinityManager.java:206)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 at
org.apache.ignite.internal.processors.cache.GridCacheContext.toCacheKeyObje= ct(GridCacheContext.java:1801)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 at
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtA= tomicCache.get(GridDhtAtomicCache.java:339)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 at
org.apache.ignite.internal.processors.cache.GridCacheAdapter.get(GridCacheA= dapter.java:4650)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 at
org.apache.ignite.internal.processors.cache.GridCacheAdapter.get(GridCacheA= dapter.java:1391)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 at
org.apache.ignite.internal.processors.cache.IgniteCacheProxy.get(IgniteCach= eProxy.java:907)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 at
my.apache.ignite.examples.collocation.CacheCollocationExample.main(CacheCol= locationExample.java:69)

In some scenarios, I have to fetch data from cache by simple key.

[1]: https://apacheignite.readme.io/docs/aff= inity-collocation
CacheCollocationExample.java
<http://apa= che-ignite-users.70518.x6.nabble.com/file/n5452/CacheCollocationExample.jav= a>
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.7= 0518.x6.nabble.com/How-to-retrieve-data-from-Collocated-Cache-with-Simple-K= ey-tp5452.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

--001a113cd768d951780534a8ca68--