Forum Replies Created

Page 6 of 8
  • davidcrossey

    Member
    May 14, 2022 at 12:00 am in reply to: how to solve this allocation problem

    If you had the following scenario, you could sort the reward desending, sort the pickSeq ascending and use indices to solve for your problem:

    q)n:10 
    q)people:([]pickSeq:0+til n;person:`$"person",/:string 1+til n;allowedToPick:n?01b)
    q)people 
    pickSeq person allowedToPick 
    ------------------------------ 
    0 person1 1 
    1 person2 1 
    2 person3 1 
    3 person4 1 
    4 person5 0 
    5 person6 0 
    6 person7 0 
    7 person8 1 
    8 person9 0 
    9 person10 0 
    
    q)rewards:([]prize:(1+til 10)*100) 
    q)rewards 
    prize 
    ----- 
    100 
    200 
    300 
    400 
    500 
    600 
    700 
    800 
    900 
    1000 
    
    q)(update ind:i from xdesc[`prize;rewards]) lj `ind xkey update ind:i from select person from xasc[`pickSeq;people] where allowedToPick 
    prize ind person 
    ----------------- 
    1000 0 person1 
    900 1 person2 
    800 2 person3 
    700 3 person4 
    600 4 person8 
    500 5 
    400 6 
    300 7 
    200 8 
    100 9

    You could also extract the person and their prize as follows:

    q){if[1=count x;x:enlist x]; if[1=count y;y:enlist y]; y!x iasc y}[exec desc prize from rewards;] exec person from xasc[`pickSeq;people] where allowedToPick 
    person1| 1000 
    person2| 900 
    person3| 800 
    person4| 700 
    person8| 600
  • davidcrossey

    Member
    May 9, 2022 at 12:00 am in reply to: Brand New to qSql

    If it’s not an exact match, you could wrap the second column in wildcards characters and use Like Each like'

    select from data where childID like’ (“*”,’parentID,'”*”)

    Note – this assumes that the parentID has less characters than childID

  • davidcrossey

    Member
    May 3, 2022 at 12:00 am in reply to: Whats the best toolset for developing in kdb+?

    VS Code in WSL with the KDB+/Q extension here

  • Check out the architecture diagram on Sync requests – KX Platform for an idea of how you could set this up.

    Your Java client can use sync requests with a Gateway (GW) process.

    The GW can then defer the response to the Java client and send the query (async) through a Query Router (QR), thus allowing the GW to handle more client requests.

    Queries then flow on to a Query Process (QP) which completes the actual work, before sending the result back to the GW, and then finally the client.

    Please also see information on Callbacks

  • davidcrossey

    Member
    April 14, 2022 at 12:00 am in reply to: how to create temp variable inside $[]

    You can do something like the following:

    q)f:{[x] $[x~`a;5;x~`b;[y:6*6;$[y<6;6;y>9;10;y]];x]} 
    q)f {[x] $[x~`a;5;x~`b;[y:6*6;$[y<6;6;y>9;10;y]];x]} 
    q)f `a 5 
    q)f `b 10

    I would use a function (as above) or a lambda (anonymous function), that way your temp variable will only remain for the scope of the function i.e. in the example above, does not exist in my global namespace after execution. You can read more about conditional scope here

    You can see if x is b in the above we have square brackets [ ] which defines a contained block of code to run if the statement is true. See more here

    Please find more on the extended if-else / switch statement here

  • davidcrossey

    Member
    April 13, 2022 at 12:00 am in reply to: Q on Linux: Can’t use arrow keys

    You’ll need to install a utility program like rlwrap and run that when you start q to add command history navigation within your q session.

  • davidcrossey

    Member
    April 11, 2022 at 12:00 am in reply to: Query Routing/ Load Balancing / asynchronous callbacks

     

    I think the issue is that you are blocking on the client as your last command

    x[]

    Interprocess communication | Basics | kdb+ and q documentation – Kdb+ and q documentation (kx.com)

    They may be no message being sent back from the client, especially true if is an issue on the server, or if you don’t have a callback on the calling handle.

    Perhaps you meant to async flush?

    neg[x][]

    Might be worth while putting a nohup on the front of your ‘&’ commands, and I’d also suggest opening you handle as the projection, instead of opening per call to GW. You could add a check in your funct to check if the handle is valid and reopen as needed?

    Just an note – you could save that function in any file, and source; doesn’t have to be .bashrc unless that’s your intention.

  • To handle multiple concurrent client sync requests you could consider using deferred response to suspend sync queries whilst they are being processed, allowing your gateway to process further client requests. The result will be returned to the client when processing has completed.

  • davidcrossey

    Member
    April 11, 2022 at 12:00 am in reply to: Unable to run/install Q Developer

    Specific port number shouldn’t be an issue.

    Best to source all of the config params prior to running the launcher.q_ script as per this note i.e. running the config.bat script first.

  • davidcrossey

    Member
    April 7, 2022 at 12:00 am in reply to: Financial chart

    ChartIQ requires a separate licence to run.

    Generally you should utilise the custom financial chart, or alternatively canvas charts/chartGL which both have candlestick charts built in.

  • davidcrossey

    Member
    April 6, 2022 at 12:00 am in reply to: Financial chart

    Do you have any data coming back through your data source “temp”?

  • davidcrossey

    Member
    April 6, 2022 at 12:00 am in reply to: Is there a tuning guide document for production?

    Check out the following for each of your questions.

    1. Linux production notes Knowledge Base kdb+ and q documentation – Kdb+ and q documentation (kx.com)
    2. Logging Best Practices – KX
    3. If using KX Platform, Monitoring – KX Platform, or you could export metrics using Prometheus Exporter to visualise in another client application

    Hope this helps.

  • davidcrossey

    Member
    April 6, 2022 at 12:00 am in reply to: Financial chart

    A few things here;

    1. You won’t see any bars as your open/high/low/close prices are all the same value. In your test data you need a range of prices over the course of a day (for example), then you would take the first/max/min/last (OHLC) per date
    2. The documentation appears to be a little misleading with “Time” column. It should be a timestamp.

    Here is a mock example I’ve just put together and a data source for reference

    Data Source

    n:10000; t:([]Date:n?.z.p;price:n?100f;Volume:n?100f); delete price from update Open:first price, Close:last price, High:max price, Low:min price, Volume:sum Volume by `date$Date from t

    Hope this helps

  • davidcrossey

    Member
    April 4, 2022 at 12:00 am in reply to: Query Routing/ Load Balancing / asynchronous callbacks

    Hi Simon,

    Thanks for sharing your query.

    Just curious if you have you tried either of these approaches outside of Developer on raw q processes to run as async callbacks?

    Regards,

    David

  • davidcrossey

    Member
    April 4, 2022 at 12:00 am in reply to: KX Maintain a proper GoLang package?

    Hi ekallivrousis,

    Just an update here. There currently isn’t any plans to develop and support a Go interface from KX.

    It may be worthwhile engaging with the wider community provided interfaces if you run into particular issues.

    Kind regards,

    David

Page 6 of 8