dsave¶
Write global tables to disk as splayed, enumerated, indexed KDB-X tables
x dsave y dsave[x;y]
Where
xis the save path as a file symbol atom or vectoryis one or more table names as a symbol atom or vector
saves the tables and returns the list of table names.
The first column of each table saved has the parted attribute applied to it, so its values must occur in contiguous runs, for example after sorting with xasc. Otherwise, dsave signals a u-fail error. If the save path is a list, the first item is the HDB root (where the sym file, if any, will be stored), while the remaining items are a path within the HDB (e.g. a partition).
Roughly the same functionality as the combination of .Q.en and set or .Q.dpft, but in a simpler form.
q)t:flip`sym`price`size!100?'(-10?`3;1.0;10)
q)q:flip`sym`bid`ask`bsize`asize!900?'(distinct t`sym;1.0;1.0;10;10)
q)meta t
c | t f a
-----| -----
sym | s
price| f
size | j
q)meta q
c | t f a
-----| -----
sym | s
bid | f
ask | f
bsize| j
asize| j
q)`:/tmp/db1 dsave `sym xasc/:`t`q
`t`q
q)\l /tmp/db1
q)meta t
c | t f a
-----| -----
sym | s p
price| f
size | j
q)meta q
c | t f a
-----| -----
sym | s p
bid | f
ask | f
bsize| j
asize| j
In the next example, the left argument is a list, of which the second item is a partition name.
q)t:flip`sym`price`size!100?'(-10?`3;1.0;10)
q)q:flip`sym`bid`ask`bsize`asize!900?'(distinct t`sym;1.0;1.0;10;10)
q)`:/tmp/db2`2015.01.01 dsave `sym xasc/:`t`q
`t`q
q)\l /tmp/db2
q)meta t
c | t f a
-----| -----
date | d
sym | s p
price| f
size | j
q)meta q
c | t f a
-----| -----
date | d
sym | s p
bid | f
ask | f
bsize| j
asize| j