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

Using the c.cs interface found in Interoperating with C # , how to use a function k()

to get data from a long - temptation to compute?

What I would like to do is

conn.ks("compute_long_running_function[]");

      

Do something else

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

      

However, this last call does not return the last result - it will time out indefinitely if /T {N}

not set beforehand.

Is there a way to send data from the server to the client waiting for it? How else can you use a function k()

without arguments.

Please note that this question is also about java interface which is almost identical.

+3


source to share


2 answers


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

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

      

the result of the function will be sent over the loopback and obtained by conn.k ()

The alternative is simply:



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

      

which will return the results of the function when they are ready. But you probably already knew that.

Hello,

David

+3


source


If you call ks

, the return value of your function is ignored and you cannot use k()

it to get it.



You only use k () to get data explicitly sent to you by the process q

, as @David shows, using a negative client descriptor.

+1


source







All Articles