Hello,

Below is my redis client code through which i'm trying to store multiple
C++ Object to Ignite Server after serializing the object in to string using
protobuf serialization library.

The same code works fine in storing and retrieving for 10lakshs objects
with redis server. But the same client gives invalid data from 127 th
object while retrieval.

Look at he sample output Below:


=============
person.proto

syntax = "proto2";

package tutorial;

message  Myself{
      required int32 orgId = 1;
      required string firstName = 2;
      required string lastName = 3;
      required string resume = 4;
      required string other =6;
}
=============


#include <hiredis/hiredis.h>
#include "person.pb.h"


auto redis_context = redisConnect("127.0.0.1", 6379);
int _set(int32_t key, tutorial::Myself p){

std::string oss;
p.SerializeToString(&oss);
        const auto set_reply =
                redisCommand(redis_context, "SET %ld
%b",(long)key,oss.c_str(), oss.length());
        freeReplyObject(set_reply);

}
int _get(int32_t key){
        const auto get_reply =
                static_cast<redisReply*>(redisCommand(redis_context, "GET
%ld",(long)key));
        std::string repr{get_reply->str, static_cast<size_t>(get_reply->len)};

        std::cout<< "\nLength: " << get_reply->len << std::endl;
        if(static_cast<size_t>(get_reply->len) <= 0) {
                std::cout << "No key is matching" << std::endl;
                return -1;
        }

        freeReplyObject(get_reply);
  tutorial::Myself person1;
        person1.ParseFromString(repr);
   std::cout<<"\n" <<  person1.orgid() << "---" << person1.firstname() <<
"--" << person1.lastname() << "--" << person1.resume() << " --" <<
 person1.other() << std::endl ;


}
int main(int argc, char **argv) {

        int start = atoi(argv[1]);
        int range = atoi(argv[2]);

        tutorial::Myself person;
        for (int32_t i = start ; i < range ; ++i)
        {
                person.clear_orgid();
                person.set_orgid(i);
                person.set_firstname("John");
                person.set_lastname("Cena");
                person.set_resume("Analyst");
                person.set_other("Summa");

                _set(i,person);

        }
        for (int32_t i = start; i < range; ++i)
        {
                _get(i);
        }

        redisFree(redis_context);
}




*OUTPUT: ======= *

./a.out 125 129

125---John--Cena--Analyst --Summa

126---John--Cena--Analyst --Summa

127---John--Cena--Analyst --Summa

*3104751*---John--Cena--Analyst --Summa  //* in 127th object i could see
some junk value. *


Kindly let me know is there any configuration change to be done at ignite
server side.


NOTE: Included the connector Configuration already in the ignite server
configuration file.

Reply via email to