You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by kotamrajuyashasvi <ko...@gmail.com> on 2017/08/01 14:55:35 UTC

c++ ignite: cache.ContainsKey(key object) method returns false even when key is present

I am running c++ ignite client, with cassandra as persistent store. The cache
has custom object as key. The key class is mapped in c++ and Java Pojo using
BinaryType object. I also implemented hashcode and equals in java pojo. When
I use cache.Get(key object) in c++ client I am able to retrieve the row .
The issue is that after I loadCache in c++ and all entries are loaded( which
I could tell from cache size and also when I query I'm able to retrieve all
rows), If I call cache.ContainsKey(key object), its returning false. But If
i call cache.Get(key object) and then call  cache.ContainsKey then its
returning true. 

Also after cache.Get(key object) in c++ client, cache size is increasing by
one even though all entries are fully loaded.But once I call cache.Get after
that how many times I call the cache.Get(key object) again and again even
with same key fields(key class variables representing the primary key) but
new key objects.. the size is remaining same its not increasing. So overall
the problem is that after loadCache in c++, even though a valid key object
is given its not able to find it in cache and loading again. But after that
it is able to identify that the key is loaded.

Also I would like to know if there is any way in c++ to obtain the key
object  using QueryFieldsCursor



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/c-ignite-cache-ContainsKey-key-object-method-returns-false-even-when-key-is-present-tp15862.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: c++ ignite: cache.ContainsKey(key object) method returns false even when key is present

Posted by kotamrajuyashasvi <ko...@gmail.com>.
Hi

Thanks for pointing it out. The sample c++ client program ran fine though.
But it might raise issues when more implementation is added. Will rectify my
code.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/c-ignite-cache-ContainsKey-key-object-method-returns-false-even-when-key-is-present-tp15862p15911.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: c++ ignite: cache.ContainsKey(key object) method returns false even when key is present

Posted by Igor Sapego <is...@apache.org>.
Hi,

Also, pay attention to your methods signature of the BinaryType
specialization. You should use 1.9 [1] version of the doc for that,
as signatures were changed after 2.0

[1] -
https://apacheignite-cpp.readme.io/v1.9/docs/cross-platform-interoperability

Best Regards,
Igor

On Wed, Aug 2, 2017 at 4:53 PM, kotamrajuyashasvi <
kotamrajuyashasvi@gmail.com> wrote:

> Hi
>
> Issue resolved. I forgot to put GetHashCode in c++ struct BinaryType of
> PersonPK. I had to implement same hashcode method used in PersonPK pojo.
>
>
>
> --
> View this message in context: http://apache-ignite-users.
> 70518.x6.nabble.com/c-ignite-cache-ContainsKey-key-object-
> method-returns-false-even-when-key-is-present-tp15862p15908.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>

Re: c++ ignite: cache.ContainsKey(key object) method returns false even when key is present

Posted by kotamrajuyashasvi <ko...@gmail.com>.
Hi

Issue resolved. I forgot to put GetHashCode in c++ struct BinaryType of
PersonPK. I had to implement same hashcode method used in PersonPK pojo.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/c-ignite-cache-ContainsKey-key-object-method-returns-false-even-when-key-is-present-tp15862p15908.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: c++ ignite: cache.ContainsKey(key object) method returns false even when key is present

Posted by kotamrajuyashasvi <ko...@gmail.com>.
Hi

I have added additional code in hashcode method of PersonPK to get trace of
when the method is being called. I have added the following piece of code in
hashcode method of PersonPK  pojo.

System.out.println("hashcode called :"+result);
System.out.println(Arrays.toString(Thread.currentThread().getStackTrace()));

The following is the result that I observed for c++ client when I ran the
above c++ client program.

-----------------------------------  stack trace when
PersonCache.LoadCache() is called in c++ ignite client ---------------------
------------------------------------ 4 entries are loaded
-----------------------------------------------------------------------
hashcode called :-1349089468
[java.lang.Thread.getStackTrace(Thread.java:1552),
com.ignitetest.PersonPK.hashCode(PersonPK.java:22),
org.apache.ignite.internal.binary.BinaryClassDescriptor.postWrite(BinaryClassDescriptor.java:894),
org.apache.ignite.internal.binary.BinaryClassDescriptor.write(BinaryClassDescriptor.java:732),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal0(BinaryWriterExImpl.java:206),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:147),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:134),
org.apache.ignite.internal.binary.GridBinaryMarshaller.marshal(GridBinaryMarshaller.java:239),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.marshalToBinary(CacheObjectBinaryProcessorImpl.java:521),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toBinary(CacheObjectBinaryProcessorImpl.java:914),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toCacheKeyObject(CacheObjectBinaryProcessorImpl.java:839),
org.apache.ignite.internal.processors.cache.GridCacheContext.toCacheKeyObject(GridCacheContext.java:1802),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter$3.apply(GridCacheStoreManagerAdapter.java:527),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker$1.process(LoadCacheCustomQueryWorker.java:99),
org.apache.ignite.cache.store.cassandra.session.CassandraSessionImpl.execute(CassandraSessionImpl.java:372),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker.call(LoadCacheCustomQueryWorker.java:65),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker.call(LoadCacheCustomQueryWorker.java:35),
java.util.concurrent.FutureTask.run(FutureTask.java:266),
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142),
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617),
java.lang.Thread.run(Thread.java:745)]


