admin - admin
Forum Replies Created
-
AuthorPosts
-
adminKeymasterBoth qStudio and Pulse dynamically download drivers on first use.
The locations they store drivers are:
C:\Users\{windows-username}\pulse\libs
C:\Users\{windows-username}\qstudio\libs
./libNotice that last ./lib is the current directory that you are running pulse from.
If you have used clickhouse or dolphindb, they should already contain files named:
clickhouse-jdbc-0.4.6.jar
jdbc-1.30.22.5-jar-with-dependencies.jarTo use new versions, you can delete and replace those files with any newer version from a maven repository.
For example from here https://mvnrepository.com/artifact/com.clickhouse/clickhouse-jdbc/0.6.0 the files section has a link to .jar file:
https://repo1.maven.org/maven2/com/clickhouse/clickhouse-jdbc/0.6.0/clickhouse-jdbc-0.6.0.jarThen restart the application to pick up the new drivers.
We will update the drivers within Pulse and qStudio regularly but it requires manual testing and we won’t be doing this quickly for every version of all 30+ databases we support. So I hope this helps.
adminKeymasterPulse stores all dashboards, database connection details etc. to one single database file pulsedb.mv.db.
- Usually with a .zip install or running on linux/mac the file is called pulsedb.mv.db and in the current directory where you run Pulse.
- On a windows installation, Pulse is installed to C:\Program Files\pulse as is best practice on windows installs, Pulse saves the database to: C:\Users\{{current-username}}\pulse so that each user can have their own settings.
Note sometimes you will see both a pulsedb.trace.db and pulsedb.mv.db file. pulsedb.trace.db is a temporary file written to when Pulse is running to allow faster database operations.
I can’t think of many scenarios where Pulse would save then lose data and it hasn’t been reported by other users.
Perhaps the original pulse.mv.db was created with different user permissions? e.g. You installed and first ran as root and now are trying to run as a limited user?
Or you ran Pulse from a different current directory? Thereby creating different configurations?
Related articles:
- Pulse Architecture – Describes how there is a server/terminal component and a frontend react web UI.
- Config Settings – Is done via ENV variables.
adminKeymasterHi Quantific,
Let’s assume you have the kdb+ pivot code (https://stackoverflow.com/questions/30789471/pivot-table-in-kdb-q) and that:
trades_agg:1000#0!trades_agg
Then providing a UI to select columns is simple.Example video: https://youtu.be/GyTQqKmymSU
Steps:
- Add table trades_agg
- Add a Multi-select component with sql query: ([] c:cols trades_agg)
- Add a Multi-select component with sql query: ([] c:cols trades_agg)
- Add a Dropdown select component with sql query: ([] c:cols trades_agg)
- Add another table with the query:
piv[trades_agg;(),<code>${{key1}}; (),
${{key2}}; (),`${{key3}}]
i.e. You want three variables, then to place those 3 variables into the piv function while making sure they are lists of symbols.
// see https://stackoverflow.com/questions/30789471/pivot-table-in-kdb-q
// I then aggregate the data into equal sized bucketspiv:{[t;k;p;v]
/ controls new columns names
f:{[v;P]`${raze ” ” sv x} each string raze P[;0],’/:v,/:\:P[;1]};
v:(),v; k:(),k; p:(),p; / make sure args are lists
G:group flip k!(t:.Q.v t)k;
F:group flip p!t p;
key[G]!flip(C:f[v]P:flip value flip key F)!raze
{[i;j;k;x;y]
a:count[x]#x 0N;
a[y]:x y;
b:count[x]#0b;
b[y]:1b;
c:a i;
c[k]:first'[a[j]@’where'[b j]];
c}[I[;0];I J;J:where 1<>count'[I:value G]]/:\:[t v;value F]};/piv[trades_agg;
date
symtime;
exchangebuysell;
shares]
adminKeymasterWe’ve added a full listing of string functions here:
http://www.timestored.com/kdb-guides/kdb-string-functions
adminKeymaster
adminKeymasterKdb doesn’t have a “case when then else”, it has something similar called vector conditional.
This link gives details: http://www.timestored.com/kdb-guides/q-quirks#caseStatementBasically standard SQL:
`SELECT
CASE
WHEN Date1 >= Date2 THEN Date1
ELSE Date2
END AS MostRecentDate`Kdb Code:
`q)update mostRecentDate:?[date1>=date2;date1;date2] from t
date1 date2 mostRecentDate
————————————
2001.08.05 2007.09.28 2007.09.28
2011.05.21 2007.07.25 2011.05.21
2005.08.10 2008.07.06 2008.07.06
2003.02.16 2008.10.11 2008.10.11
2007.10.05 2004.03.01 2007.10.05`The vector conditional takes three args ?[a;b;c]
a is a list of booleans
b and c are a list of same typed values
where a was true, the value is taken from b, otherwise it’s taken from c.
adminKeymasterThe .z namespace contains functions for accessing the current data and time. e.g.
q).z.t
09:56:06.145
q).z.d
2013.05.21The pattern is .z.{letter of data type wanted}
q)value each {x!x}`.z.p`.z.P`.z.t`.z.T`.z.d`.z.D`.z.n`.z.z`.z.Z
.z.p| 2013.05.21D09:56:06.145203000
.z.P| 2013.05.21D10:56:06.145203000
.z.t| 09:56:06.145
.z.T| 10:56:06.145
.z.d| 2013.05.21
.z.D| 2013.05.21
.z.n| 0D09:56:06.145203000
.z.z| 2013.05.21T09:56:06.145
.z.Z| 2013.05.21T10:56:06.145
adminKeymastergetenv
getenv `LOG_DIR
q)getenv `PATH
"C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Windows\\syst..
adminKeymasterFrom the console you can use ctrl+c to break during a long running command:
http://www.timestored.com/kdb-guides/debugging-kdb#interrupt-q
Make sure to exit debug mode so the server answers client queries.
adminKeymasterWe have added some notes on creating functional select that you may find useful:
http://www.timestored.com/kdb-guides/functional-queries-dynamic-sql
adminKeymasterYou could import printf like functionality using a C shared library (windows DLL, Linuz .so)
adminKeymasterIf you start kdb with the argument -T:
q -T 10
This will set a timeout on client queries of 10 seconds. Note not all queries are polite enough to stop when requested and I think commands at the console may ignore this setting.
You should also be able to modify this setting using
\T (seconds)
from within kdb.
adminKeymasterKdb outline how to import time zone data from java here:
http://code.kx.com/wiki/Cookbook/TimezonesAlmost all math operators work on the underlying time data formats. For example if you use xbar on time, you casn easily round time to the nearest 5 minutes.
Functions for handling time include:
.Q.addmonthsTime Handling Settings
\z changes US/UK date formatVariables for returning time in various formats:
.z.n gmt (timespan)
.z.N local (timespan)
.z.p gmt (timestamp)
.z.P local (timestamp)
.z.z gmt time (datetime)
.z.Z local time (datetime)
.z.D .z.d .z.T .z.T
ltime
gtime
adminKeymasterFor reading a pipe delimited file you can use 0:
Here I first use read0 to read the file as a list of strings, to demonstrate it’s the same format you gave:
q)read0 `:source.txt
"name|id|age|height"
"P13141|212314|23|167"
"R3145|212315|34|190"On the right hand side of 0: We supply the file handle.
On the left is a two item list
“SJII” – denotes the four types for each column – symbol, long, int, int
enlist “|” – means take the pipe as the delimiter and enlist tells kdb there is a header row
like so:
q)("SJII"; enlist "|") 0: `:source.txt
name id age height
------------------------
P13141 212314 23 167
R3145 212315 34 190
adminKeymasterq code is evaluated right to left. When you say:
select from t where a=1 or b=`c
What kdb is evaluating is:
select from t where a=(1 or (b=`c))
Which reduces to:
select from t where a=1
You can see this from the example below:
q)t:([] a:5?01b; b:5?`c`d)
q)t
a b
---
0 c
1 c
1 d
0 c
0 d
q)select from t where a=1 or b=`c
a b
---
1 c
1 d
q)select from t where a=(1 or b=`c)
a b
---
1 c
1 dTo make kdb behave how you expect place parentheses around a=1 like so:
q)select from t where (a=1) or b=`c
a b
---
0 c
1 c
1 d
0 cThere is a similar issue when using “and”, though mostly in kdb you will want to use comma to separate conditions rather than “and”.
-
AuthorPosts