Hi all,
I have a question about access KDB database through C programming
interface:
The c code in my program is as following:
K qtable = ks(“SkewModelData”);
K qsym = ks(“.SPX”);
k(_hdbHandle,“lastsnap”,r1(qtable),r1(qsym),(K)0); //
crashed
And the function “lastsnap” in Q is:
lastsnap:{[x;s]
dt:last select date,time from x where sym=s;
d:dt[date]; t:dt[
time];
:select from x where sym=s,date=d,time=t}
The lastsnap function runs well in Q command line. But the C program
crashed with error “stack overflow”.
Could anyone give me a hint? Thank you.
charset=us-ascii
Message-Id: <217BA86B-8727-41E7-B7E8-BF3FECF9C7CD@kx.com>
Cc: Kdb+ Personal Developers
X-Mailer: iPad Mail (8J3)
From: Charlie Skelton
Subject: Re: [personal kdb+] KDB+ C programming overflow
Date: Tue, 15 Nov 2011 08:48:28 +0100
To: “personal-kdbplus@googlegroups.com”
did you init memory correctly?
i.e. call khp before creating any k objects?
what is the meta for SkewModelData?
btw, lastsnap looks quite inefficient.
Apart from the C error, why dont you refactor your lastsnap functionas followslastsnap:{[x;s] ?[t;enlist (=;
sym;enlist s);(enlist sym)!(enlist
sym);()]}On Nov 15, 1:27?am, Weiyi Zhang <weiyi.zhang2…> wrote:> Hi all,>> I have a question about access KDB database through C programming> interface:>> The c code in my program is as following:>> K qtable = ks(“SkewModelData”);> K qsym = ks(“.SPX”);>> k(_hdbHandle,“lastsnap”,r1(qtable),r1(qsym),(K)0); ? ? ? ? ? ? ? //> crashed>> And the function “lastsnap” in Q is:>> lastsnap:{[x;s]> ?dt:last select date,time from x where sym=s;> ?d:dt[date];> ?t:dt[
time];> ?:select from x where sym=s,date=d,time=t}>> The lastsnap function runs well in Q command line. But the C program> crashed with error “stack overflow”.> Could anyone give me a hint? Thank you.</weiyi.zhang2…>