How "deep" is MLDBM ?

T

timnels

I am trying to use MLDBM to store a large number of hash entries for
which each hash entry is an hash of an array. It seems to me the MLDBM
can handle this structure, unless I try and modify a hash entry I have
added. It seems to be "insert only". If I am not missing something,
what are the alternatives?

The code (below) leaves off "item3" unless I don't use MLDBM. The
output:
$VAR1 = {
'hashkey' => {
'hash' => [
'item1',
'item2'
]
}
};

For:

use MLDBM;
use Data::Dumper;
use Fcntl;
use strict;

my %hash;

#
# Comment out this line and item3 is added.
#
tie(%hash, 'MLDBM', 'tmp', O_TRUNC|O_RDWR|O_CREAT, 0666);

$hash{hashkey} = { hash => [ "item1","item2" ] };

push @{$hash{hashkey}->{hash}}, "item3";

Data::Dumper->Indent(1);
print Dumper(\%hash);
 
A

A. Sinan Unur

(e-mail address removed) wrote in @o13g2000cwo.googlegroups.com:
I am trying to use MLDBM to store a large number of hash entries for
which each hash entry is an hash of an array. It seems to me the MLDBM
can handle this structure, unless I try and modify a hash entry I have
added. It seems to be "insert only". If I am not missing something,

Have you tried reading the documentation?

http://search.cpan.org/~chamas/MLDBM-2.01/lib/MLDBM.pm#BUGS

Sinan
 
T

timnels

Thanks. I don't know why I didn't see that the first time. I am still
worried I am wasting my time, since I think once I do:

tie(%hash, 'MLDBM', 'tmp', O_TRUNC|O_RDWR|O_CREAT, 0666);
$hash{hashkey} = { hash => [ "item1","item2" ] };
my $tmp = $hash{hashkey};
push @{$tmp->{hash}}, "item3";
$hash{hashkey} = $tmp;

....if the _single_ entry in the hash has subhashes with 100,000 +
entries I am going to get an out of memory error on $tmp, yes?
DBM::Deep seems to work but it's way to slow. Any other module you
think might do the trick?
 
A

A. Sinan Unur

(e-mail address removed) wrote in @g14g2000cwa.googlegroups.com:

[ Please quote an appropriate amount of context when replying.
Please read the posting guidelines for this group.
]
Thanks. I don't know why I didn't see that the first time. I am still
worried I am wasting my time, since I think once I do:

tie(%hash, 'MLDBM', 'tmp', O_TRUNC|O_RDWR|O_CREAT, 0666);
$hash{hashkey} = { hash => [ "item1","item2" ] };
my $tmp = $hash{hashkey};
push @{$tmp->{hash}}, "item3";
$hash{hashkey} = $tmp;

...if the _single_ entry in the hash has subhashes with 100,000 +
entries I am going to get an out of memory error on $tmp, yes?

I don't know why that would be the case. If you hit one a built in
limit, it will probably be much smaller than that.

I do not know what your real problem is, what you are trying to achieve,
but SQLite might help.

Sinan
 
X

xhoster

Thanks. I don't know why I didn't see that the first time. I am still
worried I am wasting my time, since I think once I do:

tie(%hash, 'MLDBM', 'tmp', O_TRUNC|O_RDWR|O_CREAT, 0666);
$hash{hashkey} = { hash => [ "item1","item2" ] };
my $tmp = $hash{hashkey};
push @{$tmp->{hash}}, "item3";
$hash{hashkey} = $tmp;

...if the _single_ entry in the hash has subhashes with 100,000 +
entries I am going to get an out of memory error on $tmp, yes?

Maybe. But why have a top-level hash with a single entry?
DBM::Deep seems to work but it's way to slow. Any other module you
think might do the trick?

That would depend on what the trick is that you are trying to do.

Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top