public class SecondaryConfig extends DatabaseConfig
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());
Modifier and Type | Field and Description |
---|---|
static SecondaryConfig |
DEFAULT |
Constructor and Description |
---|
SecondaryConfig()
Creates an instance with the system's default settings.
|
Modifier and Type | Method and Description |
---|---|
SecondaryConfig |
clone()
Returns a copy of this configuration object.
|
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.
|
SecondaryConfig |
setForeignKeyDatabase(Database foreignKeyDatabase)
Defines a foreign key integrity constraint for a given foreign key
database.
|
SecondaryConfig |
setForeignKeyDeleteAction(ForeignKeyDeleteAction foreignKeyDeleteAction)
Specifies the action taken when a referenced record in the foreign key
database is deleted.
|
SecondaryConfig |
setForeignKeyNullifier(ForeignKeyNullifier foreignKeyNullifier)
Specifies the user-supplied object used for setting single-valued
foreign keys to null.
|
SecondaryConfig |
setForeignMultiKeyNullifier(ForeignMultiKeyNullifier foreignMultiKeyNullifier)
Specifies the user-supplied object used for setting multi-valued foreign
keys to null.
|
SecondaryConfig |
setImmutableSecondaryKey(boolean immutableSecondaryKey)
Specifies whether the secondary key is immutable.
|
SecondaryConfig |
setKeyCreator(SecondaryKeyCreator keyCreator)
Specifies the user-supplied object used for creating single-valued
secondary keys.
|
SecondaryConfig |
setMultiKeyCreator(SecondaryMultiKeyCreator multiKeyCreator)
Specifies the user-supplied object used for creating multi-valued
secondary keys.
|
java.lang.String |
toString()
Returns the values for each configuration attribute.
|
cloneConfig, getAllowCreate, getBtreeComparator, getBtreeComparatorByClassName, getCacheMode, getDeferredWrite, getDuplicateComparator, getDuplicateComparatorByClassName, getExclusiveCreate, getKeyPrefixing, getNodeMaxDupTreeEntries, getNodeMaxEntries, getOverrideBtreeComparator, getOverrideDuplicateComparator, getReadOnly, getReplicated, getSortedDuplicates, getTemporary, getTransactional, getUseExistingConfig, setAllowCreate, setBtreeComparator, setBtreeComparator, setCacheMode, setDeferredWrite, setDuplicateComparator, setDuplicateComparator, setExclusiveCreate, setKeyPrefixing, setNodeMaxDupTreeEntries, setNodeMaxEntries, setOverrideBtreeComparator, setOverrideDuplicateComparator, setReadOnly, setReplicated, setSortedDuplicates, setTemporary, setTransactional, setUseExistingConfig
public static final SecondaryConfig DEFAULT
public SecondaryConfig()
public SecondaryConfig setKeyCreator(SecondaryKeyCreator keyCreator)
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.
keyCreator
- the user-supplied object used for creating
single-valued secondary keys.public SecondaryKeyCreator getKeyCreator()
setKeyCreator(com.sleepycat.je.SecondaryKeyCreator)
public SecondaryConfig setMultiKeyCreator(SecondaryMultiKeyCreator multiKeyCreator)
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.
multiKeyCreator
- the user-supplied object used for creating
multi-valued secondary keys.public SecondaryMultiKeyCreator getMultiKeyCreator()
setKeyCreator(com.sleepycat.je.SecondaryKeyCreator)
public SecondaryConfig setAllowPopulate(boolean allowPopulate)
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.
allowPopulate
- whether automatic population of the secondary is
allowed.public boolean getAllowPopulate()
setAllowPopulate(boolean)
has not been called, this method returns
false.setAllowPopulate(boolean)
public SecondaryConfig setForeignKeyDatabase(Database foreignKeyDatabase)
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.
foreignKeyDatabase
- the database used to check the foreign key
integrity constraint, or null if no foreign key constraint should be
checked.public Database getForeignKeyDatabase()
setForeignKeyDatabase(com.sleepycat.je.Database)
public SecondaryConfig setForeignKeyDeleteAction(ForeignKeyDeleteAction foreignKeyDeleteAction)
This property is ignored if the foreign key database property is null.
foreignKeyDeleteAction
- the action taken when a referenced record
in the foreign key database is deleted.@see #setForeignKeyDatabase
public ForeignKeyDeleteAction getForeignKeyDeleteAction()
setForeignKeyDeleteAction(com.sleepycat.je.ForeignKeyDeleteAction)
public SecondaryConfig setForeignKeyNullifier(ForeignKeyNullifier foreignKeyNullifier)
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.
foreignKeyNullifier
- the user-supplied object used for setting
single-valued foreign keys to null.@see ForeignKeyDeleteAction#NULLIFY @see
#setForeignKeyDatabase
public ForeignKeyNullifier getForeignKeyNullifier()
setForeignKeyNullifier(com.sleepycat.je.ForeignKeyNullifier)
public SecondaryConfig setForeignMultiKeyNullifier(ForeignMultiKeyNullifier foreignMultiKeyNullifier)
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.
foreignMultiKeyNullifier
- the user-supplied object used for
setting multi-valued foreign keys to null.@see ForeignKeyDeleteAction#NULLIFY @see
#setForeignKeyDatabase
public ForeignMultiKeyNullifier getForeignMultiKeyNullifier()
setForeignMultiKeyNullifier(com.sleepycat.je.ForeignMultiKeyNullifier)
public SecondaryConfig setImmutableSecondaryKey(boolean immutableSecondaryKey)
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.
immutableSecondaryKey
- whether the secondary key is immutable.public boolean getImmutableSecondaryKey()
setImmutableSecondaryKey(boolean)
has not been called, this method returns
false.setImmutableSecondaryKey(boolean)
public SecondaryConfig clone()
clone
in class DatabaseConfig
public java.lang.String toString()
toString
in class DatabaseConfig
Copyright (c) 2002, 2017 Oracle and/or its affiliates. All rights reserved.