Search code examples
kdbkbd-rdb

Saving a kdb+ "unmappable" table to disk


I have a table in my rdb (running the standard r.q) that includes a nested list of floats of the form:

(((1.a 1.b);(2.a 2.b);...;(N.a N.b));((N+1.a N+1.b);...;(N+X.a N+X.b)))

When .u.end is called I get an "unmappable error".

Is there anyway to save deeply nested data to an hdb?


Solution

  • You can manually save these tables using the following steps:

    q)t:([] a:1 2 3; f:(1 2.0;(3 4.;5 6.); 7. 8.))
    q)t
    a f
    ---------
    1 1   2
    2 3 4 5 6
    3 7   8
    q)`:t/ set t
    k){$[@x;.[x;();:;y];-19!((,y),x)]}
    'type
    q.q))
    q.q))\
    q)
    

    Fails as nested type.

    q)`:t/ set select a from t
    `:t/
    q)`:t/.d set `a`f
    `:t/.d
    q)`:t/f set t`f
    `:t/f
    q)\l .
    q)t
    a f
    ---------
    1 1   2
    2 3 4 5 6
    3 7   8
    

    Succeeds but if you compare access speed with non-nested data, you will see access is very slow.

    It is probably not built-in behaviour to prevent users saving in this format without knowing the trade-offs.