Reputation: 117
i am running the kdb tickerplant architecture with 1 tick process, 1 RDB process, and 1 HDB process. But tickerplant memory seems to be increasing which denotes slow consumer in this case RDB, so I would like to split the tables between 2 RDB's so inorder me to do that i need to modify the RDB script :
/q tick/r.q [host]:port[:usr:pwd] [host]:port[:usr:pwd]
/2008.09.09 .k ->.q
if[not "w"=first string .z.o;system "sleep 1"];
upd:insert;
/ get the ticker plant and history ports, defaults are 5010,5012
.u.x:.z.x,(count .z.x)_(":5010";":5012");
.u.end:{t:tables`.;
{0!x}each t;
t@:where `g=attr each t@\:`sym;
.Q.hdpf[`$":",.u.x 1;`:.;x;`sym];
@[;`sym;`g#] each t;
`account_balances set select by sym, asset from account_balances;
.Q.gc[];};
.u.rep:{(.[;();:;].)each x;
if[null first y;:()];
-11!y;
.Q.gc[];
`account_balances set select by sym, asset from account_balances;
`upd set (upsert);
system "cd ",1_-10_string first reverse y};
/ HARDCODE \cd if other than logdir/db
/ connect to ticker plant for (schema;(logcount;log))
.u.rep .(hopen `$":",.u.x 0)"(.u.sub[`trade;`];`.u `i`L)";
So i changed the above RDB script to subscribe to trade table only
.u.rep .(hopen `$":",.u.x 0)"(.u.sub[`account_balances;`];`.u `i`L)";
But i am getting this error :
'type
[3] /home/naseef/q/l64/tick/rdb.q:31: .u.rep:{(.[;();:;].)each x;
^
if[null first y;:()];
Upvotes: 0
Views: 138
Reputation: 13657
As per the comments on the original post: the issue here is that the RDB subscription logic assumes the schema will be a list of tuples, e.g. it assumes something like this
((`tab1;([]col1:`$()));(`tab2;([]colA:`$();col2:()));(`tab3;([]colB:`$())))
is returned from the .u.sub
component of the subscription call
"(.u.sub[`;`];`.u `i`L)"
In your case however, since you only subscribed to one table .u.sub[`trade;`]
, the schema was returned as a tuple rather than a list of tuples
(`trade;([]col1:`$();col2:()))
so then the line in .u.rep
which sets the schema in memory
(.[;();:;].)each x
didn't work as intended (since it expects to apply to each tuple).
My suggestion was to change the subscription call to
.u.sub[;`]each (),`trade
as this will essentially force the result to be an enlisted tuple
Upvotes: 1