Reputation: 115
Say I have two different subfolders in my hdb directory, folder A and folder B. Both have the data inside partitioned by date and the sym files enumerated against each individual table. Directory A has 1 sub table, `quote and directory B has another table `trade. I am able to load both of these directories into my q session individually using:
system "l /dir/A"
system "l /dir/B"
When I then attempt to click on the tables that were in directory 'A' I face the following error in QStudio:
kx.c$KException: ./2020.04.21/quote. OS reports: No such file or directory
Now if I go an execute the following again:
system "l /dir/A"
The error disappears but I face the same style of error when I now try and click on the trade table. Does anyone know if it's possible to load from two separate directories into one service?
Upvotes: 0
Views: 1332
Reputation: 1
It's possible to do without symlinks. Andrey Kozyrev wrote the code that moves between loaded HDB and sym files. You can find it under his https://github.com/quintanar401/DCoQ
.db.db:.db.dbm:(0#`)!(); .db.cdb:`;
.db.sdb:{if[not null .db.cdb;.Q[`sym`date]:(sym;date);.db.db[.db.cdb]:.Q;![`.;();0b;key .Q.dbt]]};
.db.ldb:{if[x in key .db.db;.db.cdb:x;.Q:.db.db x;`sym`date set' .Q`sym`date;system"cd ",.Q.dbp;set'[key .Q.dbt;value .Q.dbt]]};
.q.dbl:{.db.sdb[];system "l ",x;.db.cdb:last` vs`$":",x;.Q.dbp:x;.db.dbm[(` sv/: .db.cdb,/:t),t where{$[98=type x:get x;-11=type value flip x;0b]}each t:tables[]]:.db.cdb;.Q.dbt:t!get each t;};
.q.db:{if[null d:.db.dbm x;'x];if[not .db.cdb=d;.db.sdb[];.db.ldb d];last ` vs x};
then dbl"/kdb/history/fx" and then use db`trade as a reference to a table
Upvotes: 0
Reputation: 13572
If you have two different sym files not of the same name then you're in luck - you can simply create a synthetic database using symbolic links where the links point to both tables and then you can load the synthetic database. Of course maintaining the synthetic database is another issue but it's not too challenging. It would look like this:
synthdb/
2020.01.01/
trade -> /db1/2020.01.01/trade
quote -> /db2/2020.01.01/quote
2020.01.02/
trade -> /db1/2020.01.02/trade
quote -> /db2/2020.01.02/quote
splay1 -> /db1/splay1
splay2 -> /db2/splay2
flat1 -> /db1/flat1
flat2 -> /db2/flat2
sym -> /db1/sym
sym2 -> /db2/sym2
Upvotes: 2
Reputation: 2800
The problem here is that this second hdb load system "l /dir/B"
overwrites the first. When you load a hdb, kdb maps it into memory and uses the sym file to display enumerated sym cols in their original human readable form. It can only use 1 sym file to do this as enumerated columns are actually an index to where they are in the sym file and it wouldn't make sense to reference more than 1.
I think you should look at having them as one date partitioned hdb but if this is not an option you could setup 2 hdb processes with ports you can connect to:
// start hdbA with quotes
q /dir/A -p 12345
// start hdbB with trades
q /dir/B -p 23456
// connect to hdbB from hdbA
hdbB:hopen `::23456;
// example query
hdbB"select from trades where date = .z.d"
// connect to hdbA from hdbB
hdbA:hopen `::12345;
// example query
hdbA"select from quotes where date = .z.d"
Upvotes: 2