hashcode called :-1349089467
[java.lang.Thread.getStackTrace(Thread.java:1552),
com.ignitetest.PersonPK.hashCode(PersonPK.java:22),
org.apache.ignite.internal.binary.BinaryClassDescriptor.postWrite(BinaryClassDescriptor.java:894),
org.apache.ignite.internal.binary.BinaryClassDescriptor.write(BinaryClassDescriptor.java:732),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal0(BinaryWriterExImpl.java:206),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:147),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:134),
org.apache.ignite.internal.binary.GridBinaryMarshaller.marshal(GridBinaryMarshaller.java:239),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.marshalToBinary(CacheObjectBinaryProcessorImpl.java:521),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toBinary(CacheObjectBinaryProcessorImpl.java:914),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toCacheKeyObject(CacheObjectBinaryProcessorImpl.java:839),
org.apache.ignite.internal.processors.cache.GridCacheContext.toCacheKeyObject(GridCacheContext.java:1802),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter$3.apply(GridCacheStoreManagerAdapter.java:527),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker$1.process(LoadCacheCustomQueryWorker.java:99),
org.apache.ignite.cache.store.cassandra.session.CassandraSessionImpl.execute(CassandraSessionImpl.java:372),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker.call(LoadCacheCustomQueryWorker.java:65),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker.call(LoadCacheCustomQueryWorker.java:35),
java.util.concurrent.FutureTask.run(FutureTask.java:266),
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142),
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617),
java.lang.Thread.run(Thread.java:745)]


hashcode called :-1349089436
[java.lang.Thread.getStackTrace(Thread.java:1552),
com.ignitetest.PersonPK.hashCode(PersonPK.java:22),
org.apache.ignite.internal.binary.BinaryClassDescriptor.postWrite(BinaryClassDescriptor.java:894),
org.apache.ignite.internal.binary.BinaryClassDescriptor.write(BinaryClassDescriptor.java:732),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal0(BinaryWriterExImpl.java:206),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:147),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:134),
org.apache.ignite.internal.binary.GridBinaryMarshaller.marshal(GridBinaryMarshaller.java:239),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.marshalToBinary(CacheObjectBinaryProcessorImpl.java:521),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toBinary(CacheObjectBinaryProcessorImpl.java:914),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toCacheKeyObject(CacheObjectBinaryProcessorImpl.java:839),
org.apache.ignite.internal.processors.cache.GridCacheContext.toCacheKeyObject(GridCacheContext.java:1802),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter$3.apply(GridCacheStoreManagerAdapter.java:527),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker$1.process(LoadCacheCustomQueryWorker.java:99),
org.apache.ignite.cache.store.cassandra.session.CassandraSessionImpl.execute(CassandraSessionImpl.java:372),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker.call(LoadCacheCustomQueryWorker.java:65),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker.call(LoadCacheCustomQueryWorker.java:35),
java.util.concurrent.FutureTask.run(FutureTask.java:266),
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142),
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617),
java.lang.Thread.run(Thread.java:745)]


