com.sleepycat.je
Class SecondaryConfig

java.lang.Object
  extended by com.sleepycat.je.DatabaseConfig
      extended by com.sleepycat.je.SecondaryConfig
All Implemented Interfaces:
Cloneable

public class SecondaryConfig
extends DatabaseConfig

The configuration properties of a SecondaryDatabase extend those of a primary Database. The secondary database configuration is specified when calling Environment.openSecondaryDatabase.

To create a configuration object with default attributes:

     SecondaryConfig config = new SecondaryConfig();
 

To set custom attributes:

     SecondaryConfig config = new SecondaryConfig();
     config.setAllowCreate(true);
     config.setSortedDuplicates(true);
     config.setKeyCreator(new MyKeyCreator());
 

See Also:
Environment.openSecondaryDatabase @see SecondaryDatabase

Field Summary
static SecondaryConfig DEFAULT
           
 
Constructor Summary
SecondaryConfig()
          Creates an instance with the system's default settings.
 
Method Summary
 SecondaryConfig clone()
          Returns a copy of this configuration object.
(package private)  String genSecondaryConfigMismatchMessage(DatabaseConfig config, boolean kcMatch, boolean mkcMatch, boolean fkdMatch, boolean fkdaMatch, boolean fknMatch, boolean fmknMatch, boolean imskMatch)
           
 boolean getAllowPopulate()
          Returns whether automatic population of the secondary is allowed.
 Database getForeignKeyDatabase()
          Returns the database used to check the foreign key integrity constraint, or null if no foreign key constraint will be checked.
 ForeignKeyDeleteAction getForeignKeyDeleteAction()
          Returns the action taken when a referenced record in the foreign key database is deleted.
 ForeignKeyNullifier getForeignKeyNullifier()
          Returns the user-supplied object used for setting single-valued foreign keys to null.
 ForeignMultiKeyNullifier getForeignMultiKeyNullifier()
          Returns the user-supplied object used for setting multi-valued foreign keys to null.
 boolean getImmutableSecondaryKey()
          Returns whether the secondary key is immutable.
 SecondaryKeyCreator getKeyCreator()
          Returns the user-supplied object used for creating single-valued secondary keys.
 SecondaryMultiKeyCreator getMultiKeyCreator()
          Returns the user-supplied object used for creating multi-valued secondary keys.
 SecondaryConfig setAllowPopulate(boolean allowPopulate)
          Specifies whether automatic population of the secondary is allowed.
 void setAllowPopulateVoid(boolean allowPopulate)
           
 SecondaryConfig setForeignKeyDatabase(Database foreignKeyDatabase)
          Defines a foreign key integrity constraint for a given foreign key database.
 void setForeignKeyDatabaseVoid(Database foreignKeyDatabase)
           
 SecondaryConfig setForeignKeyDeleteAction(ForeignKeyDeleteAction foreignKeyDeleteAction)
          Specifies the action taken when a referenced record in the foreign key database is deleted.
 void setForeignKeyDeleteActionVoid(ForeignKeyDeleteAction foreignKeyDeleteAction)
           
 SecondaryConfig setForeignKeyNullifier(ForeignKeyNullifier foreignKeyNullifier)
          Specifies the user-supplied object used for setting single-valued foreign keys to null.
 void setForeignKeyNullifierVoid(ForeignKeyNullifier foreignKeyNullifier)
           
 SecondaryConfig setForeignMultiKeyNullifier(ForeignMultiKeyNullifier foreignMultiKeyNullifier)
          Specifies the user-supplied object used for setting multi-valued foreign keys to null.
 void setForeignMultiKeyNullifierVoid(ForeignMultiKeyNullifier foreignMultiKeyNullifier)
           
 SecondaryConfig setImmutableSecondaryKey(boolean immutableSecondaryKey)
          Specifies whether the secondary key is immutable.
 void setImmutableSecondaryKeyVoid(boolean immutableSecondaryKey)
           
 SecondaryConfig setKeyCreator(SecondaryKeyCreator keyCreator)
          Specifies the user-supplied object used for creating single-valued secondary keys.
 void setKeyCreatorVoid(SecondaryKeyCreator keyCreator)
           
 SecondaryConfig setMultiKeyCreator(SecondaryMultiKeyCreator multiKeyCreator)
          Specifies the user-supplied object used for creating multi-valued secondary keys.
 void setMultiKeyCreatorVoid(SecondaryMultiKeyCreator multiKeyCreator)
           
 DatabaseConfig setOverrideTriggers(boolean override)
           
 DatabaseConfig setTriggers(List<Trigger> triggers)
           
 String toString()
          Returns the values for each configuration attribute.
