Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Problem serializing Net::Patricia object

by Anonymous Monk
on Aug 31, 2012 at 17:36 UTC ( #991053=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear all,

I've been using Net::IPTtrie for handling IP address spaces. I am now trying to move to Net::Patricia because it's much faster, but there's something that I can't figure out. I need to store the tree structure so that I don't have to constantly rebuild it. But using Storable's nfreeze/thaw gives me a seg fault:

use Net::Patricia; use Storable qw(nfreeze thaw); my $pt = new Net::Patricia(AF_INET6); $pt->add_string(...) ... etc and then: my $frozen = nfreeze($pt); undef $pt; $pt = thaw($frozen);

(Boom! segfault here)

Why is this happening, and what other options do I have to store the tree structure?

Thanks in advance for your help.

cv

Comment on Problem serializing Net::Patricia object
Download Code
Re: Problem serializing Net::Patricia object
by cvicente (Initiate) on Aug 31, 2012 at 18:44 UTC

    I guess you can't:

    http://www.perlmonks.org/?node_id=352519

    Any other options?

Re: Problem serializing Net::Patricia object
by philiprbrenan (Monk) on Aug 31, 2012 at 21:32 UTC
    p>Please do three things. First: add

    use warnings FATAL => qw(all); use strict; use Data::Dump qw(dump pp);

    Second: eliminate the undef $pt line, try restoring to a different variable using my $pt2 for example. Third: could you supply an example of a minimal set of input data that causes a SEGV on your system? The easiest way would be via dump(). Thanks

Re: Problem serializing Net::Patricia object
by mbethke (Hermit) on Sep 01, 2012 at 20:51 UTC

    A couple of years ago I created Net::CIDR::Lookup that does pretty much the same thing. Either it predated the other modules or I was too thick to find them at this time. While as a pure-Perl module it certainly can't compete with Net::Patricia's XS code, a quick look at Net::IPTrie tells me it would likely be a tad faster than the latter and certainly use less memory. Maybe that will do for now, at least for IPv4. The v6 version uses Bit::Vector which is XS itself though I seem to remember it had some serialization hook support.

    I just uploaded V0.5 to CPAN that should be some 10-20% faster than the previous version on searches, BTW.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://991053]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2015-07-05 19:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls