Berkeley DB
version 4.2.52

com.sleepycat.db
Interface DbSecondaryKeyCreate


public interface DbSecondaryKeyCreate

An interface specifying a function which constructs secondary keys from primary key and data items.


Method Summary
 int secondaryKeyCreate(Db secondary, Dbt key, Dbt data, Dbt result)
          The secondaryKeyCreate interface is used by the Db.associate method.
 

Method Detail

secondaryKeyCreate

public int secondaryKeyCreate(Db secondary,
                              Dbt key,
                              Dbt data,
                              Dbt result)
                       throws DbException
The secondaryKeyCreate interface is used by the Db.associate method. This interface defines the application-specific function to be called to construct secondary keys from primary key and data items.

Parameters:
secondary - the database handle for the secondary.
key - a Dbt referencing the primary key.
data - a Dbt referencing the primary data item.
result - a zeroed Dbt in which the callback function should fill in data and size fields that describe the secondary key.
Returns:
  • DB_DONOTINDEX

    If any key/data pair in the primary yields a null secondary key and should be left out of the secondary index, the callback function may optionally return Db.DB_DONOTINDEX. Otherwise, the callback function should return 0 in case of success or an error outside of the Berkeley DB name space in case of failure; the error code will be returned from the Berkeley DB call that initiated the callback.

    If the callback function returns Db.DB_DONOTINDEX for any key/data pairs in the primary database, the secondary index will not contain any reference to those key/data pairs, and such operations as cursor iterations and range queries will reflect only the corresponding subset of the database. If this is not desirable, the application should ensure that the callback function is well-defined for all possible values and never returns Db.DB_DONOTINDEX.

Throws:
DbException - Signals that an exception of some sort has occurred.

Berkeley DB
version 4.2.52

Copyright (c) 1996-2003 Sleepycat Software, Inc. - All rights reserved.