Forum Replies Created

Page 1 of 2
  • sujoy

    Member
    August 18, 2024 at 5:05 am in reply to: fills in functional update

    Your syntax is incorrect

    {x!fills x} enlist px!px{x!fills,/:x} enlist px</code><p><span style="font-size: 1rem;">px| ^\px

  • sujoy

    Member
    July 31, 2024 at 12:24 pm in reply to: Unintentionally replacing the new sym file with old one broke the db

    It won’t work. Indexing in sym file will be different.

    The only way here to fix it will be to completely copy replica db to the current db.

  • sujoy

    Member
    July 28, 2024 at 2:46 am in reply to: Using the partition type as a parameter

    The main issue here is changing the .Q.pf (date) value while running the function in scope. Resulting in the error.

    Each select query runs, .Q.ps, and while evaluating the where clause, the partition field which is expected to be a list, becomes an atom and (&) fails with type error

    When you enlist it, it will work because “where eval c” will always return 1b, which eventually translates into the first partition.

    d@:&-6!*c

    You can override it to work, if you still want to use it in the function

    f:{[date;tab]

    c:enlist (=;date;date);

    date:.Q.pv;

    ?[tab;c;datesym!datesym;(enlistcnt)!enlist (count;`i)]

    }



  • sujoy

    Member
    July 27, 2024 at 6:25 am in reply to: Range Bar in kdb

    <div>It seems to me, you need to break when the range is met.</div>

    f:{1+1_first -2#{x,last where z=abs y[last x] - y}[;x;y]\ [{0<=last deltas -2#x};0]}

    where (1+til count c)!c:deltas f[lastPrice;rangeTarget]

    1 1 1 1 2 2 2 3 3 3 4 4 4

  • sujoy

    Member
    June 16, 2024 at 3:46 am in reply to: Fast file reading

    I think, read0 (0::) is reading 1 line at a time, while 0: is picking up columns. 0: will be faster, if you exactly know which position you are looking at.

  • sujoy

    Member
    June 16, 2024 at 3:26 am in reply to: .z.pd function throwing error for non unique handles

    Your function is using peach and setting -s -2, it is expecting handles on .z.pd, which is blank and hence failing.

    Start your process

    q -s 2

    q).z.pd:u#int$()

    q).z.pd

    u#int$()

    q){x+til 2} peach til 2

    0 1

    1 2

    q)\s -2

    q){x+til 2} peach til 2

    '.z.pd - expected unique vector of int handles

    [0] {x+til 10} peach til 10

    ^

    q))

  • sujoy

    Member
    June 5, 2024 at 1:35 pm in reply to: Keeping data querable while processes are taking down
  • Based on your problem statement,

    i would first ensure tp is sending the data as a table to subscriber’s and same is stored in tplog.

    Next whenever TP has a new Table, tp should append the same in .u.w for each (or required) subscriber (rdb)

    rdb on upd will simply insert. So a new table should appear without any data loss.

    Thanks

    Sujoy

  • sujoy

    Member
    January 24, 2024 at 12:00 am in reply to: Selecting date from table

    The error represents “TRADE_DT” is not in the table. Most likely you are overriding “test” somewhere in the code, which does not have the column “TRADE_DT”.

    As such the query has no issues, it should work.

  • sujoy

    Member
    August 5, 2023 at 12:00 am in reply to: Parallelising .Q.dpft with default compression enabled

    This is cool. I also have used and created similar override to .Q.dpft. Use case is valid till 3.6.

    If you use KX 4.0 with slaves, it internally is optimised to save data faster on disk (Probably some c code ). Something I did not find in the KX release notes.

    In my tests, it will beat/match the peach override.

    Many Thanks

    Sujoy

  • sujoy

    Member
    June 24, 2023 at 12:00 am in reply to: .Q.par Doesn’t Provide the Correct Result in the Segmented db.

    Seems like a case when entries were added in par.txt from possibly 3 to 8 without moving the partitions to correct locations. Only way to fix this is to move all the partitions to right locations.

    These all will be giving inconsistent results

    `l `bv `L `a2 `par `dpts `dpt `dpft `dpft `dsftg `chk

     

  • sujoy

    Member
    April 17, 2023 at 12:00 am in reply to: How to walkthrough a tree and calculate value on path?

    Try to traverse through Dictionary

    tree:([]parent:`A`A`A`B`B`E`E;child:`B`C`D`E`F`G`H;data:(1;2;3;4;5;6;7)); 
    tree:([]parent:`A`A`A`B`B`E`E;child:`B`C`D`E`F`G`H;data:(1;2;3;4;5;6;7)); 
    traverse_dict:exec child!parent from tree; 
    calc:`A`D`C`B`F`E`G`H!1 3 2 1 5 4 6 7; 
    traverse_func:{[st;end;dict;calc] prd calc except[(dict) end;(dict) st] }[;;traverse_dict;calc]; 
    outputTree:([] parent:`A`A`A`A`A`B`B`B`E`E;child:`C`D`F`G`H`F`G`H`G`H); // output update 
    val:traverse_func'[parent;child] from outputTree

     

  • sujoy

    Member
    September 17, 2022 at 12:00 am in reply to: .Q.qp for splayed table

    If you refer here: https://code.kx.com/q/basics/syscmds/#l-load-file-or-directory

    • serialized object, deserializes it into memory as variable name
    • directory of a splayed table, maps the table to variable name, without loading any columns into memory

    When you are running, l .t -> you are loading the object as t in root. Thus .Q.qp is showing t as 0

    % ls -lrth t
    total 16
    -rw-r–r–  1 sujoyrak**bleep**  staff    40B Sep 17 17:20 v1
    -rw-r–r–  1 sujoyrak**bleep**  staff    40B Sep 17 17:20 v2

    % q 
    KDB+ 4.0 2021.07.12 Copyright (C) 1993-2021 Kx Systems
    q)l .
    q)a
    ,`t
    q).Q.qp t
    0b
    q)l t
    `t
    q).Q.qp t
    0

     

  • sujoy

    Member
    September 11, 2022 at 12:00 am in reply to: xbar millisecond

    5 xbar `time$time

  • sujoy

    Member
    August 3, 2022 at 12:00 am in reply to: If conditions $ vs ?

    Apart from vector-based condition mentioned above, ? Will always run the fail condition unlike $.

    $[1;2;err]
    2
    
    ?[1;2;err]
    'err
    [0] ?[1;2;err]
Page 1 of 2