Hi,
I am trying to process some data in c++. I first got my rawData on kdb+.
Then I converted it to a dictionary of tables for easier processing (not sure if this would be the best approach)
applyParamsR: {
dictR:: ()!();
tmp: raze addDictR each (select distinct date from rawData)`date;
dictR
};
applyParamsR
Then I just downloaded this in to c++ and stored in a K object say flip.
Then i created another variable processedFlip and initialized to flip.
Now I have a function called processData which essentially takes each table in this dictionary, processes it and then returns the modified table and i assign the processedFlip key to this modified table.
The trouble is when i try to access the flip again, it is now behaving like processedFlip. Instead of raw data, it now seems to have processed data. Is this expected behaviour? My raw data had 10 columns, on second run of applyParamC, there are only 8(as in processed data).
Some code below.
K applyParamC(K& allD, appParams& apar)
{
cout << “in appPC \n”;
K keys, data, dat1, dat1s, dat2s, procFlip;
int ndicts, row;
keys = kK(allD)[0];
data = kK(allD)[1];
ndicts = data->n;
procFlip = allD;
cout << “ndicts:” << ndicts << “\n”;
for(row=0; row<ndicts; ++row)
{ cout << "dictprocessed: " << row << “\n”;
dat1 = kK(data)[row];
dat1s = kK(dat1->k)[1];
dat2s = applyParamSin(dat1s, apar);
cout << “dat2s returned \n”;
kK(kK(procFlip)[1])[row] = dat2s;
//r0(dat2s);
}
return(procFlip);
}
main ----
K flip = getRawData();
K appFlip;
for(i=0; i<2; i++)
appFlip = applyParamC(flip, apar);
appParams is just a normal struct. applyParamC runs fine for the first time but when i call it again it gives a segmentation fault coz the code tries to access 9th column but now the data has only 8 columns.