Saving a keyed table to disk

437 views
Skip to first unread message

Nav

unread,
May 7, 2009, 11:03:55 AM5/7/09
to Kdb+ Personal Developers
Hi,

Is there a way to save a keyed table to disk?

I went through the documentation, but everywhere I looked, it spoke
about the table necessarily had to be a non-keyed table.

These were some of the references

1. .Q.dpft https://code.kx.com/trac/wiki/DotQ/DotQDotdpft
2. .Q.en https://code.kx.com/trac/wiki/Cookbook/SplayedTables#Enumeratingvarcharcolumnsinatable

Regards,
Nav

Felix Lungu

unread,
May 7, 2009, 11:59:10 AM5/7/09
to personal...@googlegroups.com
just save it as single file.

Tim Rieder

unread,
May 8, 2009, 7:28:09 AM5/8/09
to personal...@googlegroups.com
If you really want it splayed, unkey it first:

/ A is your keyed table
A:0!A;
.Q.dpft[`:.;.z.D;`sym;`A]

When you want to work with the table, simply xkey or ! it after loading it. This does not have the desired effect (i.e. all rows for all partitions keyed), but natively q does not support this except as in Felix's solution, which is the best for small tables. Keep in mind though that writing static binary files to disk will require them to be completely loaded back into memory before usage.

Nav

unread,
May 13, 2009, 8:03:25 AM5/13/09
to Kdb+ Personal Developers

Hi,

I am currenlty using Felix's solution and storing files ( one file for
each symbol ). Some of the symbol names have special characters
including '#' and '$'. While storing data for these symbols, using set
kdb+ is throwing an error. How do I escape the special characters .

For instance, if Nav# is a symbol, I do this, `:/path/Nav# set trade.
For this, kdb+ throws an error.

Please advice.

Regards,
Nav

Simon Garland

unread,
May 13, 2009, 8:46:26 AM5/13/09
to personal...@googlegroups.com

On 13.05.2009, at 14:03, Nav wrote:

> I am currently using Felix's solution and storing files ( one file for


> each symbol ). Some of the symbol names have special characters
> including '#' and '$'. While storing data for these symbols, using set
> kdb+ is throwing an error. How do I escape the special characters .
>
> For instance, if Nav# is a symbol, I do this, `:/path/Nav# set trade.
> For this, kdb+ throws an error.

the column names have to be valid q variable names, so you can't use
special characters
first letter in a-zA-Z, thereafter a-zA-Z0-9 and if you must "_"

avoid names in .Q.res (res <-> reserved) as well - calling a column
"select" will not end well


Reply all
Reply to author
Forward
0 new messages