Hi,
With the latest q.exe/q.lib released on 3 March, I’m now able to build my project with okx() for validity check on serialized data.
But I encountered one problem – data serialized by b9(-1, k) are reported as 'badmsg in both q and by okx().
Test code attached below:
============================================test.h=================================================
#define KXVER 3
#include <k.h>
#ifdef __cplusplus
extern “C” {
#endif
KDB_API K K_DECL testSerial(K);
#ifdef __cplusplus
}
#endif
============================================test.h=================================================
============================================test.cpp=================================================
#include <iostream>
#include <iomanip>
KDB_API K K_DECL testSerial(K a) {
K k = ktn(0, 1);
kK(k)[0] = kp(“000001.SZ”);
K s = b9(-1, k);
for (G* i = kG(s); i < kG(s) + s->n; ++i) {
std::cout << std::setiosflags(std::ios::uppercase) << std::setfill(‘0’) << std::setw(2)
<< std::hex << static_cast<int>(*i);
}
std::cout << std::endl;
std::cout << "okx = " << okx(s) << std::endl;
if (a->g) {
r0(s);
return k;
}
else {
r0(k);
return s;
}
}
============================================test.cpp=================================================
============================================test.q=================================================
\c 20 2000
testSerial:(hsym
$"./kdb+")2:(
testSerial;1);show testSerial;
show testSerial 1b;
show testSerial 0b;
show -8!testSerial 1b; /NOTE -8! output is different from b9 output
show -9!testSerial 0b;
============================================test.q=================================================
The output is as following, note that: (1) -8! output is different from b9 output; (2) b9 output is getting okx() to return 0, and -9! to return 'badmsg.
============================================CONSOLE=================================================
D:\DEV\CHF>q test.q
KDB+ 3.2 2015.03.05 Copyright (C) 1993-2015 Kx Systems
w32/ 4()core 4095MB Think flying-thinkpad 192.168.10.104 NONEXPIRE
Welcome to kdb+ 32bit edition
For support please see http://groups.google.com/d/forum/personal-kdbplus
Tutorials can be found at http://code.kx.com/wiki/Tutorials
To exit, type \
To remove this startup msg, edit q.q
code
0100000125000000000001000000000000000A0009000000000000003030303030312E535A
okx = 0
“000001.SZ”
0100000125000000000001000000000000000A0009000000000000003030303030312E535A
okx = 0
0x0100000125000000000001000000000000000a0009000000000000003030303030312e535a
0100000125000000000001000000000000000A0009000000000000003030303030312E535A
okx = 0
0x010000001d0000000000010000000a00090000003030303030312e535a
0100000125000000000001000000000000000A0009000000000000003030303030312E535A
okx = 0
k){0N!x y}
'badmsg
@
“q”
“show -9!testSerial 0b;”
q))
============================================CONSOLE=================================================