Issue in deserializing in q from c++

45 views
Skip to first unread message

Roni Hoffman

unread,
May 4, 2021, 7:23:42 AMMay 4
to Kdb+ Personal Developers
Hello, wondering if anyone has any ideas here

 I have been trying to publish a serialized K object from C++ using Kafka, and trying to deserialize using kdb/q (using -9!msg[`data]) on a kafka q topic listener. I am able to serialize/deserialize simple atomic types successfully, where as simple lists / mixed lists fail to deserialize throwing badmsg err.  However, a C++ consumer which listens to the topic is able to deserialize both simple list / mixed lists successfully.  Does anyone have any pointers here? . Publisher - C++

================ K msg = ktn(KI, 3);
kI(msg)[0] = 101;
kI(msg)[1] = 201;
kI(msg)[2] = 32;// K msg = knk(2, ki(112), ks("abc")); U g={2};
auto k = ks("(100;200;300)");
auto p = ::b9(3, msg); RdKafka::ErrorCode err =
producer->produce(topic,
RdKafka::Topic::PARTITION_UA,
RdKafka::Producer::RK_MSG_COPY /* Copy payload */,
kG(p), p->n,
NULL, 0,
0,
NULL,
NULL);Consumer = C++
================
// Simple List
K x= ktn(KG, payload.get_size());
memmove(kG(x), payload.get_data(), payload.get_size());
K row = d9(x);
std::cout<<"Payload :" << (int) kI(row)[0] << " 1 : "<< (int) kI(row)[1] << " 2 :" << (int) kI(row)[2] << std::endl;

Many thanks

Reply all
Reply to author
Forward
0 new messages