ManagedkdbInsights/basic_tick_V3/basictick/tick.q (73 lines of code) (raw):

/ q tick.q sym . -p 5001 </dev/null >foo 2>&1 & /2014.03.12 remove license check /2013.09.05 warn on corrupt log /2013.08.14 allow <endofday> when -u is set /2012.11.09 use timestamp type rather than time. -19h/"t"/.z.Z -> -16h/"n"/.z.P /2011.02.10 i->i,j to avoid duplicate data if subscription whilst data in buffer /2009.07.30 ts day (and "d"$a instead of floor a) /2008.09.09 .k -> .q, 2.4 /2008.02.03 tick/r.k allow no log /2007.09.03 check one day flip /2006.10.18 check type? /2006.07.24 pub then log /2006.02.09 fix(2005.11.28) .z.ts end-of-day /2006.01.05 @[;`sym;`g#] in tick.k load /2005.12.21 tick/r.k reset `g#sym /2005.12.11 feed can send .u.endofday /2005.11.28 zero-end-of-day /2005.10.28 allow`time on incoming /2005.10.10 zero latency "kdb+tick 2.8 2014.03.12" /q tick.q SRC [DST] [-p 5010] [-o h] show "TP: START" show "Command Line Arguments..." params:.Q.opt .z.X show params / read in params .tp.procName:first params`procName .tp.volumeName:first params`volumeName / to simulate of day /tp("{.u.end .u.d;if[.u.l;hclose .u.l;.u.l:.u.ld .u.d]}[]") / cd to code directory \cd /opt/kx/app/code / BEGIN load libraries relative to the code directory /load schema \l taq.schema.q / END load libraries src:"sym" path:"/opt/kx/app/shared/",.tp.volumeName,"/",.tp.procName \l tick/u.q \d .u ld:{if[not type key L::`$(-10_string L),string x;.[L;();:;()]];i::j::-11!(-2;L);if[0<=type i;-2 (string L)," is a corrupt log. Truncate to length ",(string last i)," and restart";exit 1];hopen L}; tick:{init[];if[not min(`time`sym~2#key flip value@)each t;'`timesym];@[;`sym;`g#]each t;d::.z.D;if[l::count y;L::`$":",y,"/",x,10#".";l::ld d]}; endofday:{end d;d+:1;if[l;hclose l;l::ld d]}; ts:{if[d<x;if[d<x-1;system"t 0";'"more than one day?"];endofday[]]}; if[system"t"; .awscust.z.ts:{.u.pub'[t;value each t];@[`.;t;@[;`sym;`g#]0#];i::j;.u.ts .z.D}; upd:{[t;x] if[not -12=type first first x;if[d<"d"$a:.z.P;.z.ts[]];a:"n"$a;x:$[0>type first x;a,x;(enlist(count first x)#a),x]]; t insert x;if[l;l enlist (`upd;t;x);j+:1];}]; if[not system"t";system"t 1000"; .awscust.z.ts:{.u.ts .z.D}; upd:{[t;x].u.ts"d"$a:.z.P; if[not -12=type first first x;a:"n"$a;x:$[0>type first x;a,x;(enlist(count first x)#a),x]]; f:key flip value t;pub[t;$[0>type first x;enlist f!x;flip f!x]];if[l;l enlist (`upd;t;x);i+:1];}]; \d . .u.tick[src;path]; \ globals used .u.w - dictionary of tables->(handle;syms) .u.i - msg count in log file .u.j - total msg count (log file plus those held in buffer) .u.t - table names .u.L - tp log filename, e.g. `:./sym2008.09.11 .u.l - handle to tp log file .u.d - date /test >q tick.q >q tick/ssl.q /run >q tick.q sym . -p 5010 /tick >q tick/r.q :5010 -p 5011 /rdb >q sym -p 5012 /hdb >q tick/ssl.q sym :5010 /feed