hashcode called :-1349089404
[java.lang.Thread.getStackTrace(Thread.java:1552),
com.ignitetest.PersonPK.hashCode(PersonPK.java:22),
org.apache.ignite.internal.binary.BinaryClassDescriptor.postWrite(BinaryClassDescriptor.java:894),
org.apache.ignite.internal.binary.BinaryClassDescriptor.write(BinaryClassDescriptor.java:732),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal0(BinaryWriterExImpl.java:206),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:147),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:134),
org.apache.ignite.internal.binary.GridBinaryMarshaller.marshal(GridBinaryMarshaller.java:239),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.marshalToBinary(CacheObjectBinaryProcessorImpl.java:521),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toBinary(CacheObjectBinaryProcessorImpl.java:914),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toCacheKeyObject(CacheObjectBinaryProcessorImpl.java:839),
org.apache.ignite.internal.processors.cache.GridCacheContext.toCacheKeyObject(GridCacheContext.java:1802),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter$3.apply(GridCacheStoreManagerAdapter.java:527),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker$1.process(LoadCacheCustomQueryWorker.java:99),
org.apache.ignite.cache.store.cassandra.session.CassandraSessionImpl.execute(CassandraSessionImpl.java:372),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker.call(LoadCacheCustomQueryWorker.java:65),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker.call(LoadCacheCustomQueryWorker.java:35),
java.util.concurrent.FutureTask.run(FutureTask.java:266),
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142),
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617),
java.lang.Thread.run(Thread.java:745)]


---stack trace when PersonCache.Get(PersonPK(1,"cust1")) is called for first
time in c++ ignite client after LoadCache is called ----

hashcode called :-1349089468
[java.lang.Thread.getStackTrace(Thread.java:1552),
com.ignitetest.PersonPK.hashCode(PersonPK.java:22),
org.jsr166.ConcurrentHashMap8.internalGet(ConcurrentHashMap8.java:1188),
org.jsr166.ConcurrentHashMap8.get(ConcurrentHashMap8.java:2620),
org.apache.ignite.internal.processors.cache.CacheStoreBalancingWrapper.load(CacheStoreBalancingWrapper.java:80),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadFromStore(GridCacheStoreManagerAdapter.java:327),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.load(GridCacheStoreManagerAdapter.java:293),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadAllFromStore(GridCacheStoreManagerAdapter.java:427),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadAll(GridCacheStoreManagerAdapter.java:393),
org.apache.ignite.internal.processors.cache.GridCacheAdapter$16.call(GridCacheAdapter.java:2005),
org.apache.ignite.internal.processors.cache.GridCacheAdapter$16.call(GridCacheAdapter.java:2003),
org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6618),
org.apache.ignite.internal.processors.closure.GridClosureProcessor$2.body(GridClosureProcessor.java:925),
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110),
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142),
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617),
java.lang.Thread.run(Thread.java:745)]


hashcode called :-1349089468
[java.lang.Thread.getStackTrace(Thread.java:1552),
com.ignitetest.PersonPK.hashCode(PersonPK.java:22),
org.jsr166.ConcurrentHashMap8.internalPutIfAbsent(ConcurrentHashMap8.java:1422),
org.jsr166.ConcurrentHashMap8.putIfAbsent(ConcurrentHashMap8.java:2725),
org.apache.ignite.internal.processors.cache.CacheStoreBalancingWrapper.load(CacheStoreBalancingWrapper.java:88),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadFromStore(GridCacheStoreManagerAdapter.java:327),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.load(GridCacheStoreManagerAdapter.java:293),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadAllFromStore(GridCacheStoreManagerAdapter.java:427),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadAll(GridCacheStoreManagerAdapter.java:393),
org.apache.ignite.internal.processors.cache.GridCacheAdapter$16.call(GridCacheAdapter.java:2005),
org.apache.ignite.internal.processors.cache.GridCacheAdapter$16.call(GridCacheAdapter.java:2003),
org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6618),
org.apache.ignite.internal.processors.closure.GridClosureProcessor$2.body(GridClosureProcessor.java:925),
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110),
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142),
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617),
java.lang.Thread.run(Thread.java:745)]


hashcode called :-1349089468
[java.lang.Thread.getStackTrace(Thread.java:1552),
com.ignitetest.PersonPK.hashCode(PersonPK.java:22),
org.jsr166.ConcurrentHashMap8.internalReplace(ConcurrentHashMap8.java:1215),
org.jsr166.ConcurrentHashMap8.remove(ConcurrentHashMap8.java:2930),
org.apache.ignite.internal.processors.cache.CacheStoreBalancingWrapper$LoadFuture.onDone(CacheStoreBalancingWrapper.java:259),
org.apache.ignite.internal.processors.cache.CacheStoreBalancingWrapper$LoadFuture.onDone(CacheStoreBalancingWrapper.java:239),
org.apache.ignite.internal.util.future.GridFutureAdapter.onDone(GridFutureAdapter.java:332),
org.apache.ignite.internal.processors.cache.CacheStoreBalancingWrapper$LoadFuture.onComplete(CacheStoreBalancingWrapper.java:282),
org.apache.ignite.internal.processors.cache.CacheStoreBalancingWrapper$LoadFuture.onComplete(CacheStoreBalancingWrapper.java:272),
org.apache.ignite.internal.processors.cache.CacheStoreBalancingWrapper.load(CacheStoreBalancingWrapper.java:100),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadFromStore(GridCacheStoreManagerAdapter.java:327),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.load(GridCacheStoreManagerAdapter.java:293),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadAllFromStore(GridCacheStoreManagerAdapter.java:427),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadAll(GridCacheStoreManagerAdapter.java:393),
org.apache.ignite.internal.processors.cache.GridCacheAdapter$16.call(GridCacheAdapter.java:2005),
org.apache.ignite.internal.processors.cache.GridCacheAdapter$16.call(GridCacheAdapter.java:2003),
org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6618),
org.apache.ignite.internal.processors.closure.GridClosureProcessor$2.body(GridClosureProcessor.java:925),
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110),
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142),
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617),
java.lang.Thread.run(Thread.java:745)]

