KX Community

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

Home Forums kdb+ Amend Entire Works in memory but not with a handle?

  • Amend Entire Works in memory but not with a handle?

    Posted by jattwick on May 25, 2023 at 12:00 am

    I’ve noticed some weird behaviour with amend entire using lists of lists. The behaviour is different depending on whether on I use a file handle or pass the list directly to the function. Code to recreate is pasted below:

     

    weirdPartition:(1 2 3f;();enlist 1 2 3);
    file:`:./tester/weirdPartition;
    file set weirdPartition;
    addToWeirdPartition:(1 2 3f;4 5 6f);

    // amend at?

    // handle doesn’t work? type error?
    .[file;();,;addToWeirdPartition]
    // in memory works?
    .[get file;();,;addToWeirdPartition]

     

    Anyone explain why it does not work with a handle?

    jattwick replied 8 months, 2 weeks ago 2 Members · 2 Replies
  • 2 Replies
  • cillianreilly

    Member
    May 25, 2023 at 12:00 am

    I think this is due to the constraints specified here: https://code.kx.com/q/ref/amend/#on-disk, in particular that only vectors of types 1-19 can be updated directly on disk. Given that weirdPartition has type 0, it can’t be updated on disk, but has no such constraints in memory.

    Note: Personally unclear on whether the wording on the above link (“Certain vectors (types 1-19) can be updated directly on disk without the need to fully rewrite the file. “) means it can’t be done, or it can be done but that the entire file must be rewritten, and there is another issue at play here. I’m leaning towards the former, and that modifications must be done in memory first before writing.

  • jattwick

    Member
    May 25, 2023 at 12:00 am

    The weird thing for me is we have a process that writes in this fashion, running several times a day. In some cases, it fails (which makes sense given the explanation you have given), but it does work in some cases as well. might lean towards just re-architecting the datatypes for this table.

Log in to reply.