rocuinneagain
Forum Replies Created
-
Both work perfectly fine. For someone new to Linux I would probably say try Ubuntu – if you have issues you’ll find more threads/tutorials online for it.
Windows Subsystem for Linux (WSL) is a great option to have access to Linux locally on your Windows machine.
- Install WSL | Microsoft Learn
- Ubuntu 22.04.5 LTS – Free download and install on Windows | Microsoft Store
- This reply was modified 3 days, 19 hours ago by rocuinneagain.
-
Hi,
What version of PyKX do you have installed?
You need at least 3.0.0 to use that syntax.
pip install pykx==3.0.1
-
/: each-right is what you want https://code.kx.com/q/ref/maps/#each-left-and-each-right
q).test.ex.t1:{[data] data};
q).test.ex.t2:{[data] data};
q).test.ex ./:((`t1;1);(`t2;1))
1 1
- This reply was modified 2 weeks, 2 days ago by rocuinneagain.
-
embedPy operates in a q first manner so you’d have to load your .p file and then call a q statement outside to do the assignment:
https://github.com/KxSystems/embedPy/tree/master/docs
q)func:.p.get[`func]
PyKX is the most flexible interface as it allows you do mix q first and Python first code in the same project
Python first assign a python function to a q variable
>>> kx.q['func'] = func
q first assign a python function to a q variable:
https://code.kx.com/pykx/2.5/pykx-under-q/intro.html#function-calls
q)func:.pykx.get[`func]
- This reply was modified 2 months, 1 week ago by rocuinneagain.
- This reply was modified 2 months, 1 week ago by rocuinneagain.
- This reply was modified 2 months, 1 week ago by rocuinneagain.
- This reply was modified 2 months, 1 week ago by rocuinneagain.
- This reply was modified 2 months, 1 week ago by rocuinneagain.
- This reply was modified 2 months, 1 week ago by rocuinneagain.
- This reply was modified 2 months, 1 week ago by rocuinneagain.
- This reply was modified 2 months, 1 week ago by megan_mcp.
- This reply was modified 2 months, 1 week ago by megan_mcp.
- This reply was modified 2 months, 1 week ago by megan_mcp.
- This reply was modified 2 months, 1 week ago by megan_mcp.
- This reply was modified 1 month ago by supportelearningwp-com.
- This reply was modified 1 month ago by supportelearningwp-com.
-
rocuinneagain
MemberOctober 5, 2024 at 11:54 am in reply to: How to run os commands in new KX Developer instanceYour other post asks about Windows.’ls’ and ‘pwd’ are Linux commands and will not work on Windows.
Try \dir which is a valid command in a Windows command prompt.
-
For example code use backslash to leave it as a multi line comment so those wishing to use this as a library can load the script without it running the example every time.
https://code.kx.com/q/basics/syntax/#comments
See example: https://github.com/KxSystems/kdb-tick/blob/master/tick.q#L50
- This reply was modified 2 months, 3 weeks ago by rocuinneagain.
- This reply was modified 1 month ago by supportelearningwp-com.
code.kx.com
Syntax | Basics | kdb+ and q documentation - kdb+ and q documentation
Syntax of the q programming language
-
The question is vague on what you are trying to do and how (no example code etc.)
Below is an example which when run results in:
HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello
Java can decompress the data which kdb+ compressed with .Q.gz without issue:
import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.zip.*; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.lang.String; import com.kx.c; public class Main { public static String decompress(final byte[] bytes) throws IOException { if (bytes == null || bytes.length == 0) { return ""; } try (final GZIPInputStream ungzip = new GZIPInputStream(new ByteArrayInputStream(bytes))) { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final byte[] data = new byte[8192]; int nRead; while ((nRead = ungzip.read(data)) != -1) { out.write(data, 0, nRead); } return out.toString(); } } public static void main(String[] args) { c c = null; Object result = null; byte[] bytes = null; try { c = new c("localhost", 5001); String query="`byte$.Q.gz(9;400#"Hello")"; result = c.k(query); bytes = ((byte[]) result); System.out.println(decompress(bytes)); } catch (Exception e){ System.err.println(e.toString()); } } }
- This reply was modified 2 months, 3 weeks ago by rocuinneagain.
- This reply was modified 2 months, 3 weeks ago by rocuinneagain.
- This reply was modified 2 months, 3 weeks ago by rocuinneagain.
- This reply was modified 2 months, 3 weeks ago by rocuinneagain.
- This reply was modified 2 months, 3 weeks ago by rocuinneagain.
- This reply was modified 2 months, 3 weeks ago by rocuinneagain.
- This reply was modified 1 month ago by supportelearningwp-com.
- This reply was modified 1 month ago by supportelearningwp-com.
-
This article may be of interest if you have not seen it:
-
rocuinneagain
MemberSeptember 11, 2024 at 4:18 pm in reply to: Store array of bytes in a table columnq does not have a type for lists of lists so you use the generic untyped list ()
q)tab:([] bytesCol:())
q)`tab insert enlist (0x0021;0x0002232)
0 1
q)tab
bytesCol
----------
0x0021
0x00002232
q)meta tab
c | t f a
--------| -----
bytesCol| X
q)type tab`bytesCol
0h -
rocuinneagain
MemberSeptember 9, 2024 at 8:14 am in reply to: Is it save to write to the same sym file by 2 or more q processes currently.Q.en uses ?. It is ? that does the locking. So both at the same time is fine.
See:
https://code.kx.com/q/ref/enum-extend/#filepath
code.kx.com
Enum Extend | Reference | kdb+ and q documentation - kdb+ and q documentation
Enum Extend is a q operator that extends an enumeration.
-
If a line ends in ; then the output is not displayed.
$ cat test.q
a:til 10
f:{x*y}
f[a;5]; /Not displayed
f[a;200] /Displayed
f[a;.01]; /Not displayed
$ q test.q
0 200 400 600 800 1000 1200 1400 1600 1800
q)-
Note that -1 will display items differently than letting q display them
$ cat test.q
a:til 10
f:{"the answer is "," "sv string x*y}
f[a;200] //Result will print but include "" around it
f2:{-1 "the answer is "," "sv string x*y}
f2[a;200] //Result printed to standard out does not display "". -1 is also shown as the returned value.
f2[a;200]; // Same as above but ; suppresses -1 bring shown
f3:{-1 "the answer is "," "sv string x*y;}
f3[a;200] //; moved inside the function to supress -1
$q test.q
"the answer is 0 200 400 600 800 1000 1200 1400 1600 1800" //f[a;200]
the answer is 0 200 400 600 800 1000 1200 1400 1600 1800 //f2[a;200]
-1 //f2[a;200] continued
the answer is 0 200 400 600 800 1000 1200 1400 1600 1800 //f2[a;200];
the answer is 0 200 400 600 800 1000 1200 1400 1600 1800 //f3[a;200]
-
-
rocuinneagain
MemberAugust 27, 2024 at 10:50 am in reply to: xgroup error in taxi and weather analysisAdd .reset_index() when you create the tables to unkey them, then the for loop will run as you expect. For example:
group_taxi_dates = kx.q.xgroup("pickup_date", taxi_tab).reset_index()
-
q)reply:"\360\237\221\215"
q)reply
"\360\237\221\215"
q)-1 reply;
👍 -
rocuinneagain
MemberAugust 27, 2024 at 10:46 am in reply to: How to deserialize a Kafka topic message with kfk.qYou do not need pollKafkaAsync.
Otherwise things look fine.