---stack trace when PersonCache.Get(PersonPK(1,"cust1")) is called for
second time in c++ ignite client after LoadCache is called ----

no stack trace observed. i.e no call to hashcode. 



I also ran similar java client and following is what I observed.

-----------------------------------  stack trace when
PersonCache.LoadCache() is called in java ignite client
---------------------
------------------------------------ 4 entries are loaded
-----------------------------------------------------------------------

hashcode called :-1349089468
[java.lang.Thread.getStackTrace(Thread.java:1552),
com.ignitetest.PersonPK.hashCode(PersonPK.java:22),
org.apache.ignite.internal.binary.BinaryClassDescriptor.postWrite(BinaryClassDescriptor.java:894),
org.apache.ignite.internal.binary.BinaryClassDescriptor.write(BinaryClassDescriptor.java:732),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal0(BinaryWriterExImpl.java:206),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:147),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:134),
org.apache.ignite.internal.binary.GridBinaryMarshaller.marshal(GridBinaryMarshaller.java:239),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.marshalToBinary(CacheObjectBinaryProcessorImpl.java:521),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toBinary(CacheObjectBinaryProcessorImpl.java:914),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toCacheKeyObject(CacheObjectBinaryProcessorImpl.java:839),
org.apache.ignite.internal.processors.cache.GridCacheContext.toCacheKeyObject(GridCacheContext.java:1802),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter$3.apply(GridCacheStoreManagerAdapter.java:527),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker$1.process(LoadCacheCustomQueryWorker.java:99),
org.apache.ignite.cache.store.cassandra.session.CassandraSessionImpl.execute(CassandraSessionImpl.java:372),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker.call(LoadCacheCustomQueryWorker.java:65),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker.call(LoadCacheCustomQueryWorker.java:35),
java.util.concurrent.FutureTask.run(FutureTask.java:266),
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142),
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617),
java.lang.Thread.run(Thread.java:745)]


hashcode called :-1349089467
[java.lang.Thread.getStackTrace(Thread.java:1552),
com.ignitetest.PersonPK.hashCode(PersonPK.java:22),
org.apache.ignite.internal.binary.BinaryClassDescriptor.postWrite(BinaryClassDescriptor.java:894),
org.apache.ignite.internal.binary.BinaryClassDescriptor.write(BinaryClassDescriptor.java:732),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal0(BinaryWriterExImpl.java:206),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:147),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:134),
org.apache.ignite.internal.binary.GridBinaryMarshaller.marshal(GridBinaryMarshaller.java:239),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.marshalToBinary(CacheObjectBinaryProcessorImpl.java:521),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toBinary(CacheObjectBinaryProcessorImpl.java:914),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toCacheKeyObject(CacheObjectBinaryProcessorImpl.java:839),
org.apache.ignite.internal.processors.cache.GridCacheContext.toCacheKeyObject(GridCacheContext.java:1802),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter$3.apply(GridCacheStoreManagerAdapter.java:527),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker$1.process(LoadCacheCustomQueryWorker.java:99),
org.apache.ignite.cache.store.cassandra.session.CassandraSessionImpl.execute(CassandraSessionImpl.java:372),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker.call(LoadCacheCustomQueryWorker.java:65),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker.call(LoadCacheCustomQueryWorker.java:35),
java.util.concurrent.FutureTask.run(FutureTask.java:266),
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142),
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617),
java.lang.Thread.run(Thread.java:745)]


