Hi Mark/Kim,
Now that I have this up and running, my goal is to collect some data in C++ and transfer it to kdb in the form of a dictionary. This seems like the most sensible method.
Then in kdb I can insert the data onto a table. The goal is to have this real-time.
I have been able to do the simpler task of sending across atoms with type float, however generalising to a dictionary is more difficult.
On top of that I cannot create K string objects as I cannot get the ss function to work.
Here is example code of my attempt which is not correct. Hopefully it’s not too far away, and you could point out the errors (please):
//Define empty table in kdb
tbl:( col1:();col2:();col3:())
//A dictionary K object is made up of key object and value object
//Define key
K key=ktn(KS,2); //only need 3 values
string col1=“string1”; //created string variable col1
string col2=“string2”;
string col3=“string3”;
kS(key)[0]=ss(col1); //intern the string using ss, of course not correct
kS(key)[1]=ss(col2);
kS(key)[2]=ss(col3);
//Define value
K val=ktn(0,2);
kK(val)[0]=kf(price1); //price1 and price2 are floats
kK(val)[1]=kf(price2);
kK(val)[2]=ks(sym); //not sure what to do here again for a string intern first? how?
//Create the dictionary
K result=xD(xkey,val);
K result1=k(handle,“func”,result,(K)0); //I opened a handle to kdb in earlier post
//where func is defined in kdb below:
func:{[d] tbl insert(d[
col1];d[col2];d[
col3])}
Note: I’m not experienced in C++ as you can tell. I want to get the data across from C++ to kdb where I am more comfortable.
I was initially not going to create a dictionary, just pass each value across separately where each takes a parameter is func.
However, if I have a lot of values then there’ll be too many parameters, so a dictionary seems like the sensible thing to use.
Though, as I mentioned i also had problems with strings, and I think the examples online are always char types, so how to do it for strings?
again, any help appreciated.
thanks,
John