DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Berkeley DB
version 4.4.20

com.sleepycat.db
Interface SecondaryKeyCreator

All Known Implementing Classes:
SerialSerialKeyCreator, TupleSerialKeyCreator, TupleTupleKeyCreator

public interface SecondaryKeyCreator

An interface specifying how secondary keys for a SecondaryDatabase are created.

A secondary key may be derived from the primary key, primary data, or a combination of the primary key and data. For secondary keys that are optional, the key creator method may return false and the key/data pair will not be indexed. To ensure the integrity of a secondary database the key creator method must always return the same result for a given set of input parameters.

The key creator object is specified by calling SecondaryConfig.setKeyCreator. The secondary database configuration is specified when calling Environment.openSecondaryDatabase.

For example:

    class MyKeyCreator implements SecondaryKeyCreator {
        public boolean createSecondaryKey(SecondaryDatabase secondary,
                                            DatabaseEntry key,
                                            DatabaseEntry data,
                                            DatabaseEntry result)
                throws DatabaseException {
            //
            // DO HERE: Extract the secondary key from the primary key and data,
            // and set the secondary key into the result parameter.
            //
            return true;
        }
    }
    ...
    SecondaryConfig secConfig = new SecondaryConfig();
    secConfig.setKeyCreator(new MyKeyCreator());


Method Summary
 boolean createSecondaryKey(SecondaryDatabase secondary, DatabaseEntry key, DatabaseEntry data, DatabaseEntry result)
          Creates a secondary key entry, given a primary key and data entry.
 

Method Detail

createSecondaryKey

public boolean createSecondaryKey(SecondaryDatabase secondary,
                                  DatabaseEntry key,
                                  DatabaseEntry data,
                                  DatabaseEntry result)
                           throws DatabaseException
Creates a secondary key entry, given a primary key and data entry.

Parameters:
secondary - the database to which the secondary key will be added.

key - the primary key entry. This parameter must not be modified by this method.

data - the primary data entry. This parameter must not be modified by this method.

result - the secondary key created by this method.

Returns:
true if a key was created, or false to indicate that the key is not present.

Throws:
DatabaseException - if an error occurs attempting to create the secondary key.

Berkeley DB
version 4.4.20

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