hashcode called :-1349089436
[java.lang.Thread.getStackTrace(Thread.java:1552),
com.ignitetest.PersonPK.hashCode(PersonPK.java:22),
org.apache.ignite.internal.binary.BinaryClassDescriptor.postWrite(BinaryClassDescriptor.java:894),
org.apache.ignite.internal.binary.BinaryClassDescriptor.write(BinaryClassDescriptor.java:732),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal0(BinaryWriterExImpl.java:206),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:147),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:134),
org.apache.ignite.internal.binary.GridBinaryMarshaller.marshal(GridBinaryMarshaller.java:239),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.marshalToBinary(CacheObjectBinaryProcessorImpl.java:521),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toBinary(CacheObjectBinaryProcessorImpl.java:914),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toCacheKeyObject(CacheObjectBinaryProcessorImpl.java:839),
org.apache.ignite.internal.processors.cache.GridCacheContext.toCacheKeyObject(GridCacheContext.java:1802),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter$3.apply(GridCacheStoreManagerAdapter.java:527),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker$1.process(LoadCacheCustomQueryWorker.java:99),
org.apache.ignite.cache.store.cassandra.session.CassandraSessionImpl.execute(CassandraSessionImpl.java:372),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker.call(LoadCacheCustomQueryWorker.java:65),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker.call(LoadCacheCustomQueryWorker.java:35),
java.util.concurrent.FutureTask.run(FutureTask.java:266),
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142),
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617),
java.lang.Thread.run(Thread.java:745)]


hashcode called :-1349089404
[java.lang.Thread.getStackTrace(Thread.java:1552),
com.ignitetest.PersonPK.hashCode(PersonPK.java:22),
org.apache.ignite.internal.binary.BinaryClassDescriptor.postWrite(BinaryClassDescriptor.java:894),
org.apache.ignite.internal.binary.BinaryClassDescriptor.write(BinaryClassDescriptor.java:732),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal0(BinaryWriterExImpl.java:206),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:147),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:134),
org.apache.ignite.internal.binary.GridBinaryMarshaller.marshal(GridBinaryMarshaller.java:239),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.marshalToBinary(CacheObjectBinaryProcessorImpl.java:521),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toBinary(CacheObjectBinaryProcessorImpl.java:914),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toCacheKeyObject(CacheObjectBinaryProcessorImpl.java:839),
org.apache.ignite.internal.processors.cache.GridCacheContext.toCacheKeyObject(GridCacheContext.java:1802),
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter$3.apply(GridCacheStoreManagerAdapter.java:527),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker$1.process(LoadCacheCustomQueryWorker.java:99),
org.apache.ignite.cache.store.cassandra.session.CassandraSessionImpl.execute(CassandraSessionImpl.java:372),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker.call(LoadCacheCustomQueryWorker.java:65),
org.apache.ignite.cache.store.cassandra.session.LoadCacheCustomQueryWorker.call(LoadCacheCustomQueryWorker.java:35),
java.util.concurrent.FutureTask.run(FutureTask.java:266),
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142),
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617),
java.lang.Thread.run(Thread.java:745)]

---stack trace when PersonCache.Get(PersonPK(1,"cust1")) is called for first
time in java ignite client after LoadCache is called ----

hashcode called :-1349089468
[java.lang.Thread.getStackTrace(Thread.java:1552),
com.ignitetest.PersonPK.hashCode(PersonPK.java:22),
org.apache.ignite.internal.binary.BinaryClassDescriptor.postWrite(BinaryClassDescriptor.java:894),
org.apache.ignite.internal.binary.BinaryClassDescriptor.write(BinaryClassDescriptor.java:732),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal0(BinaryWriterExImpl.java:206),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:147),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:134),
org.apache.ignite.internal.binary.GridBinaryMarshaller.marshal(GridBinaryMarshaller.java:239),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.marshalToBinary(CacheObjectBinaryProcessorImpl.java:521),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toBinary(CacheObjectBinaryProcessorImpl.java:914),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toCacheKeyObject(CacheObjectBinaryProcessorImpl.java:839),
org.apache.ignite.internal.processors.cache.GridCacheContext.toCacheKeyObject(GridCacheContext.java:1802),
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.get0(GridDhtAtomicCache.java:488),
org.apache.ignite.internal.processors.cache.GridCacheAdapter.get(GridCacheAdapter.java:4663),
org.apache.ignite.internal.processors.cache.GridCacheAdapter.get(GridCacheAdapter.java:1388),
org.apache.ignite.internal.processors.cache.IgniteCacheProxy.get(IgniteCacheProxy.java:1117),
HelloIgniteJava.main(HelloIgniteJava.java:58)]

---stack trace when PersonCache.Get(PersonPK(1,"cust1")) is called for
second time in java ignite client after LoadCache is called ----

