List Info

Thread: "ocaml_beginners"::[] Bigarray.Genarray.map_file with offset




"ocaml_beginners"::[] Bigarray.Genarray.map_file with offset
user name
2006-07-18 13:47:28
Can anybody suggest a convenient way of using Bigarray's
map_file feature with a file offset (that is, mapping a
chunk of the file not beginning at the first byte)?

Thanks,
Mark <><



------------------------ Yahoo! Groups Sponsor
--------------------~--> 
See what's inside the new Yahoo! Groups email.
http://us.click.yahoo.com/2pRQfA/bOaOAA/yQLSAA/saFolB/TM

------------------------------------------------------------
--------~-> 

Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http:/
/groups.yahoo.com/group/ocaml_beginners/

<*> To unsubscribe from this group, send an email to:
    ocaml_beginners-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 



"ocaml_beginners"::[] Bigarray.Genarray.map_file with offset
user name
2006-07-18 20:42:44
Mark White wrote:
> Can anybody suggest a convenient way of using
Bigarray's
> map_file feature with a file offset (that is, mapping a
> chunk of the file not beginning at the first byte)?

Define "convenient"... ;)

It is sort of surprising that the interface was not
originally 
designed with this capability in mind, since it is a natural
aspect of 
"file mapping" in general, and the underlying OS
facilities that 
provide file mapping "always" include this in
*their* interfaces...

In any case, it looks like "map_file" would need
to have a second 
version (e.g., "map_file_with_offset") that had
an extra parameter for 
the offset.  If there was a "labeled" version of
Bigarray, then this 
could just be an optional param defaulting to 0.

Then the offset would have to be factored into the various
file size 
vs array size computations and comparisons, and finally
passed on to 
the OS API calls (mmap itself for *nix, and MapViewOfFile
for Win32).

Of course, the obvious easy case is just
"ignoring" some number of 
initial elements in the Bigarray IFF it happens that
"offset" number 
of bytes is exactly some number of your Bigarray elements...
but this 
is fairly limited as solutions go.

Robert Roessler
robertrrftp.com
http://www.rftp.com


------------------------ Yahoo! Groups Sponsor
--------------------~--> 
Something is new at Yahoo! Groups.  Check out the enhanced
email design.
http://us.click.yahoo.com/SISQkA/gOaOAA/yQLSAA/saFolB/TM

------------------------------------------------------------
--------~-> 

Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http:/
/groups.yahoo.com/group/ocaml_beginners/

<*> To unsubscribe from this group, send an email to:
    ocaml_beginners-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 



"ocaml_beginners"::[] Bigarray.Genarray.map_file with offset
user name
2006-07-19 12:26:50
Robert Roessler writes:
> Mark White wrote:
> > Can anybody suggest a convenient way of using
Bigarray's
> > map_file feature with a file offset (that is,
mapping a
> > chunk of the file not beginning at the first
byte)?
> 
> Define "convenient"... ;)

Guess I probably meant "not having to re-write
Bigarray" 

> In any case, it looks like "map_file" would
need to have a second 
> version (e.g., "map_file_with_offset") that
had an extra parameter for 
> the offset.  If there was a "labeled"
version of Bigarray, then this 
> could just be an optional param defaulting to 0.
> 
> Then the offset would have to be factored into the
various file size 
> vs array size computations and comparisons, and finally
passed on to 
> the OS API calls (mmap itself for *nix, and
MapViewOfFile for Win32).

Hm, this doesn't look so bad, actually: half a dozen tiny
changes each each in mmap_unix.c and mmap_win32.c, plus
corresponding type updates to the OCaml side.  A small
module with just an updated map_file function could produce
data structures that play nicely with the rest of Bigarray.

Or I could just buy yet more RAM... 

> Of course, the obvious easy case is just
"ignoring" some number of 
> initial elements in the Bigarray IFF it happens that
"offset" number 
> of bytes is exactly some number of your Bigarray
elements... but this 
> is fairly limited as solutions go.

Indeed; and in my case I want to map multi-dimensional
Genarrays, which makes it pretty much a non-starter.

Thanks,
Mark <><



------------------------ Yahoo! Groups Sponsor
--------------------~--> 
Great things are happening at Yahoo! Groups.  See the new
email design.
http://us.click.yahoo.com/TISQkA/hOaOAA/yQLSAA/saFolB/TM

------------------------------------------------------------
--------~-> 

Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http:/
/groups.yahoo.com/group/ocaml_beginners/

<*> To unsubscribe from this group, send an email to:
    ocaml_beginners-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 



[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )