An allocation size error in a non-boxed mapped file correctly preserves the old 
contents of the name, but on boxed mapped arrays, the contents of the variable 
are destroyed.

from the lab, 


jdatafn=: jpath '~temp\jdata.jmf' 
createjmf_jmf_ jdatafn;1000 
map_jmf_ 'jdata';jdatafn

jdata =:  i. 2 5 
jdata 
0 1 2 3 4 
5 6 7 8 9

jdata =: jdata ,  i. 200 5 
|allocation error 
|   jdata    =:jdata,i.200 5 
jdata 
0 1 2 3 4 
5 6 7 8 9
NB. above is correct, but

 
jdata =:  <"1 i. 2 5 
jdata 
┌─────────┬─────────┐ 
│0 1 2 3 4│5 6 7 8 9│ 
└─────────┴─────────┘ 

jdata    =:jdata, <"1 i.200 5 
|allocation error 
|   jdata    =:jdata,<"1 i.200 5 
jdata NB. empty

The file on disk is also "destroyed" in that a remapping will also be empty.  
This means that you can't use an allocation error as a trigger to resize

I was already thinking of a workaround that involves checking the size of an 
append and resizing if there is a danger of an allocation error 

 some utilities:

getsize_jmf_ =:(1 {::"1 ] (] {~ (< @:[) i.~ {."1@:])  1 8 {"1  
}.@:showmap_jmf_@:(''"_)) NB. y is mappedfilename 

resize_jmf_ =: 4 : 0 NB. x is newsize (< 5 is multiplier of old size. else is 
newsize) y is mappedfilename 
'vname fmapname' =. y 
if. 5 > x do. ns =. 8096 ([ *  >.@%~) x * getsize fmapname else. ns =. x end. 
smoutput ns 
unmap_jmf_ vname;ns 
map_jmf_ vname;fmapname 
)

but calling resize causes an error that breaks all future jmf operations until 
restart of J (in J6 32 bit anyway), and not sure why.

1.2 resize_jmf_ 'jdata_base_';jdatafn 
8096 
|domain error: SetFilePointerR 
|       SetFilePointerR fh;totsize;NULLPTR;FILE_BEGIN
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to