hashcode called :-1349089468
[java.lang.Thread.getStackTrace(Thread.java:1552),
com.ignitetest.PersonPK.hashCode(PersonPK.java:22),
org.apache.ignite.internal.binary.BinaryClassDescriptor.postWrite(BinaryClassDescriptor.java:894),
org.apache.ignite.internal.binary.BinaryClassDescriptor.write(BinaryClassDescriptor.java:732),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal0(BinaryWriterExImpl.java:206),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:147),
org.apache.ignite.internal.binary.BinaryWriterExImpl.marshal(BinaryWriterExImpl.java:134),
org.apache.ignite.internal.binary.GridBinaryMarshaller.marshal(GridBinaryMarshaller.java:239),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.marshalToBinary(CacheObjectBinaryProcessorImpl.java:521),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toBinary(CacheObjectBinaryProcessorImpl.java:914),
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.toCacheKeyObject(CacheObjectBinaryProcessorImpl.java:839),
org.apache.ignite.internal.processors.cache.GridCacheContext.toCacheKeyObject(GridCacheContext.java:1802),
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.get0(GridDhtAtomicCache.java:488),
org.apache.ignite.internal.processors.cache.GridCacheAdapter.get(GridCacheAdapter.java:4663),
org.apache.ignite.internal.processors.cache.GridCacheAdapter.get(GridCacheAdapter.java:1388),
org.apache.ignite.internal.processors.cache.IgniteCacheProxy.get(IgniteCacheProxy.java:1117),
HelloIgniteJava.main(HelloIgniteJava.java:62)]




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/c-ignite-cache-ContainsKey-key-object-method-returns-false-even-when-key-is-present-tp15862p15900.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: c++ ignite: cache.ContainsKey(key object) method returns false even when key is present

Posted by kotamrajuyashasvi <ko...@gmail.com>.
Hi. Thanks for the response..

->The ignite version used is 1.9.0.
->With Java Client its working fine.

--------------------------------- ignite config xml 
---------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd">


	<import resource="file:connection-settings.xml" />
	
    <bean id="persistence_settings"
class="org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings">
		<constructor-arg type="org.springframework.core.io.Resource"
value="file:persistence-settings-1.xml" />
	</bean>

    <bean id="ignite.cfg"
class="org.apache.ignite.configuration.IgniteConfiguration">
       
         <property name="clientMode" value="true"/> 
 
		 <property name="binaryConfiguration">
            <bean
class="org.apache.ignite.configuration.BinaryConfiguration">
                <property name="compactFooter" value="false"/>

                <property name="idMapper">
                    <bean
class="org.apache.ignite.binary.BinaryBasicIdMapper">
                        <property name="lowerCase" value="true"/>
                    </bean>
                </property>

                <property name="nameMapper">
                    <bean
class="org.apache.ignite.binary.BinaryBasicNameMapper">
                        <property name="simpleName" value="true"/>
                    </bean>
                </property>

                <property name="classNames">
                    <list>
                        <value>com.ignitetest.PersonPK</value>
                    </list>
                </property>
            </bean>
        </property>


		<property name="cacheConfiguration">
            <list>                
                <bean
class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="indexedTypes">
                        <list>
                            <value>com.ignitetest.PersonPK</value>
                            <value>com.ignitetest.Person</value>
                        </list>
                    </property>
                    <property name="name" value="cache1"/>
                    <property name="readThrough" value="true"/>
                    <property name="writeThrough" value="true"/>
                    <property name="cacheStoreFactory">
                        <bean
class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
                            <property name="dataSourceBean"
value="cassandraAdminDataSource"/>
                            <property name="persistenceSettingsBean"
value="persistence_settings"/>
                        </bean>
                    </property>
                </bean>
           </list>
        </property>
  <property name="peerClassLoadingEnabled" value="true"></property>
        <property name="discoverySpi">
            <bean
class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <property name="ipFinder">                   
                    <bean
class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
                        <property name="addresses">
                            <list>
                                <value>127.0.0.1</value>
                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>
    </bean>
</beans>

---------------------------------persistence settings 
---------------------------------------------------------
<persistence keyspace="testkeyspace" table="person">
	<keyPersistence class="com.ignitetest.PersonPK" strategy="POJO" />
    <valuePersistence class="com.ignitetest.Person" strategy="POJO" />
</persistence>

---------------------------------Person Pojo 
---------------------------------------------------------
package com.ignitetest;

