mkirank has asked for the wisdom of the Perl Monks concerning the following question:
use Heap; my %servers; my $servername; my ($epoch,$field1,$field2,$field3,$field4); my $tmparref; my $heap = 'heap'; open (LOG,"$file") or die "cannot open $!"; while (<LOG>) { ($servername,$epoch,$field1,$field2,$field3,$field4) = get_details +($_); ## Create a reference to a array $tmparref = [$field1,$field2,$field3,$field4] if (exists($servers{$servername}{$epoch})) { push@{$servers{$servername}{$epoch}},$tmparref; } else { $servers{$servername}{$epoch}=[$tmparref]; ## creat a object of heap dynamically at runtime ${$heap$servers{$servername}} = Heap->new; } ## for each server add the epoch time to a heap object ${$heap$servers{$servername}}->add( $elem ); } close(LOG); my ($process_server,$minday,$maxday); foreach (keys (%servers) { $process_server = $servers{$_}; ## Sort on the keys (epoch) get the minimum and maximum epoch for that server for (then for each day) { ### Here again we need to create a hash with the summarized +data ### summarize the data } print the record for top x (a constant) }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Design Approach (Processing Huge Hash)
by merlyn (Sage) on Aug 26, 2004 at 13:13 UTC | |
by mkirank (Chaplain) on Aug 27, 2004 at 05:07 UTC | |
|
Re: Design Approach (Processing Huge Hash)
by BrowserUk (Patriarch) on Aug 26, 2004 at 14:52 UTC | |
|
Re: Design Approach (Processing Huge Hash)
by rsteinke (Scribe) on Aug 26, 2004 at 15:00 UTC |