dsave
¶
Write global tables to disk as splayed, enumerated, indexed kdb+ tables.
x dsave y dsave[x;y]
Where
x
is the save path as a file symbol atom or vectory
is one or more table names as a symbol atom or vector
save the table/s and returns the list of table names. (Since V3.2 2014.05.07.)
The first column of each table saved has the parted attribute applied to it. 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)type each flip t
sym | 11
price| 9
size | 7
q)type each flip q
sym | 11
bid | 9
ask | 9
bsize| 7
asize| 7
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
q)type each flip t
sym | 20
price| 9
size | 7
q)type each flip q
sym | 20
bid | 9
ask | 9
bsize| 7
asize| 7
In the following, 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)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)type each flip t
sym | 11
price| 9
size | 7
q)type each flip q
sym | 11
bid | 9
ask | 9
bsize| 7
asize| 7
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