Skip to Main Content

Berkeley DB Family

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

secondary index key generation function, documentation error?

526209Aug 2 2006 — edited Aug 2 2006
Hi all,

I've been looking at documentation on secondary indexes here:

http://www.sleepycat.com/docs/ref/am/second.html

I noticed in the example code a reference to Dbt flag "DB_DBT_APPMALLOC", but it seems as though this flag does not exist. Looking at the Dbt reference page here:

http://www.sleepycat.com/docs/api_cxx/dbt_class.html

the valid Dbt flags are: DB_DBT_MALLOC, DB_DBT_REALLOC, DB_DBT_USERMEM, DB_DBT_PARTIAL. So does this "DB_DBT_APPMALLOC" refer to DB_DBT_USERMEM?

In any case, the problem I'm working through is this; I have a secondary key which must be extracted from Dbt * pdata and stored in user allocated memory. Unfortunately, the documented example doesn't go over this explicitly and I'm a bit new to BDB, so I'm hesitant..

When allocating memory for use by the Dbt secondary key, how long does this memory have to be valid for the secondary index to do its thing? When is it safe to free this? I'm guessing it's intimately tied to the lifetime of the primary key/data Dbt pair, but it isn't very clear from docs.

Thanks for any help!

Comments

526209
Ok, so I've poked around a bit more and have found more info on DB_DBT_APPMALLOC:

http://www.sleepycat.com/docs/api_cxx/db_associate.html

"""
If the callback function needs to allocate memory for the data field rather than simply pointing into the primary key or datum, the flags field of the returned Dbt should be set to DB_DBT_APPMALLOC, which indicates that Berkeley DB should free the memory when it is done with it.
"""

This seems to answer my earlier questions. Thanks for your patience :)
1 - 1
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 30 2006
Added on Aug 2 2006
1 comment
866 views