public class Person {
	int col1;
	int col2;
	int col3;
	String col4;
	String col5;
	public int getCol1() {
		return col1;
	}
	public void setCol1(int col1) {
		this.col1 = col1;
	}
	public int getCol2() {
		return col2;
	}
	public void setCol2(int col2) {
		this.col2 = col2;
	}
	public int getCol3() {
		return col3;
	}
	public void setCol3(int col3) {
		this.col3 = col3;
	}
	public String getCol4() {
		return col4;
	}
	public void setCol4(String col4) {
		this.col4 = col4;
	}
	public String getCol5() {
		return col5;
	}
	public void setCol5(String col5) {
		this.col5 = col5;
	}
}
    
---------------------------------PersonPK Pojo 
---------------------------------------------------------
package com.ignitetest;

import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryReader;
import org.apache.ignite.binary.BinaryWriter;
import org.apache.ignite.binary.Binarylizable;

public class PersonPK implements Binarylizable{
	int col1;
	String col5;
	public int getCol1() {
		return col1;
	}
	public void setCol1(int col1) {
		this.col1 = col1;
	}
	public String getCol5() {
		return col5;
	}
	public void setCol5(String col5) {
		this.col5 = col5;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + col1;
		result = prime * result + ((col5 == null) ? 0 : col5.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		PersonPK other = (PersonPK) obj;
		if (col1 != other.col1)
			return false;
		if (col5 == null) {
			if (other.col5 != null)
				return false;
		} else if (!col5.equals(other.col5))
			return false;
		return true;
	}
	@Override
	public void readBinary(BinaryReader reader) throws BinaryObjectException {
		this.col1  = reader.readInt("col1");
		this.col5 = reader.readString("col5");
		
	}
	@Override
	public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
		writer.writeInt("col1", col1);
		writer.writeString("col5", col5);	
	}
	
	
}

-----------------------------------------C++ pojo map header
---------------------------------------------

#ifndef _IGNITE_EXAMPLES_CPDU
#define _IGNITE_EXAMPLES_CPDU

#include <string>
#include <sstream>

#include "ignite/ignite.h"
#include "ignite/ignition.h"

namespace ignite
{
        struct Person
        {
           
            Person(int32_t _col1,int64_t _col2,int64_t _col3, const
std::string& _col4, const std::string& _col5):
                  col1(_col1),
                  col2(_col2),
                  col3(_col3),
                  col4(_col4),
                  col5(_col5)
            {
                // No-op.
            }
			
            int32_t col1;
            int32_t col2;
            int32_t col3;
            std::string col4;
            std::string col5;
        };

		 struct PersonPK
          {
			  PersonPK(){

			  }	
 
              PersonPK(const ignite::PersonPK& copyfromPersonPK)
              {
                  col1         = copyfromPersonPK.col1;
                  col5         = copyfromPersonPK.col5;
              }
 
              PersonPK(int32_t _col1, const std::string& _col5):
                    col1(_col1),
                    col5(_col5)
              {
 
              }
 
              int32_t col1;
              std::string col5;
          };

}

namespace ignite
{
    namespace binary
    {
        IGNITE_BINARY_TYPE_START(ignite::Person)

            typedef ignite::Person Person;

            IGNITE_BINARY_GET_TYPE_ID_AS_HASH(Person)
            IGNITE_BINARY_GET_TYPE_NAME_AS_IS(Person)
            IGNITE_BINARY_GET_FIELD_ID_AS_HASH
            IGNITE_BINARY_GET_HASH_CODE_ZERO(Person)
            IGNITE_BINARY_IS_NULL_FALSE(Person)
            IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(Person)

            void Write(BinaryWriter& writer, ignite::Person obj)
            {
                writer.WriteInt32("col1", obj.col1);
                writer.WriteInt32("col2", obj.col2);
                writer.WriteInt32("col3", obj.col3);
                writer.WriteString("col4", obj.col4);
                writer.WriteString("col5", obj.col5);
            }

            ignite::Person Read(BinaryReader& reader)
            {
                int32_t _col1 = reader.ReadInt32("col1");
                int32_t _col2 = reader.ReadInt32("col2");
                int32_t _col3 = reader.ReadInt32("col3");
                std::string _col4 = reader.ReadString("col4");
                std::string _col5 = reader.ReadString("col5");

                return ignite::Person(_col1, _col2, _col3, _col4, _col5);
            }

        IGNITE_BINARY_TYPE_END


	  template<>
      struct BinaryType<PersonPK>
      {
        static int32_t GetTypeId()
        {
          return GetBinaryStringHashCode("PersonPK");
        }
 
        std::string GetTypeName()
        {
          return "PersonPK";
        }
 
        static int32_t GetFieldId(const char* name)
        {
          return GetBinaryStringHashCode(name);
        }
 
