A fix to the error in my workaround is to changed to this definition: (there
was a shape error)
getsize_jmf_ =: {.@:(1 {::"1 ] (] {~ (< @:[) i.~ {."1@:]) 1 8 {"1
}.@:showmap_jmf_@:(''"_))
regarding the boxed mapped arrays being destroyed on allocation error though,
is that something that can be fixed?
from here, http://wiki.jsoftware.com/help/release/mbx.htm
mapped boxed arrays survive allocation errors in amend. They also survive
syntax/domain errors before the assign.
----- Original Message -----
From: 'Pascal Jasmin' via General <[email protected]>
To: General forum <[email protected]>
Cc:
Sent: Monday, December 8, 2014 3:42 PM
Subject: [Jgeneral] bug in mapped boxed arrays
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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm