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 254F2200CE6 for ; Wed, 2 Aug 2017 08:19:07 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 23C51168C3F; Wed, 2 Aug 2017 06:19:07 +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 1C740168C3D for ; Wed, 2 Aug 2017 08:19:05 +0200 (CEST) Received: (qmail 77739 invoked by uid 500); 2 Aug 2017 06:19:00 -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 77729 invoked by uid 99); 2 Aug 2017 06:18:59 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Aug 2017 06:18:59 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 878BD180642 for ; Wed, 2 Aug 2017 06:18:59 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.973 X-Spam-Level: ** X-Spam-Status: No, score=2.973 tagged_above=-999 required=6.31 tests=[DKIM_ADSP_CUSTOM_MED=0.001, KAM_ASCII_DIVIDERS=0.8, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_NONE=-0.0001, SPF_SOFTFAIL=0.972] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 7HOxm-EBLiLa for ; Wed, 2 Aug 2017 06:18:58 +0000 (UTC) Received: from mwork.nabble.com (mwork.nabble.com [162.253.133.43]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id A1CC75F29A for ; Wed, 2 Aug 2017 06:18:57 +0000 (UTC) Received: from static.162.255.23.37.macminivault.com (unknown [162.255.23.37]) by mwork.nabble.com (Postfix) with ESMTP id 5BCD9585455FF for ; Tue, 1 Aug 2017 23:18:57 -0700 (MST) Date: Tue, 1 Aug 2017 23:18:56 -0700 (MST) From: kotamrajuyashasvi To: user@ignite.apache.org Message-ID: <1501654736852-15879.post@n6.nabble.com> In-Reply-To: References: <1501599335969-15862.post@n6.nabble.com> Subject: Re: c++ ignite: cache.ContainsKey(key object) method returns false even when key is present MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit archived-at: Wed, 02 Aug 2017 06:19:07 -0000 Hi. Thanks for the response.. ->The ignite version used is 1.9.0. ->With Java Client its working fine. --------------------------------- ignite config xml --------------------------------------------------------- com.ignitetest.PersonPK com.ignitetest.PersonPK com.ignitetest.Person 127.0.0.1 ---------------------------------persistence settings --------------------------------------------------------- ---------------------------------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 #include #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 { 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 #include #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 PersonCache = ignite.GetOrCreateCache("cache1"); std::cout << "CACHE SIZE before loadCache(): " << PersonCache.Size()<