KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ What exactly does .u.end do?

  • What exactly does .u.end do?

    Posted by mannix on March 17, 2022 at 12:00 am
    end:{(neg union/[w[;;0]])@:(`.u.end;x)}

    I know the following:
    1) that union/[w[;;0]]) is grabbing the handles as integers picking the ones which are repeated.

    2) Neg obviously makes these negative for async.
    3) The apply each left then applies that to the list union/[w[;;0]])
    4) the x is usually a date?

    What is this actually doing, and what is the significance of x as the date?

     

    mannix replied 9 months, 1 week ago 3 Members · 2 Replies
  • 2 Replies
  • pmallon

    Member
    March 17, 2022 at 12:00 am

    Hi,

    1-3) Correct.

    4) yes this is a date, you will notice end is called from endofday function in tick.q, which is called when the date rolls, checked on the timer.

    endofday:{end d;d+:1;if[l;hclose l;l::0(`.u.ld;d)]};

    Where d is the current date the tp is running.

    .u.end will be an EOD function on the subscriber, commonly an RDB an example below from r.q:

    / end of day: save, clear, hdb reload
    .u.end:{t:tables`.;t@:where `g=attr each t@:`sym;.Q.hdpf[`$":",.u.x 1;`:.;x;`sym];@[;`sym;`g#] each t;}

    Hope that helps.

    Patrick

  • ghe

    Member
    March 23, 2022 at 12:00 am

    Hi,

    Here is another example:

    /end of day function - triggered by tickerplant at EOD 
    .u.end:{ hclose LogfileHandle; /close the connection to the old log file 
    /create the new logfile 
    logfile::hsym `$"RealTimeTradeWithAsofQuotes_",string .z.D; .[logfile;();:;()]; 
    /Initialise the new log file 
    LogfileHandle::hopen logfile; {delete from x}each tables `.};

    Hope this helps.

Log in to reply.