Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Memory Efficient Alternatives to Hash of Array

by tilly (Archbishop)
on Dec 27, 2008 at 06:41 UTC ( #732753=note: print w/replies, xml ) Need Help??


in reply to Memory Efficient Alternatives to Hash of Array

You are trying to process 4-5 GB of data in Perl, which probably can only address 2-3 GB of data internally. That won't work. Which means that you want to keep data on disk. When processing data on disk you should always think about whether sorting helps. In this case sorting gives you all of the error rates for a given tag right after each other. So use the Unix sort utility or Sort::External to sort your data then process your file in one pass. That pass could have a snippet like this in it:
my $last_key = ""; my @last_error_rates; while (my $line = <DATA>) { my ($key, $error_rate) = split /\s+/, $line; if ($key ne $last_key) { # We just crossed a key boundary, do processing. process_block($last_key, @last_error_rates) if $last_key; $last_key = $key; @last_error_rates = (); } push @last_error_rates, $error_rate } # Don't forget the final block! process_block($last_key, @last_error_rates);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://732753]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2020-04-09 01:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The most amusing oxymoron is:
















    Results (46 votes). Check out past polls.

    Notices?