rocuinneagain
Forum Replies Created
-
rocuinneagain
MemberApril 29, 2022 at 12:00 am in reply to: Question about query that stuck the KDB processhttps://code.kx.com/q4m3/6_Functions/#677-more-over-iteration
The final overload of
/
is equivalent to a while loop in imperative programming. It provides a declarative way to specify a test to end the iteration. Thinking functionally, we provide a predicate function that is applied to the result at each step. The iteration continues as long as the predicate result is1b
and stops otherwise. For example, we stop the computation of the Fibonacci sequence once it exceeds 1000 as follows.q)fib:{x,sum -2#x} q)fib/[{1000>last x}; 1 1] 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597
Your code accidentally boiled down to an infinite loop as the result never moves to 0b
1 1/[sums;1]
/Each iteration it runs 1 1[1] / Which returns 1 /Then sums 1 /This returns 1 /This is a non zero value which gets treated as 1b so the loop starts again /Infinite loop
-
rocuinneagain
MemberApril 29, 2022 at 12:00 am in reply to: [checkHost.sh] Failed error when installing Platform on Ubuntu 20.04https://code.kx.com/platform/deployment/lin_prerequisites/#host-configuration
Kdb+ licenses (
k4.lic
) are tied to the hostname of a machine and specifically the hostname in FQDN (<HOSTNAME>.<DOMAINNAME>
) format.The installer expects the hostname to be the the required FQDN format .i.e
server1.company.com
-
rocuinneagain
MemberApril 22, 2022 at 12:00 am in reply to: Insert a not matching dictionary to a tableq){k:key y;x upsert enlist (k where k in cols x)#y}[x;td2] a b c ------- 1 I 10 2 J 20 3 K 30 99 a
-
rocuinneagain
MemberApril 17, 2022 at 12:00 am in reply to: apply the function, pass the return value to the function again, multiple roundsYou can so this using over
q)tab:([] A:1 2 3;B:4 5 6;C:7 8 9) // Sample table q)tab A B C ----- 1 4 7 2 5 8 3 6 9 q)func:{![x;();0b;enlist[y]!enlist (+;y;1)]} //Function I want to run q)func[tab;`A] // Same as: update A:A+1 from tab A B C ----- 2 4 7 3 5 8 4 6 9 q)func over enlist[tab],`A`B`C // Using over accumulator A B C ------ 2 5 8 3 6 9 4 7 10
-
rocuinneagain
MemberApril 17, 2022 at 12:00 am in reply to: Putting CSV data into a chart & other questionsThis is likely close to how qsql would be used based on your example
//Read CSV and store in memory table myCSV:("PFFFFF";enlist csv) 0: `$":/q/spy.csv" //Only retain lines where Line and close do not equal 0 myCSV:select from myCSV where Line<>0, close<>0 //Add deltas other extra columns myCSV:update dc:deltas Line, dclose:deltas close, dc2:1+til count i, dclose2:1+til count i from myCSV //Display the table myCSV
If you run those lines in Developer then you can use
myCSV
in your Dashboard widget to display it as the data is stored in an in memory table.set stores data in kdb+ binary files (not human readable).
If you wish to save as CSV either of these should work for you:
`:myCSV.csv 0: csv 0: myCSV save `myCSV.csv
-
-
Another Github user recently created a new Go interface: jshinonome/geek: golang interface for kdb+/q (github.com)
-
This behaviour happens with file handles also:
Applying the handle to data appends it to the file as bytes. Applying the
neg
of the handle to char data appends it as text. The result of a successful operation is the positive or negative handle.File system | Basics | kdb+ and q documentation – Kdb+ and q documentation (kx.com)
As to why I am not sure. The choice could have been made to return a generic null (::) instead possibly.
For stdout and stderr it can feel strange at first but it is not printing ‘hello1’ in one go. Instead ‘hello’ is printed as you requested then as you are in an interactive session the q) prompt wants to display the returned object so it then prints ‘1’.
q)1"hello"; //The ; stops the q) prompt from printing the returned object '1' hello q) q)-1"hello"; //-1 is often more useful as it includes a n newline char hello
-
- How are you trying to plot the data? table, bar, line etc. ?
- Are you seeing an error? Why do you say it cannot be plotted?
Common components to chart:
-
rocuinneagain
MemberMarch 21, 2022 at 12:00 am in reply to: What is the purpose of publishing value each t to t in .u.pub?This is batching mode when the timer
t
is set. https://code.kx.com/q/basics/syscmds/#t-timerIn this mode the TP will cache data and only publish it when the timer triggers
.z.ts
https://code.kx.com/q/ref/dotz/#zts-timerIn this case
t
is a list of tables and it callspub
on each of them ('
form) https://code.kx.com/q/ref/maps/#eachvalue
is called so that the cached data from the TP is populated inpub
to send to subscribers (RDB etc.)Some more information on batch mode: https://code.kx.com/q/wp/tick-profiling/
q)upd'[t;value each t] //A demo 'upd' which prints the parameters sent to it q)a:([] c1:1 2 3) q)b:([] c2:4 5 6) q)t:tables[] //Create list of tables q)t `s#`a`b q)upd'[t;value each t] (`a;+(,`c1)!,1 2 3) (`b;+(,`c2)!,4 5 6)
-
Can you include a small reproducible piece of code?
I do not see the files being created.
//Including kdb+ version information //If behaviour has changed include previous version information also q).z.k 2021.07.12 q).z.K 4f //An example table q)ot:([]a:1 2 3;b:`a`b`n;c:("jj";"kk";"pp")) q)save `ot `:ot //No # or ## files created by `save` keyword q){x where x like "ot*"}key `:. ,`ot
The # and ## files you see are used by the anymap datatype on disk.
You can still read your file with
get `:ot
-
The email you received with your kc.lic included some details on this topic:
Generally, kdb+ as an on-demand client behaves exactly like, and should be treated the same as, any plain http client (e.g. curl, apt-get or firefox) accessing a CDN-fronted web service.
It connects to a remote port 80 as part of a normal http request; thus you generally only need to allow outbound http _connections_ but both _traffic_ to and from remote port 80.
As the communication protocol is plain http you can employ any standard mechanism, including proxies (transparent and opaque by setting the HTTP_PROXY environment variable) as long as kdb+ is able to issue an http request and receive a response from the remote Kx service.
If you need to allowlist the remote servers should treat kdb+ on-demand as a CDN-fronted service and employ DNS-based filtering. The current list of hostnames required for kdb+ on-demand operation is {h,g}.kdbod.{com,net,org}. -
There is some background on DSL files here:
https://code.kx.com/q/wp/query-interface/#background
What documentation are you following for JDBC connectivity?
-
rocuinneagain
MemberFebruary 18, 2022 at 12:00 am in reply to: Anyone using the Tensorflow functional API from inside q(embedpy)?You could load the function in to q rather than redefine it line by line.
Example file.p
def get_model(input_shape, time2vec_dim = 3): inp = Input(input_shape) x = inp time_embedding = keras.layers.TimeDistributed(Time2Vec(time2vec_dim – 1))(x)
Load it and pull in the function:
q)l file.p q)get_model:.p.get`get_model q)get_model[(65;16)]
Another example of this: https://github.com/rianoc/qparquet
Looking to replicate an example from https://keras.io/api/layers/recurrent_layers/time_distributed/
q)lyr:.p.import`keras.layers q)x:lyr[`:Input;`shape pykw (10, 128, 128, 3)] q)conv_2d_layer:lyr[`:Conv2D;64;(3;3)] q)time_embedding:lyr[`:TimeDistributed;conv_2d_layer] q )outputs:time_embedding[x] q)print outputs[`:shape] (None, 10, 126, 126, 64)
-
rocuinneagain
MemberFebruary 15, 2022 at 12:00 am in reply to: embedPy inside q (kdb+) process fails to import a moduleThe error is that a variable “cxt” is not being found.
https://code.kx.com/q/basics/errors/#runtime-errors
General debugging tips included on: https://code.kx.com/q/basics/debug/
As this is a third party project you will get better support by raising an issue with the developer directly:
- https://github.com/michaelsimonelli/extendPy/issues
- https://github.com/michaelsimonelli/qoinbase-q/issues
The developer does not document the supported embedPy versions which would be important to know.
One difference I see is you are calling
pc:.cbpro.PublicClient[]
But the developer passes a string – this could be your issue
cli: .cli.priv.addFuncs .cbpro.PublicClient[url];