genecutl has asked for the wisdom of the Perl Monks concerning the following question:
The code was working quite nicely until I started working with very large data sets that caused my machine to run out of memory. To get around this problem, I'm trying to use a disk-based tied data structure with MLDBM. Unfortunately, I can't get it to work. Here is some simplified code:$data[1]->{'477'}->[5] = [ 'value', 'value', 0 , undef, 5, 'value' ];
Unfortunately, that assignment at the end doesn't take, and $data[$id] remains empty. I've tried things like this:use MLDBM qw(DB_File Storable); # ... stuff .... foreach $gid (@group_ids) { my %temp_hash; unlink "$DBFilePath/$$.$gid" if -e "$DBFilePath/$$.$gid"; tie %temp_hash, 'MLDBM', "$DBFilePath/$$.$gid", O_RDWR|O_CREAT, 06 +40 or die "Can't tie temp_array to $DBFilePath/$$.$gid: $!"; $data[$gid] = \%temp_hash; foreach $sample_id (@{$groups[$gid]}) { foreach $element_num ( 0 .. $element_count ) { $element = []; # ... do a bunch of stuff here ... $data[$gid]->{$sample_id}->[$element_num] = $element; } } }
But that still doesn't work. The only way I've found to add anything to $data[$id] is to assign an array ref in its entirety:$tmp = $data[$gid]->{$sample_id}; $tmp->[$element_num] = $element;
That is obviously not a workable solution, since I need to add elements one by one to get around the memory issues. Am I asking for too much or am I just doing this wrong? Thanks!$tmp = $data[$gid]; $tmp=>{$sample_id} = [ $element1, $element2, ... ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help with complex tied data structure
by perrin (Chancellor) on Nov 20, 2003 at 22:22 UTC | |
by genecutl (Beadle) on Nov 20, 2003 at 23:03 UTC | |
by perrin (Chancellor) on Nov 20, 2003 at 23:19 UTC | |
|
Re: Need help with complex tied data structure
by Abigail-II (Bishop) on Nov 20, 2003 at 23:04 UTC | |
by genecutl (Beadle) on Nov 20, 2003 at 23:28 UTC | |
by Abigail-II (Bishop) on Nov 20, 2003 at 23:34 UTC | |
by genecutl (Beadle) on Nov 21, 2003 at 00:31 UTC |