        static bool IsNull(const PersonPK& obj)
        {
          return false;
        }
 
        static void GetNull(PersonPK& dst)
        {
          dst = PersonPK();
        }
 
        static void Read(BinaryReader& reader, PersonPK& dst)
        {
          dst.col1 = reader.ReadInt32("col1");
          dst.col5 = reader.ReadString("col5");
        }
 
        static void Write(BinaryWriter& writer, const PersonPK& obj)
        {
          writer.WriteInt32("col1", obj.col1);
          writer.WriteString("col5", obj.col5);
       }
     };

    }
};


#endif // _IGNITE_EXAMPLES_CPDU

------------------------------------------------- ignite c++ client
---------------------------------------
#include <stdint.h>
#include <iostream>
#include "ignite/ignite.h"
#include "ignite/ignition.h"
#include "pojomap.h"

using namespace std;
using namespace ignite;
using namespace cache;
using namespace query;

void callIgnite();

int main()
{
	callIgnite();
	return 0;
}

void callIgnite()
{
	IgniteConfiguration cfg;
	cfg.springCfgPath = "default-config.xml";

	try
	{
		Ignite ignite = Ignition::Start(cfg);

		Person myPerson;
		PersonPK pk ;

		ResVector result;

		std::cout << std::endl;
		std::cout << ">>> Cassandra Cache query example started." << std::endl;
		std::cout << std::endl;

		Cache<PersonPK, Person> PersonCache = ignite.GetOrCreateCache<PersonPK,
Person>("cache1");

		std::cout << "CACHE SIZE before loadCache(): " <<
PersonCache.Size()<<std::endl; //initial 0
		PersonCache.LoadCache();
		std::cout << "CACHE SIZE after loadCache
:"<<PersonCache.Size()<<std::endl; // size after loading all = 4

		pk = PersonPK(1,"cust1");
		myPerson = PersonCache.Get(pk);
		std::cout<<myPerson.account_num<<endl;
		std::cout << "CACHE SIZE after Get 1:"<<PersonCache.Size()<<std::endl; //
size 5
		
		PersonCache.Get(PersonPK(1,"cust1"));
		std::cout<<myPerson.account_num<<endl;
		std::cout << "CACHE SIZE after Get 2:"<<PersonCache.Size()<<std::endl;  //
size 5
		
		Ignition::StopAll(false);
	}
	catch (IgniteError& err)
	{
		std::cout << "An error occurred: " << err.GetText() << std::endl;
	}
}







--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/c-ignite-cache-ContainsKey-key-object-method-returns-false-even-when-key-is-present-tp15862p15879.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: c++ ignite: cache.ContainsKey(key object) method returns false even when key is present

Posted by Igor Sapego <is...@apache.org>.
Hello,

Which version are you on?
Also, please share your configuration. Does the same
behaviour persists if you do it using Java API?

> Also I would like to know if there is any way in c++ to obtain the key
> object  using QueryFieldsCursor

You should use SQL query like "select _key, ... from YourType" and then
just retrieve key as any other column.

Best Regards,
Igor

On Tue, Aug 1, 2017 at 5:55 PM, kotamrajuyashasvi <
kotamrajuyashasvi@gmail.com> wrote:

> I am running c++ ignite client, with cassandra as persistent store. The
> cache
> has custom object as key. The key class is mapped in c++ and Java Pojo
> using
> BinaryType object. I also implemented hashcode and equals in java pojo.
> When
> I use cache.Get(key object) in c++ client I am able to retrieve the row .
> The issue is that after I loadCache in c++ and all entries are loaded(
> which
> I could tell from cache size and also when I query I'm able to retrieve all
> rows), If I call cache.ContainsKey(key object), its returning false. But If
> i call cache.Get(key object) and then call  cache.ContainsKey then its
> returning true.
>
> Also after cache.Get(key object) in c++ client, cache size is increasing by
> one even though all entries are fully loaded.But once I call cache.Get
> after
> that how many times I call the cache.Get(key object) again and again even
> with same key fields(key class variables representing the primary key) but
> new key objects.. the size is remaining same its not increasing. So overall
> the problem is that after loadCache in c++, even though a valid key object
> is given its not able to find it in cache and loading again. But after that
> it is able to identify that the key is loaded.
>
> Also I would like to know if there is any way in c++ to obtain the key
> object  using QueryFieldsCursor
>
>
>
> --
> View this message in context: http://apache-ignite-users.
> 70518.x6.nabble.com/c-ignite-cache-ContainsKey-key-object-
> method-returns-false-even-when-key-is-present-tp15862.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>