Questions tagged [q-lang]

The q language is a programming language by kx.com for querying kdb+ databases.

Q was developed by Arthur Whitney in 2003 and is built on top of the K programming language. The names q and kdb+ are often used interchangeably, but generally q refers to the programming language and kdb+ refers to the entire runtime environment.

245 questions
4
votes
3 answers

Executing q in shell script

I need to load a q file with a hardcoded dictionary, insert a key and assign returned value from the dictionary to an environment variable inside a shell script. This how it would look like in q: q)\l /home/.../marketconfig.q q)show…
jump3r
  • 161
  • 1
  • 7
3
votes
2 answers

q kdb+ finding index of match elements using a list

Say I have a list b:1 1 2 3 4 and I want to find the location of the element in list b using another list a:1 2 When I type in b in\ a, I got 11000b 00000b where it should be 11000b 00100b What is going on and how to get the desired…
3
votes
1 answer

kdb q - license not found despite $QHOME set

In .bashrc and .profile I have my QHOME variable set to the directory that contains k4.lic, l64, q.k (validated by echo $QHOME). When I startup q from the login shell all works fine, the license file is found. When I start a q process…
tenticon
  • 2,639
  • 4
  • 32
  • 76
3
votes
2 answers

kdb q - apply each-left for each atom in list and reduce

I would like to apply each-left between a column of a table and each atom in a list. I cannot use each-both because the table column and the list are not of same length. I have seen this done in one line somewhere already but I can't find it…
tenticon
  • 2,639
  • 4
  • 32
  • 76
3
votes
2 answers

q - loading script with try catch

I have a q script on C:\some\path\startup.q that loads several other q scripts into the current session like this \l C:\some\other\path\script1.q \l C:\some\other\path\script2.q \l C:\some\other\path\script3.q Now, it could happen that I want to…
tenticon
  • 2,639
  • 4
  • 32
  • 76
3
votes
1 answer

Hitting enter results in KDB background process stopping

I am running a Kx Q process on my Linux server I notice that when I run this command that after I hit return/enter on my shell that the process stops ./kdb/q/l32/q -p 1234 & However, if I run this in the foreground... ./kdb/q/l32/q -p 1234 It…
DJ180
  • 18,724
  • 21
  • 66
  • 117
3
votes
3 answers

How to re-establish lost KDB connection in Java

In my Java application I am establishing KDB connection using private void initConnection() throws KException, IOException { conn = new c(host, port); conn.tz = TimeZone.getTimeZone(CONNECTION_TIMEZONE); } Then I use conn for inserting data…
AmbGup
  • 731
  • 1
  • 9
  • 23
3
votes
1 answer

How to update dependent values in KDB table

I am struggling finding an efficient way of updating column values fv when it depends on the previous values of some other columns sAA and sBB. These in turn needs to be updated with the newly calculated version of fv for the current date, then the…
Sven F.
  • 77
  • 6
3
votes
3 answers

Identify N maxes of a row, discarding the remaining bottom values from table rows

I've got stuck on the following problem and was hoping for some help. I've tried a few things and have used some information found on Stack Overflow (such as this/How to apply max function for each row in KDB? and this/Iterate over current row…
Sven F.
  • 77
  • 6
3
votes
2 answers

When are double quotes required to create a KDB/q symbol?

Normally, for simple character strings, a leading backtick does the trick. Example: `abc However, if the string has some special characters, such as space, this will not work. Example: `$"abc def" Example: `$"BAT-3Kn.BK" What are the rules when…
kevinarpe
  • 20,319
  • 26
  • 127
  • 154
3
votes
2 answers

KDB simple keyed table performance

I have the following table, about 3m rows. I want to know which approach/attributes I can use the squeeze maximum performance out of it. I will be selecting only on exact matches for inst +…
Tokyo D
  • 173
  • 2
  • 10
3
votes
3 answers

Why is the kdb+ epoch date 2000.01.01?

I am new to kdb+ and I was wondering why the epoch date of 2000.01.01 for kdb is different to that of unix (1970.01.01). Does the difference affect any interactions with the operating system or other languages?
user8992008
3
votes
4 answers

How to build a dictionary from contents of a csv file in kdb?

I have a csv file with contents like below source,address,table,tableName,sym,symSet source_one,addr1:port1:id1:pass1,table_one,tableName1,syms_one,SYM1 SYM2 SYM3 source_two,addr2:port2:id2:pass2,table_two,tableName2,syms_two,SYM21 SYM22 SYM23 My…
CleanSock
  • 363
  • 2
  • 4
  • 15
3
votes
2 answers

kdb conditional update and select in one query

I can do this: x:([]v: 4 2; w: 10 100) x: update z:`test from x where v = 4 x But i'd really like to be able to do the conditional update and select all in one hit. something like select v, w, (select `test from x where v = v) from z Is this…
user7613376
3
votes
1 answer

q - Application by name

In the q for mortals chapter on functions there is a little paragraph on "Application by name": q)f:{x*x} q)f[5] _ q)`f[5] 25 q)`f 5 _ q).my.name.space.f:{2*x} q)`.my.name.space.f[5] I don't understand where and why this would be used. Thanks for…
tenticon
  • 2,639
  • 4
  • 32
  • 76
1 2
3
16 17