develooper Front page | perl.moose | Postings from June 2015

Storage needs

From:
Demian Riccardi
Date:
June 23, 2015 17:23
Subject:
Storage needs
Message ID:
CACaGo3OqW19N7M9okMn6A5MJu_u0-sq2g9yExjMKTOd1SqQj+w@mail.gmail.com
Hello,

I'm trying to add storage to my library (HackaMol), and I think I'm close
to getting it to work. My library depends on a non-moose class
(Math::Vector::Real), which I was able to get serialized:

http://stackoverflow.com/questions/6101800/store-a-moose-object-that-has-a-pdl-as-an-attribute/31005543#31005543

Any attributes that are Math::Vector:Real objects serialize, unless they
are an additional level below in the object, e.g.
(ArrayRef[Math::Vector::Real])  In the script below (along with runtime
errors) I can store and load the HackaMol::Atom if I remove the coords
attribute.  The coords attribute has Array traits for storing large numbers
of atomic configurations, a characteristic that is central to HackaMol.

you can see what I added to get the storage to sorta work here:
https://github.com/demianriccardi/HackaMol/commit/384ceb9ce3749d6342fc54df292182442764d180

you'll notice the strange add_custom_type_handler( '[Math::Vector::Real]'
which was a step I was hoping would bring me closer.  Is there a way to get
this to work?

Thanks!

Demian

use Modern::Perl;

use Math::Vector::Real;

use HackaMol;


my $atom = HackaMol::Atom->new(Z=>1, coords=>[V(1,1,2)]);

print $atom->dump;


$atom->store('atom.json');


my $atom_again = HackaMol::Atom->load('atom.json');

print $atom_again->dump;



Object ({1, 1, 2}) does not have a &pack method, cannot collapse at
/Users/riccade/perl5/perlbrew/perls/p5.20.1t/lib/site_perl/5.20.1/MooseX/Storage/Engine.pm
line 209.

MooseX::Storage::Engine::__ANON__(Math::Vector::Real=ARRAY(0x7f93a8805468),
HASH(0x7f93a8f90700)) called at
/Users/riccade/perl5/perlbrew/perls/p5.20.1t/lib/site_perl/5.20.1/MooseX/Storage/Engine.pm
line 254

MooseX::Storage::Engine::__ANON__(ARRAY(0x7f93a882d478),
HASH(0x7f93a8f90700)) called at
/Users/riccade/perl5/perlbrew/perls/p5.20.1t/lib/site_perl/5.20.1/MooseX/Storage/Engine.pm
line 92

MooseX::Storage::Engine::collapse_attribute_value(MooseX::Storage::Engine=HASH(0x7f93ac54b138),
Moose::Meta::Class::__ANON__::SERIAL::2=HASH(0x7f93ab1ec208),
HASH(0x7f93a8f90700)) called at
/Users/riccade/perl5/perlbrew/perls/p5.20.1t/lib/site_perl/5.20.1/MooseX/Storage/Engine.pm
line 62

MooseX::Storage::Engine::collapse_attribute(MooseX::Storage::Engine=HASH(0x7f93ac54b138),
Moose::Meta::Class::__ANON__::SERIAL::2=HASH(0x7f93ab1ec208),
HASH(0x7f93a8f90700)) called at
/Users/riccade/perl5/perlbrew/perls/p5.20.1t/lib/site_perl/5.20.1/MooseX/Storage/Engine.pm
line 145

MooseX::Storage::Engine::map_attributes(MooseX::Storage::Engine=HASH(0x7f93ac54b138),
"collapse_attribute", HASH(0x7f93a8f90700)) called at
/Users/riccade/perl5/perlbrew/perls/p5.20.1t/lib/site_perl/5.20.1/MooseX/Storage/Engine.pm
line 39

MooseX::Storage::Engine::collapse_object(MooseX::Storage::Engine=HASH(0x7f93ac54b138))
called at
/Users/riccade/perl5/perlbrew/perls/p5.20.1t/lib/site_perl/5.20.1/MooseX/Storage/Basic.pm
line 14

MooseX::Storage::Basic::pack(HackaMol::Atom=HASH(0x7f93a882d550)) called at
/Users/riccade/perl5/perlbrew/perls/p5.20.1t/lib/site_perl/5.20.1/MooseX/Storage/Format/JSON.pm
line 25

MooseX::Storage::Format::JSON::freeze(HackaMol::Atom=HASH(0x7f93a882d550))
called at
/Users/riccade/perl5/perlbrew/perls/p5.20.1t/lib/site_perl/5.20.1/MooseX/Storage/IO/File.pm
line 20

MooseX::Storage::IO::File::store(HackaMol::Atom=HASH(0x7f93a882d550),
"atom.json") called at atom.pl line 6



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About