I just pushed to git the needed routine to allow
memory mapped files to be implemented via
File::Map.  In fact, if you install File::Map and
then create a sample data file you can try my
development script to see the new capability. :-)

Still to do, figure out a clean way to set the new
PDL type from $hdr->{Type}.  The test file I
created was from:

pdl> writeflex 'a_short_3_7.dat', sequence(ushort, 3, 7);

Here is the sample code listing along with the
log from the git commit.

Enjoy!
Chris

    Add set_state_and_add_deletedata_magic() to support File::Map

    Since File::Map works at the level of mapping a file into
    a perl scalar lvalue, I've implemented a routine that does
    the required state setting and addition of deletedata magic
    for the pdl.

    For reference, here is a simple sequence using map_file
    from File::Map to do the memory mapping for an existing
    PDL::IO::FlexRaw data file:

        use 5.10.1;

        use PDL;
        use PDL::IO::FlexRaw;
        use PDL::Core qw(:Internal);

        use File::Map qw(map_file);

        $hdr = PDL::IO::FlexRaw::_read_flexhdr('a_ushort_3_7.dat.hdr');
        $h = $hdr->[0];

        $amm = PDL->zeros( ushort );  # fix to use $h->{Type} instead
        $amm->setdims($h->{Dims});
        $ammdr = $amm->get_dataref;
        map_file ${$ammdr}, 'a_ushort_3_7.dat', '+<';   # must enable rw
        $amm->upd_data;
        $amm->set_state_and_add_deletedata_magic(length(${$ammdr}));

        $amm *= 3;
        say $amm;
        undef $amm;  # the file should be updated now

        $acheck = readflex 'a_ushort_3_7.dat';
        say $acheck; # should be the same as from $amm


On Wed, Mar 28, 2012 at 11:58 AM, Joel Berger <[email protected]> wrote:
> I have passes on:
>
> This is perl 5, version 14, subversion 2 (v5.14.2) built for i686-linux
> This is perl 5, version 14, subversion 0 (v5.14.0) built for x86_64-linux
>
> Looking good.
>
> Joel Berger
>
>
> On Wed, Mar 28, 2012 at 10:06 AM, David Mertens <[email protected]>
> wrote:
>>
>> Nearly all tests pass on my 64 bit Mac OSX Lion, which is a 64-bit POSIX
>> system. The tests that fail are the gd_oo_tests.t, but these failed before
>> the latest memory updates. Apparently I haven't been paying close attention.
>> I'll open that thread under a separate discussion.
>>
>> David
>>
>>
>> On Wed, Mar 28, 2012 at 9:40 AM, David Mertens <[email protected]>
>> wrote:
>>>
>>> All tests pass on my Ubuntu 32 bit system. I can check my Mac in a little
>>> bit.
>>>
>>> David
>>>
>>>
>>> On Wed, Mar 28, 2012 at 8:59 AM, Chris Marshall <[email protected]>
>>> wrote:
>>>>
>>>> Thanks, Rob.
>>>>
>>>> Any PDL users of 32bit or 64bit POSIX systems
>>>> willing to check this out?
>>>>
>>>> On Wed, Mar 28, 2012 at 4:21 AM, Sisyphus <[email protected]>
>>>> wrote:
>>>> >
>>>> > ----- Original Message ----- From: "Chris Marshall"
>>>> >
>>>> >
>>>> >> If you get a chance to try a test build with this git, I
>>>> >> would appreciate knowing---whether it worked or not.
>>>> >
>>>> >
>>>> > No problems here (on MS Windows) with any of my 32-bit or 64-bit
>>>> > builds of
>>>> > perl.
>>>> >
>>>> > So far, so good .... :-)
>>>> >
>>>> > Cheers,
>>>> > Rob
>>>> >
>>>>
>>>> _______________________________________________
>>>> Perldl mailing list
>>>> [email protected]
>>>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>>>
>>>
>>>
>>>
>>> --
>>>  "Debugging is twice as hard as writing the code in the first place.
>>>   Therefore, if you write the code as cleverly as possible, you are,
>>>   by definition, not smart enough to debug it." -- Brian Kernighan
>>>
>>
>>
>>
>> --
>>  "Debugging is twice as hard as writing the code in the first place.
>>   Therefore, if you write the code as cleverly as possible, you are,
>>   by definition, not smart enough to debug it." -- Brian Kernighan
>>
>>
>> _______________________________________________
>> Perldl mailing list
>> [email protected]
>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>>
>

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to