(package private)  void validate(DatabaseConfig configArg)
          For JCA Database handle caching.
 
Methods inherited from class com.sleepycat.je.DatabaseConfig
checkTriggers, cloneConfig, combineConfig, getAllowCreate, getBtreeComparator, getBtreeComparatorByClassName, getCacheMode, getCacheModeStrategy, getDeferredWrite, getDuplicateComparator, getDuplicateComparatorByClassName, getExclusiveCreate, getKeyPrefixing, getNodeMaxDupTreeEntries, getNodeMaxEntries, getOverrideBtreeComparator, getOverrideDuplicateComparator, getOverrideTriggers, getReadOnly, getReplicated, getSortedDuplicates, getTemporary, getTransactional, getTriggers, getUseExistingConfig, persistentEquals, setAllowCreate, setAllowCreateVoid, setBtreeComparator, setBtreeComparator, setBtreeComparatorInternal, setBtreeComparatorVoid, setBtreeComparatorVoid, setCacheMode, setCacheModeStrategy, setCacheModeStrategyVoid, setCacheModeVoid, setDeferredWrite, setDeferredWriteVoid, setDuplicateComparator, setDuplicateComparator, setDuplicateComparatorInternal, setDuplicateComparatorVoid, setDuplicateComparatorVoid, setExclusiveCreate, setExclusiveCreateVoid, setKeyPrefixing, setKeyPrefixingVoid, setNodeMaxDupTreeEntries, setNodeMaxDupTreeEntriesVoid, setNodeMaxEntries, setNodeMaxEntriesVoid, setOverrideBtreeComparator, setOverrideBtreeComparatorVoid, setOverrideDuplicateComparator, setOverrideDuplicateComparatorVoid, setOverrideTriggersVoid, setReadOnly, setReadOnlyVoid, setReplicated, setSortedDuplicates, setSortedDuplicatesVoid, setTemporary, setTemporaryVoid, setTransactional, setTransactionalVoid, setTriggersVoid, setUseExistingConfig, setUseExistingConfigVoid, validateForNewDb, validateOnDbOpen
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT

public static final SecondaryConfig DEFAULT
Constructor Detail

SecondaryConfig

public SecondaryConfig()
Creates an instance with the system's default settings.

Method Detail

setKeyCreator

public SecondaryConfig setKeyCreator(SecondaryKeyCreator keyCreator)
Specifies the user-supplied object used for creating single-valued secondary keys.

Unless the primary database is read-only, a key creator is required when opening a secondary database. Either a KeyCreator or MultiKeyCreator must be specified, but both may not be specified.

Unless the primary database is read-only, a key creator is required when opening a secondary database.

WARNING: Key creator instances are shared by multiple threads and key creator methods are called without any special synchronization. Therefore, key creators must be thread safe. In general no shared state should be used and any caching of computed values must be done with proper synchronization.

Parameters:
keyCreator - the user-supplied object used for creating single-valued secondary keys.
Returns:
this

setKeyCreatorVoid

public void setKeyCreatorVoid(SecondaryKeyCreator keyCreator)

getKeyCreator

public SecondaryKeyCreator getKeyCreator()
Returns the user-supplied object used for creating single-valued secondary keys.

Returns:
the user-supplied object used for creating single-valued secondary keys.
See Also:
setKeyCreator(com.sleepycat.je.SecondaryKeyCreator)

setMultiKeyCreator

public SecondaryConfig setMultiKeyCreator(SecondaryMultiKeyCreator multiKeyCreator)
Specifies the user-supplied object used for creating multi-valued secondary keys.

Unless the primary database is read-only, a key creator is required when opening a secondary database. Either a KeyCreator or MultiKeyCreator must be specified, but both may not be specified.

WARNING: Key creator instances are shared by multiple threads and key creator methods are called without any special synchronization. Therefore, key creators must be thread safe. In general no shared state should be used and any caching of computed values must be done with proper synchronization.

Parameters:
multiKeyCreator - the user-supplied object used for creating multi-valued secondary keys.
Returns:
this

setMultiKeyCreatorVoid

public void setMultiKeyCreatorVoid(SecondaryMultiKeyCreator multiKeyCreator)

