Discussions
Categories
- 197K All Categories
- 2.5K Data
- 546 Big Data Appliance
- 1.9K Data Science
- 450.8K Databases
- 221.9K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 552 MySQL Community Space
- 479 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.1K ORDS, SODA & JSON in the Database
- 556 SQLcl
- 4K SQL Developer Data Modeler
- 187.2K SQL & PL/SQL
- 21.4K SQL Developer
- 296.4K Development
- 17 Developer Projects
- 139 Programming Languages
- 293.1K Development Tools
- 110 DevOps
- 3.1K QA/Testing
- 646.1K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 161 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.2K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 19 Java Essentials
- 162 Java 8 Questions
- 86K Java Programming
- 81 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 205 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 475 LiveLabs
- 39 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 175 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 233 Portuguese
secondary index key generation function, documentation error?

526209
Member Posts: 2
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!
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
-
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
This discussion has been closed.