Re: BerkeleyDB

2006-02-13 Thread Tom Allison

Hans Meier (John Doe) wrote:

Tom Allison am Dienstag, 14. Februar 2006 02.28:


I was trying out some jobs with the Berkeley DB and decided to move up from
DB_File to BerkeleyDB.  I don't need a lot of features, just speed.

But I keep running into a "dumb" error that doesn't make any sense to me.
untie attempted while 1 inner references still exist at ./dbm_test.pl line
31.

According to docs and the old DB_File method...  I shouldn't get this
warning. I can't find anything that's not working with the code, but I
don't like errors just the same...

Any ideas?

#!/usr/bin/perl

use strict;
use warnings;
use BerkeleyDB;
use Digest::MD5 qw[md5_hex];
use Time::HiRes qw[tv_interval gettimeofday];
use Data::Dumper;

my %hash;
my $db = tie %hash, "BerkeleyDB::Hash",
  -Filename => 'authentication.db',
  -Flags=> DB_CREATE
  or die "yer fucked!\n";

for(my $x = 0; $x<10_000; $x++) {
  my $y = int(1 + rand(10_000_000));
  my $t = [gettimeofday];
  if(exists $hash{$y}) {
my $value = $hash{$y};
print "get ";
  } else {
my $value = md5_hex(@$t);
$hash{$y} = $value;
print "put ";
  }
  print tv_interval($t, [gettimeofday]),"\n";
}

untie %hash;



The one inner reference mentioned in the error is hold in $db :-)

What you can do:

a) Since you don't use $dh, just say

tie %hash, "BerkeleyDB::Hash";

you can always

my $db=tied(%hash);

b) put before untie %hash a

undef $db;

hth,
Hans



That simple!
Thanks!

I'm keeping the db reference so I can db_sync().
It seems to get into these lags where 6-12 records take >0.2 seconds to process.
Much longer than the typical...

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: BerkeleyDB

2006-02-13 Thread Hans Meier (John Doe)
Tom Allison am Dienstag, 14. Februar 2006 02.28:
> I was trying out some jobs with the Berkeley DB and decided to move up from
> DB_File to BerkeleyDB.  I don't need a lot of features, just speed.
>
> But I keep running into a "dumb" error that doesn't make any sense to me.
> untie attempted while 1 inner references still exist at ./dbm_test.pl line
> 31.
>
> According to docs and the old DB_File method...  I shouldn't get this
> warning. I can't find anything that's not working with the code, but I
> don't like errors just the same...
>
> Any ideas?
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
> use BerkeleyDB;
> use Digest::MD5 qw[md5_hex];
> use Time::HiRes qw[tv_interval gettimeofday];
> use Data::Dumper;
>
> my %hash;
> my $db = tie %hash, "BerkeleyDB::Hash",
>-Filename => 'authentication.db',
>-Flags=> DB_CREATE
>or die "yer fucked!\n";
>
> for(my $x = 0; $x<10_000; $x++) {
>my $y = int(1 + rand(10_000_000));
>my $t = [gettimeofday];
>if(exists $hash{$y}) {
>  my $value = $hash{$y};
>  print "get ";
>} else {
>  my $value = md5_hex(@$t);
>  $hash{$y} = $value;
>  print "put ";
>}
>print tv_interval($t, [gettimeofday]),"\n";
> }
>
> untie %hash;

The one inner reference mentioned in the error is hold in $db :-)

What you can do:

a) Since you don't use $dh, just say

tie %hash, "BerkeleyDB::Hash";

you can always

my $db=tied(%hash);

b) put before untie %hash a

undef $db;

hth,
Hans

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: BerkeleyDB

2001-04-22 Thread King, Jason

Jeffrey wrote ..

>new to the list and will likely see plenty that will help; but here's
>something specific to my explorations now.
>
>I'm doing some development and testing for production and have pretty
>well decided Perl-Perl/Tk and Berkeley DB will best serve my purpose.
>This after exploring the DBI with DB2 (DBI is fine, but DB2 is overkill
>for many reasons), and other 'SQL'-like DBs/interfaces. Here's the
>difficulty: finding Perl-specific info/guide (ie more than Perl's
>BerkeleyDB mod papers) to help me under- stand the techniques and
>functions I'll need to write (or crib from CPAN) for the several kinds
>of record updates I need to perform. Sleepycat docs repeatedly mention
>BDB's ability to handle 'insert, delete, update recs' but I can't find
>a darn thing that explicitly and broadly says anything about updating
>recs, which is my main concern. The Perl/DBI book touches on using
>Berkeley DB to a minor degree but with using DB_File for 1.85. It's a
>start but I'm running out of places to look to find more info. Anybody
>know of anything? I've been through all the links at the Perl sites I
>know about. I'd be grateful for any steerage. Thank


I think you're underestimating your abilities :)

I mean this in the nicest way - I wouldn't consider what you're talking
about to be a beginner's topic .. so you might not find that you'll receive
the best answer here (I certainly have no idea)

it seems like a perfect question for the comp.lang.perl.misc newsgroup ..
I'm sure you'll find people there who can steer you correctly

take a look at the sorts of topics that this list deals with .. it's much
more basic than how to deal with the Perl/BDB interface

-- 
  jason king

  In Spearfish, South Dakota, if three or more Indians are walking down
  the street together, they can be considered a war party and fired
  upon. - http://dumblaws.com/