Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions code/common/pubsub.q
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ selfiltered:{[x;y]
pub:{[t;x]
if[not count x;:()];
if[count h:subrequestall[t];-25!(h;(`upd;t;x))];
if[t in subrequestfiltered`tbl;
{[t;x] data:eval(?;t;x`filts;0b;x`columns);neg[x`handle](`upd;t;data)}[t;]
each select handle,filts,columns from subrequestfiltered where tbl=t
];
};
if[t in .stpps.subrequestfiltered`tbl;
{[t;x;sels] data:eval(?;x;sels`filts;0b;sels`columns);
if[count data;neg[sels`handle](`upd;t;data)]}[t;x;]
each select handle,filts,columns from .stpps.subrequestfiltered where tbl=t
];
};

// publish and clear tables
pubclear:{
Expand Down
1 change: 1 addition & 0 deletions tests/stp/TestCases.csv
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ RDB (or any Subscriber),Subscriptions,All Subscriptions,1.1.1,"Data is published
,,Update logs,1.1.6,"Data is published, it is saved in the log file",Update saved in log file,,MP,Done,subscription/subs.csv,
,,Error logs,1.1.7,"Bad update published, gets saved in error log",Bad update saved to log file,,MP,Done,subscription/subs.csv,
,,Filtered Subscription file missing ,1.1.8,Filtered sub file doesn't exist,Process fails to start,,MP,Done,subfile/subfilemissing.csv,is this one covered?
,,Publish only by filtered subsciptions,1.1.9,Subscriber subscribes with .u.sub[`table;`list`of`symbols],Consumer subscribes to specific list of sym data with only the specific data being published,,PK,In Progress,pubsub/pubsub.csv,
RDB ,Recovery - single daily log file (tabperiod=`none),"RDB Restart, all subscriptions",2.1.1,"RDB subscribes for all data, is bounced",Data is the same in the RDB pre and post bounce,,AW,Done,recovery/recoverysinglelog.csv,
,,"RDB restart, sym subscriptions (using .rdb.subscribesyms variable)",2.1.2,"RDB subscribes to a subset of syms, is bounced",Data is the same in the RDB pre and post bounce,,AW,Done,recovery/recoverysinglelog.csv,
,,"RDB restart, complex filter using filtered subs functionality ",2.1.3,RDB subscribes to a subset of data using filtered functionality ,Data is the same in the RDB pre and post bounce,"These are similar to 2.1.1 but for this type of TP log file the TP may have multple log files, all of which should be replayed. So the set up should be:
Expand Down
12 changes: 11 additions & 1 deletion tests/stp/pubsub/pubsub.csv
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,14 @@ run,0,0,q,psHandle(upsert;`trade;testtrade),1,,"Update trade table on pubsub"
true,0,0,q,1~count psHandle(`trade),1,,"Check there is one row in trade table"
run,0,0,q,neg[psHandle](`.stpps.pubclear;`trade),1,,"Call pubclear funtion"
true,0,0,q,0~count psHandle(`trade),1,,"Check that trade table has been cleared"
true,0,0,q,1~.tst.upd,1,,"Check that local UPD function has been called"
run,0,0,q,upd:upsert,1,,"Define upd for sub filter tests"
true,0,0,q,0~.tst.upd,1,,"Check that local UPD function has been called"
run,0,0,q,rdbHandle(`.u.sub;`trade;`AAPL`GOOG),1,,"Subscribe to filtered sym list"
run,0,0,q,rdbHandle"test:select from trade where i=(last;i)fby sym",1,,"Define set data to compare filter against"
run,0,0,q,rdbHandle".u.pub[`trade;test]",1,,"Force publish for the filtered list to check it is working as intended"
true,0,0,q,trade~rdbHandle"(select from test where sym in `AAPL`GOOG)",1,,"Check that published filtered sym list is same as select statement"
run,0,0,q,rdbHandle(`.u.sub;`trade;`AAPL`GOOG`MSFT),1,,"Re-subscribe with additional sym in the filtered sym list"
run,0,0,q,trade:0#trade,1,,"Empty local trade table to make sure nothing is in it before publishing filtered sym list"
run,0,0,q,rdbHandle".u.pub[`trade;test]",1,,"Force publish filter list again with updated sym list publishing to empty trade table"
true,0,0,q,trade~rdbHandle"(select from test where sym in `AAPL`GOOG`MSFT)",1,,"Check that updated published filtered sym list is same as select statement"