Basically I read in the contents of a very large file as an array and then bucket-hash it using the Data::Bucket index() method:
However, the call to index led to an out of memory error and I am considering various approaches to fixing this issue:=head2 index Usage : my $bucket = Data::Bucket->index(data => strings, %other) +; Purpose : Build a data structure with @strings partitioned into buc +kets Returns : An object. Argument : A list of data compatible with the compute_index() functi +on =cut sub index { my ($class, %parm) = @_; exists $parm{data} or die "Data must be passed for indexing" ; ref $parm{data} eq 'ARRAY' or die 'You must pass an array ref'; my $self = bless (\%parm, ref ($class) || $class); $self->bucket_hash; return $self; } =head2 bucket_hash Usage : Called internally by index() Purpose : Partition $self->{data} by repeated calls to $self->compute_record_index Returns : Nothing Argument : None. =cut sub bucket_hash { my ($self) = @_; for my $data (@{$self->{data}}) { my $index = $self->compute_record_index($data); my @index = ref $index eq 'ARRAY' ? @$index : ($index) ; for (@index) { push @{ $self->{bucket}{$_} } , $data ; } } return $self; }
| I have beheld the tarball of 22.1 on ftp.gnu.org with my own eyes. How can you say that there is no God in the Church of Emacs? -- David Kastrup |
|
| Enforce strict model-view separation in template engines via HTML::Seamstress | The car is in the cdr, not the cdr in the car |
In reply to hashref population yields out of memory error by metaperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |