update splayed table on disk

Hi All,
I am trying to do an on disk update for a splayed table something on the lines of 

https://code.kx.com/q/ref/lists/#amend

But it keeps on throwing me an 'open error while I use the filehandle for update.

Ex:

@[`:tbl;enlist 2;:;dict]

where dict is the new row.

Can anyone help me in this?

Hey,

To update on disk you can simply upsert to the filepath for example:

q)`:hdb/tab1/ set tab1

`:hdb/tab1/

q)tab1

price size char


1     4    A

2     5    B

3     6    C

q)\l hdb

q)tab1

price size char


1     4    A

2     5    B

3     6    C

q)`:tab1 upsert enlist dict

`:tab1

q)\l tab1

`tab1

q)tab1

price size char


1     4    A

2     5    B

3     6    C

4     5    D

However if you want to update a specific row on disk you could update each column individually with something like: 

@'[sv':tab1,'key dict;2;:;value dict]

I wouldn’t really recommed this method as iterating over columns to update them is a particularly bad idea as there is a risk involved in the operation in that it can cause significant issues were it to fail (i.e. a possible corruption of your partition). 

Hope this helps!

Seán

On-disk tables are append-only. In order to update an on-disk dataset, you can only read it into memory, amend it, and re-splay the resultant data back to disk.