Skip to content

Commit a4aff2e

Browse files
authored
TorQ_679: Support immediate writing in WDB
The forcesave parameter disregards table count checks when .wdb.savetodisk is called on the timer. The .wdb.immediate argument has been added to configure this behaviour. Logic in .wdb.replayupd is unaffected by this configuration
1 parent 4a26653 commit a4aff2e

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

code/processes/wdb.q

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ mergenumbytes:@[value;`mergenumbytes;500000000]; /-d
4141

4242
mergenumrows:@[value;`mergenumrows;100000]; /-default number of rows for merge process
4343
mergenumtab:@[value;`mergenumtab;`quote`trade!10000 50000]; /-specify number of rows per table for merge process
44+
immediate:@[value;`immediate;0b]; /-disregards .wdb.maxrows and writes down data every time timer calls .wdb.savetodisk
4445

4546
hdbtypes:@[value;`hdbtypes;`hdb]; /-list of hdb types to look for and call in hdb reload
4647
rdbtypes:@[value;`rdbtypes;`rdb]; /-list of rdb types to look for and call in rdb reload
@@ -166,7 +167,7 @@ savetablesbypart:{[dir;pt;forcesave;tablename;writedownmode]
166167
savetables:$[writedownmode in partwritemodes;savetablesbypart[;;;;writedownmode];savetables];
167168

168169
savetodisk:{[]
169-
changes:savetables[savedir;getpartition[];0b;] each tablelist[];
170+
changes:savetables[savedir;getpartition[];immediate;] each tablelist[];
170171
/- we have to let the idbs know of the changes in the wdbhdb. using filldb[] to make sure it is a db with all the tables
171172
if[any[changes] and writedownmode in `partbyenum`default;filldb[];notifyidbs[`.idb.intradayreload;enlist()]]};
172173

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
action,ms,bytes,lang,code,repeat,minver,comment
2+
before,0,0,q,update active:0b from `.timer.timer,,"Disable timer"
3+
before,0,0,q,.wdb.immediate:1b,,"Show that immediate write not used in .wdb.replayupd"
4+
true,0,0,q,(counts < .wdb.maxrows `quote) and (0 < counts:count quote),1,,"Show number of quotes played back from tplog are less than .wdb.maxrows[`quote]"
5+
true,0,0,q,delete quote from `.; system " " sv (enlist "l"; "/" sv ((getenv `KDBWDB); string .z.d)); 0 = count quote,1,,"Show that replayupd does not trigger savetables when quote is less than .wdb.maxrows[`quote]"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
action,ms,bytes,lang,code,repeat,minver,comment
2+
before,0,0,q,update active:0b from `.timer.timer,,"Disable timer"
3+
before,0,0,q,.wdb.immediate:1b,,"Enable immediate write down"
4+
before,0,0,q,quotetmp:quote,,"Store quotes from tplog"
5+
before,0,0,q,".wdb.ignorelist,:`KUT`KUTR`quotetmp",,"Ignore `KUT`KUTR`quotetmp tables for save down"
6+
before,0,0,q,.wdb.savetodisk[],1,,"Write down all tables and clear in-memory"
7+
before,0,0,q,quote:([] time:2#.z.p; sym:`NVDA`TSLA; bid:148.75 299.10; ask:148.85 299.15; bsize:2000 1500; asize:500 750; mode:"ZZ"; ex:"LO"; src:`BARX`GETGO),,"Make small number of quotes for test"
8+
true,0,0,q,(counts < .wdb.maxrows `quote) and (0 < counts:count quote),1,,"Given quote table exists but row count is under threshold of .wdb.maxrows[`quote]"
9+
true,0,0,q,.wdb.savetodisk[]; 0 = count quote,1,,"Quote table therefore cleared using forcesave param and maxrows inequality disregarded"
10+
true,0,0,q,system " " sv (enlist "l"; "/" sv ((getenv `KDBWDB); string .z.d)); (count quote) > (count quotetmp),,"And data is successfully written to disk"

0 commit comments

Comments
 (0)