getMultiKeyCreator

public SecondaryMultiKeyCreator getMultiKeyCreator()
Returns the user-supplied object used for creating multi-valued secondary keys.

Returns:
the user-supplied object used for creating multi-valued secondary keys.
See Also:
setKeyCreator(com.sleepycat.je.SecondaryKeyCreator)

setAllowPopulate

public SecondaryConfig setAllowPopulate(boolean allowPopulate)
Specifies whether automatic population of the secondary is allowed.

If automatic population is allowed, when the secondary database is opened it is checked to see if it is empty. If it is empty, the primary database is read in its entirety and keys are added to the secondary database using the information read from the primary.

If this property is set to true and the database is transactional, the population of the secondary will be done within the explicit or auto-commit transaction that is used to open the database.

Parameters:
allowPopulate - whether automatic population of the secondary is allowed.
Returns:
this

setAllowPopulateVoid

public void setAllowPopulateVoid(boolean allowPopulate)

getAllowPopulate

public boolean getAllowPopulate()
Returns whether automatic population of the secondary is allowed. If setAllowPopulate(boolean) has not been called, this method returns false.

Returns:
whether automatic population of the secondary is allowed.
See Also:
setAllowPopulate(boolean)

setForeignKeyDatabase

public SecondaryConfig setForeignKeyDatabase(Database foreignKeyDatabase)
Defines a foreign key integrity constraint for a given foreign key database.

If this property is non-null, a record must be present in the specified foreign database for every record in the secondary database, where the secondary key value is equal to the foreign database key value. Whenever a record is to be added to the secondary database, the secondary key is used as a lookup key in the foreign database. If the key is not found in the foreign database, a ForeignConstraintException is thrown.

The foreign database must not have duplicates allowed. If duplicates are allowed, an IllegalArgumentException will be thrown when the secondary database is opened.

Parameters:
foreignKeyDatabase - the database used to check the foreign key integrity constraint, or null if no foreign key constraint should be checked.
Returns:
this

setForeignKeyDatabaseVoid

public void setForeignKeyDatabaseVoid(Database foreignKeyDatabase)

getForeignKeyDatabase

public Database getForeignKeyDatabase()
Returns the database used to check the foreign key integrity constraint, or null if no foreign key constraint will be checked.

Returns:
the foreign key database, or null.
See Also:
setForeignKeyDatabase(com.sleepycat.je.Database)

setForeignKeyDeleteAction

public SecondaryConfig setForeignKeyDeleteAction(ForeignKeyDeleteAction foreignKeyDeleteAction)
Specifies the action taken when a referenced record in the foreign key database is deleted.

This property is ignored if the foreign key database property is null.

Parameters:
foreignKeyDeleteAction - the action taken when a referenced record in the foreign key database is deleted.
Returns:
this
See Also:
@see #setForeignKeyDatabase

setForeignKeyDeleteActionVoid

public void setForeignKeyDeleteActionVoid(ForeignKeyDeleteAction foreignKeyDeleteAction)

getForeignKeyDeleteAction

public ForeignKeyDeleteAction getForeignKeyDeleteAction()
Returns the action taken when a referenced record in the foreign key database is deleted.

Returns:
the action taken when a referenced record in the foreign key database is deleted.
See Also:
setForeignKeyDeleteAction(com.sleepycat.je.ForeignKeyDeleteAction)

setForeignKeyNullifier

public SecondaryConfig setForeignKeyNullifier(ForeignKeyNullifier foreignKeyNullifier)
Specifies the user-supplied object used for setting single-valued foreign keys to null.

This method may not be used along with setMultiKeyCreator(com.sleepycat.je.SecondaryMultiKeyCreator). When using a multi-key creator, use setForeignMultiKeyNullifier(com.sleepycat.je.ForeignMultiKeyNullifier) instead.

If the foreign key database property is non-null and the foreign key delete action is NULLIFY, this property is required to be non-null; otherwise, this property is ignored.

WARNING: Key nullifier instances are shared by multiple threads and key nullifier methods are called without any special synchronization. Therefore, key creators must be thread safe. In general no shared state should be used and any caching of computed values must be done with proper synchronization.

Parameters:
foreignKeyNullifier - the user-supplied object used for setting single-valued foreign keys to null.
Returns:
this
See Also:
@see ForeignKeyDeleteAction#NULLIFY @see #setForeignKeyDatabase

setForeignKeyNullifierVoid

