NAME
DiaColloDB::PDL::MM - DiaColloDB utilities: (temporary) mmaped PDLs
SYNOPSIS
##========================================================================
## PRELIMINARIES
use DiaColloDB::PDL::MM;
##========================================================================
## Constructors etc.
$mmpdl = CLASS->new($file?, $type?, @dims, \%opts?);
$mmpdl = CLASS->mmtemp($file?, $type?, @dims, \%opts?);
$bool = CLASS->unlink(@basenames);
undef = $obj->DESTROY();
##========================================================================
## Accessors
$file = $mmdpl->file();
$istmp = $mmdpl->temp();
$pdl = $mmpdl->_pdl();
DESCRIPTION
DiaColloDB::PDL::MM provides a simple object-oriented wrapper for (temporary) PDLs using mmap() via PDL::IO::FastRaw. This is mostly useful to ensure that the memory used by large intermediate piddles is freed when the objects are destroyed, since mmap() bypasses perl's internal memory management.
Globals & Constants
- Variable: @ISA
-
DiaColloDB::PDL::MM inherits from PDL.
- Variable: %MMTMP
-
Psuedo-set of all tempfiles created, used by END block.
- Variable: $LOG_DEFAULT
-
Default log-level for debugging (default=undef: off).
Constructors etc.
- new
-
$mmpdl = CLASS->new($file?, $type?, @dims, \%opts?); $mmpdl = $pdl->mmzeroes($file?, $type?, \%opts?);
Creates and returns a new mmap()ed PDL and returns the result as a blessed HASH-ref conforming to PDL inheritance conventions. %opts, %$mmpdl:
( file => $template, ##-- file basename or File::Temp template; default='pdlXXXX' suffix => $suffix, ##-- File::Temp::tempfile() suffix (default='.pdl') log => $level, ##-- logging verbosity (default=$LOG_DEFAULT) temp => $bool, ##-- delete on END (default: $file =~ /X{4}/) PDL => $pdl, ##-- guts: real underlying mmap()ed piddle (must be key 'PDL' for PDL inheritance to work) )
- mmtemp
-
$mmpdl = CLASS->mmtemp($file?, $type?, @dims, \%opts?);
like new(), but always sets
$opts->{temp}=1
. - unlink
-
$bool = CLASS->unlink(@basenames); $bool = $mmpdl->unlink();
Unlinks file(s) generated by
mmzeroes($basename)
.$basename
defaults to$mmpdl->{file}
if called as an object method. - DESTROY
-
undef = $obj->DESTROY()
Destructor implicitly calls unlink(); must also handle "pure" piddles created e.g. by $mmpdl->xvals().
Accessors
- file
-
$file = $mmdpl->file();
Returns mmap()ed filename.
- temp
-
$istmp = $mmdpl->temp();
Returns true iff $mmpdl is marked as a temporary.
- _pdl
-
$pdl = $mmpdl->_pdl();
Returns "real" underlying PDL.
AUTHOR
Bryan Jurish <moocow@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2015-2020 by Bryan Jurish
This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.
SEE ALSO
PDL(3pm), PDL::IO::FastRaw(3pm), DiaColloDB(3pm), perl(1), ...