Search code examples
windowsperlberkeley-db

How do I see how many keys are in a Berkeley DB (Perl)?


I simply need to find out how many elements I have in this hash, and I'm looking at the docs but the only thing that might give me this is db_stat, and there's a TODO under it.

http://search.cpan.org/dist/BerkeleyDB/BerkeleyDB.pod#Using_db_stat

So other than creating a cursor and parsing through the entire thing, how can I see how many keys are in the hash?


Solution

  • Seem to have found the answer here:

    http://download.oracle.com/docs/cd/E17076_02/html/api_reference/C/dbstat.html

    Names many different variables set when db_stat is called, including the one I was looking for, 'hash_ndata', which gives the number of key-value pairs.