Skip to content

Commit 1595084

Browse files
GGabiGGabe73
andauthored
Schema now does not contain a copy of the entire table (#659)
* .stpps.schemas now contains only schemas and no other data * Preserving schema format for partitioned DBs * Added test case --------- Co-authored-by: GGabi <[email protected]>
1 parent df6a81e commit 1595084

File tree

6 files changed

+69
-1
lines changed

6 files changed

+69
-1
lines changed

code/common/pubsub.q

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ attrstrip:{[t]
114114
init:{[t]
115115
if[count b:t where not t in tables[];{.lg.e[`psinit;m:"Table ",string[x]," does not exist"];'m} each b];
116116
.stpps.t:t except b;
117-
.stpps.schemas:.stpps.t!value each .stpps.t;
117+
.stpps.schemas:.stpps.t!{t: value x; $[.Q.qp t; t; 0#t]} each .stpps.t;
118118
.stpps.tabcols:.stpps.t!cols each .stpps.t;
119119
};
120120

tests/schemas/insert_data.q

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
stpHandle:gethandle[`stp1]
2+
wdbHandle:gethandle[`wdb1]
3+
testtrade:((5#`GOOG),5?`4;10?100.0;10?100i;10#0b;10?.Q.A;10?.Q.A;10#`buy)
4+
testquote:(10?`4;(5?50.0),50+5?50.0;10?100.0;10?100i;10?100i;10?.Q.A;10?.Q.A;10#`3)
5+
stpHandle @/: `.u.upd ,/: ((`trade;testtrade);(`quote;testquote))
6+
wdbHandle(`.u.end;`.wdb.currentpartition)
7+
exit 0

tests/schemas/process.csv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
host,port,proctype,procname,U,localtime,g,T,w,load,startwithall,extras,qcmd
2+
localhost,{KDBBASEPORT}+100,discovery,discovery1,,1,0,,,${KDBCODE}/processes/discovery.q,1,,q
3+
localhost,{KDBBASEPORT}+101,segmentedtickerplant,stp1,,1,0,,,${KDBCODE}/processes/segmentedtickerplant.q,1,-schemafile ${TORQHOME}/database.q,q
4+
localhost,{KDBBASEPORT}+103,rdb,rdb1,,1,1,180,,${KDBCODE}/processes/rdb.q,1,,q
5+
localhost,{KDBBASEPORT}+104,hdb,hdb1,,1,1,180,,${TORQHOME}/hdb,1,,q
6+
localhost,{KDBBASEPORT}+105,wdb,wdb1,,1,1,180,,${KDBCODE}/processes/wdb.q,1,,q

tests/schemas/run.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# Handle command-line arguments
4+
source $KDBTESTS/flagparse.sh
5+
6+
#Set up the test env with data
7+
#path to test directory
8+
testpath=${KDBTESTS}/schemas
9+
10+
#start procs
11+
${TORQHOME}/torq.sh start discovery1 rdb1 stp1 hdb1 wdb1 -csv ${testpath}/process.csv
12+
${TORQHOME}/torq.sh summary -csv ${testpath}/process.csv
13+
14+
#Start test proc
15+
/usr/bin/rlwrap q ${TORQHOME}/torq.q \
16+
-proctype test -procname test1 \
17+
-load ${KDBTESTS}/helperfunctions.q ${testpath}/settings.q ${testpath}/insert_data.q \
18+
-procfile ${testpath}/process.csv -quiet
19+
20+
${TORQHOME}/torq.sh stop all -csv ${testpath}/process.csv
21+
22+
# Do the tests
23+
#start procs
24+
${TORQHOME}/torq.sh start discovery1 rdb1 stp1 hdb1 wdb1 -csv ${testpath}/process.csv
25+
26+
#Start test proc
27+
/usr/bin/rlwrap q ${TORQHOME}/torq.q \
28+
-proctype test -procname test1 \
29+
-test ${testpath} \
30+
-load ${KDBTESTS}/helperfunctions.q ${testpath}/settings.q \
31+
-procfile ${testpath}/process.csv -debug
32+
33+
#Shut down procs
34+
${TORQHOME}/torq.sh stop all -csv ${testpath}/process.csv

tests/schemas/settings.q

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.servers.CONNECTIONS:`wdb`segmentedtickerplant`hdb`idb`gateway`rdb
2+
.servers.startup[];
3+
4+
hdbdir: `$getenv[`TORQHOME],"/wdbhdb/"

tests/schemas/test.csv

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
action,ms,bytes,lang,code,repeat,minver,comment
2+
comment,0,,"Test 1 - Check all the schemas are empty after having written to the DB"
3+
before,0,0,q,\c 200 200,1,,"Set width of .Q.s1 to be wide enough for all tables"
4+
before,0,0,q,.servers.startup[],1,,"Start TorQ Connection Management"
5+
before,0,0,q,.proc.sys "sleep 2",1,,"Wait for process to start"
6+
before,0,0,q,hdbHandle:gethandle[`hdb1],1,,"Open HDB handle"
7+
before,0,0,q,schemas:hdbHandle`.stpps.schemas,1,,"Open HDB handle"
8+
true,0,0,q,([]time:`timestamp$();sym:`symbol$();procname:`symbol$();counter:`long$();pid:`int$();host:`symbol$();port:`int$())~schemas`heartbeat,,,"Check the schema is empty"
9+
true,0,0,q,([]time:`timestamp$();sym:`symbol$();proctype:`symbol$();host:`symbol$();loglevel:`symbol$();id:`symbol$();message:())~schemas`logmsg,,,"Check the schema is empty"
10+
true,0,0,q,""+`time`sym`src`dest`srcport`destport`seq`ack`win`tsval`tsecr`flags`protocol`length`len`data!`packets"~.Q.s1 schemas`packets,,,"Check the partitioned table schema is as expected"
11+
true,0,0,q,""+`time`sym`bid`ask`bsize`asize`mode`ex`src!`quote"~.Q.s1 schemas`quote,,,"Check the partitioned table schema is as expected"
12+
true,0,0,q,""+`time`sym`bid`ask`bsize`asize`mode`ex`srctime!`quote_iex"~.Q.s1 schemas`quote_iex,,,"Check the partitioned table schema is as expected"
13+
true,0,0,q,""+`time`sym`price`size`stop`cond`ex`side!`trade"~.Q.s1 schemas`trade,,,"Check the partitioned table schema is as expected"
14+
true,0,0,q,""+`time`sym`price`size`stop`cond`ex`srctime!`trade_iex"~.Q.s1 schemas`trade_iex,,,"Check the partitioned table schema is as expected"
15+
after,0,0,q,hclose hdbHandle,1,,"Close handles"
16+
after,0,0,q,.os.deldir logdir,1,,"Delete test logs"
17+
after,0,0,q,.os.deldir hdbdir,1,,"Delete test hdb"

0 commit comments

Comments
 (0)