How "deep" is MLDBM ?

Discussion in 'Perl Misc' started by timnels@gmail.com, Oct 11, 2005.

  1. Guest

    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);
     
    , Oct 11, 2005
    #1
    1. Advertising

  2. wrote in news:1129035880.392440.310710
    @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
    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, Oct 11, 2005
    #2
    1. Advertising

  3. Guest

    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?
     
    , Oct 11, 2005
    #3
  4. wrote in news:1129042722.833216.11800
    @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
    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, Oct 11, 2005
    #4
  5. Guest

    wrote:
    > 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

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Oct 11, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Mott

    MLDBM

    Jeff Mott, Aug 12, 2003, in forum: Perl Misc
    Replies:
    4
    Views:
    110
    simonis
    Aug 13, 2003
  2. Brian Greenfield

    HoH and MLDBM problems

    Brian Greenfield, Aug 26, 2003, in forum: Perl Misc
    Replies:
    4
    Views:
    169
    Bob Walton
    Sep 17, 2003
  3. JS

    mldbm error

    JS, Oct 31, 2003, in forum: Perl Misc
    Replies:
    3
    Views:
    238
    Ben Morrow
    Oct 31, 2003
  4. Mark Ng

    MLDBM error

    Mark Ng, Nov 30, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    111
    Mark Ng
    Nov 30, 2004
  5. Replies:
    0
    Views:
    149
Loading...

Share This Page