public void setForeignKeyNullifierVoid(ForeignKeyNullifier foreignKeyNullifier)

getForeignKeyNullifier

public ForeignKeyNullifier getForeignKeyNullifier()
Returns the user-supplied object used for setting single-valued foreign keys to null.

Returns:
the user-supplied object used for setting single-valued foreign keys to null.
See Also:
setForeignKeyNullifier(com.sleepycat.je.ForeignKeyNullifier)

setForeignMultiKeyNullifier

public SecondaryConfig setForeignMultiKeyNullifier(ForeignMultiKeyNullifier foreignMultiKeyNullifier)
Specifies the user-supplied object used for setting multi-valued foreign keys to null.

If the foreign key database property is non-null and the foreign key delete action is NULLIFY, this property is required to be non-null; otherwise, this property is ignored.

WARNING: Key nullifier instances are shared by multiple threads and key nullifier methods are called without any special synchronization. Therefore, key creators must be thread safe. In general no shared state should be used and any caching of computed values must be done with proper synchronization.

Parameters:
foreignMultiKeyNullifier - the user-supplied object used for setting multi-valued foreign keys to null.
Returns:
this
See Also:
@see ForeignKeyDeleteAction#NULLIFY @see #setForeignKeyDatabase

setForeignMultiKeyNullifierVoid

public void setForeignMultiKeyNullifierVoid(ForeignMultiKeyNullifier foreignMultiKeyNullifier)

getForeignMultiKeyNullifier

public ForeignMultiKeyNullifier getForeignMultiKeyNullifier()
Returns the user-supplied object used for setting multi-valued foreign keys to null.

Returns:
the user-supplied object used for setting multi-valued foreign keys to null.
See Also:
setForeignMultiKeyNullifier(com.sleepycat.je.ForeignMultiKeyNullifier)

setImmutableSecondaryKey

public SecondaryConfig setImmutableSecondaryKey(boolean immutableSecondaryKey)
Specifies whether the secondary key is immutable.

Specifying that a secondary key is immutable can be used to optimize updates when the secondary key in a primary record will never be changed after that primary record is inserted. For immutable secondary keys, a best effort is made to avoid calling SecondaryKeyCreator.createSecondaryKey when a primary record is updated. This optimization may reduce the overhead of an update operation significantly if the createSecondaryKey operation is expensive.

Be sure to set this property to true only if the secondary key in the primary record is never changed. If this rule is violated, the secondary index will become corrupted, that is, it will become out of sync with the primary.

Parameters:
immutableSecondaryKey - whether the secondary key is immutable.
Returns:
this

setImmutableSecondaryKeyVoid

public void setImmutableSecondaryKeyVoid(boolean immutableSecondaryKey)

getImmutableSecondaryKey

public boolean getImmutableSecondaryKey()
Returns whether the secondary key is immutable. If setImmutableSecondaryKey(boolean) has not been called, this method returns false.

Returns:
whether the secondary key is immutable.
See Also:
setImmutableSecondaryKey(boolean)

clone

public SecondaryConfig clone()
Returns a copy of this configuration object.

Overrides:
clone in class DatabaseConfig

validate

void validate(DatabaseConfig configArg)
        throws DatabaseException
For JCA Database handle caching.

Overrides:
validate in class DatabaseConfig
Throws:
IllegalArgumentException - via JEConnection.openSecondaryDatabase.
DatabaseException

setTriggers

public DatabaseConfig setTriggers(List<Trigger> triggers)
Overrides:
setTriggers in class DatabaseConfig
Parameters:
triggers - the list of database triggers to be associated with the environment.
Returns:
this

setOverrideTriggers

public DatabaseConfig setOverrideTriggers(boolean override)
Overrides:
setOverrideTriggers in class DatabaseConfig
Parameters:
override - Set to true to override the existing comparator.
Returns:
this

genSecondaryConfigMismatchMessage

String genSecondaryConfigMismatchMessage(DatabaseConfig config,
                                         boolean kcMatch,
                                         boolean mkcMatch,
                                         boolean fkdMatch,
                                         boolean fkdaMatch,
                                         boolean fknMatch,
                                         boolean fmknMatch,
                                         boolean imskMatch)

toString

public String toString()
Returns the values for each configuration attribute.

Overrides:
toString in class DatabaseConfig
Returns:
the values for each configuration attribute.


Copyright (c) 2004-2012 Oracle. All rights reserved.