Q Language - Maintenance Functions
.Q.en is a dyadic function which help in splaying a table by enumerating a symbol column. It is especially useful when we are dealing with historical db (splayed, partition tables etc.). −
where directory is the home directory of the historical database where sym file is located and table is the table to be enumerated.
Manual enumeration of tables is not required to save them as splayed tables, as this will be done by −
The .Q.dpft function helps in creating partitioned and segmented tables. It is advanced form of .Q.en, as it not only splays the table but also creates a partition table.
There are four arguments used in .Q.dpft −
symbolic file handle of the database where we want to create a partition,
q data value with which we are going to partition the table,
name of the field with which parted (`p#) attribute is going to be applied (usually `sym), and
the table name.
Let’s take an example to see how it works −
q)tab:(sym:5?`msft`hsbc`samsung`ibm;time:5?(09:30:30);price:5?30.25) q).Q.dpft[`:c:/q/;2014.08.24;`sym;`tab] `tab q)delete tab from ` 'type q)delete tab from `/ 'type q)delete tab from . 'type q)delete tab from `. `. q)tab 'tab
We have deleted the table tab from the memory. Let us now load it from the db
q)\l c:/q/2014.08.24/ q)\a ,`tab q)tab sym time price ------------------------------- hsbc 07:38:13 15.64201 hsbc 07:21:05 5.387037 msft 06:16:58 11.88076 msft 08:09:26 12.30159 samsung 04:57:56 15.60838
.Q.chk is a monadic function whose single parameter is the symbolic file handle of the root directory. It creates empty tables in a partition, wherever necessary, by examining each partition subdirectories in the root.
where directory is the home directory of the historical database.