How to use the k () function to receive data in kdb / q

advertisements

Using the c.cs interface found in Interfacing with C#, how do I use the k() function to receive data from a long-running computation?

What I would like to do is

conn.ks("compute_long_running_function[]");

Do something else

results=conn.k();//wait for data

However, this latter call does not return the last result -- it times out indefinitely unless /T {N} has been set beforehand.

Is there a way to send data from the server to the client that is waiting for it? How else would one use the k() function with no arguments.

Note that this question also applies to the java interface, which is nearly identical.


The k() function will block until it receives data from the remote socket. So if your function looked like this:

compute_long_running_function:{[] r:til 1000; neg[.z.w] r }

the function result will be sent over the loopback connection and be retrieved by conn.k()

The alternative is you just do:

results=conn.k("compute_long_running_function[]");

which will return the results of the function when they are ready. But you might have known that already.

Regards,

David