com.sleepycat.je
Class DatabaseConfig

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

public class DatabaseConfig
extends Object
implements Cloneable

Specifies the attributes of a database.

There are two groups of database attributes: per-database handle attributes, and database-wide attributes. An attribute may be persistent/transient or mutable/immutable:

Scope Mutable Persistent Attribute
Database-wide attribute True True btree comparator
duplicate comparator
key prefixing
nodeMaxEntries
True False deferred write
transactional
False True sorted duplicates
False False temporary
Per-database handle attributes False False allow create
exclusive create
read only
use existing config

Persistent attributes will be saved in the log and remain in effect every time the environment is reopened. Transient attributes only remain in effect until:


Field Summary
static DatabaseConfig DEFAULT
          An instance created using the default constructor is initialized with the system's default settings.
 
Constructor Summary
DatabaseConfig()
          An instance created using the default constructor is initialized with the system's default settings.
 
Method Summary
(package private)  boolean checkTriggers(List<Trigger> triggerList)
          Checks that the triggers in the list have consistent definitions.
 DatabaseConfig clone()
          Returns a copy of this configuration object.
 DatabaseConfig cloneConfig()
          Deprecated. As of JE 4.0.13, replaced by clone().

(package private) static DatabaseConfig combineConfig(DatabaseImpl dbImpl, DatabaseConfig dbHandleConfig)
          Combine the per-Database handle and Database-wide properties for a database handle.
 boolean getAllowCreate()
          Returns true if the Environment.openDatabase method is configured to create the database if it does not already exist.
 Comparator<byte[]> getBtreeComparator()
          Returns the Comparator used for key comparison on this database.
 boolean getBtreeComparatorByClassName()
          Returns true if the btree comparator is set by class name, not by serializable Comparator object
 CacheMode getCacheMode()
          Returns the default CacheMode used for operations performed on this database, or null if the environment default is used.
 CacheModeStrategy getCacheModeStrategy()
           
 boolean getDeferredWrite()
          Returns the deferred-write option.
 Comparator<byte[]> getDuplicateComparator()
          Returns the Comparator used for duplicate record comparison on this database.
 boolean getDuplicateComparatorByClassName()
          Returns true if the duplicate comparator is set by class name, not by serializable Comparator object.
 boolean getExclusiveCreate()
          Returns true if the Environment.openDatabase method is configured to fail if the database already exists.
 boolean getKeyPrefixing()
          Returns the key prefixing configuration.
 int getNodeMaxDupTreeEntries()
          Deprecated. this property no longer has any effect and zero is always returned; getNodeMaxEntries() should be used instead.
 int getNodeMaxEntries()
          Returns the maximum number of children a B+Tree node can have.
 boolean getOverrideBtreeComparator()
          Returns the override setting for the btree comparator.
 boolean getOverrideDuplicateComparator()
          Returns the override setting for the duplicate comparator.
 boolean getOverrideTriggers()
           
 boolean getReadOnly()
          Returns true if the database is configured in read-only mode.
(package private)  boolean getReplicated()
          For internal use only.
 boolean getSortedDuplicates()
          Returns true if the database is configured to support records with duplicate keys.
 boolean getTemporary()
          Returns the temporary database option.
 boolean getTransactional()
          Returns true if the database open is enclosed within a transaction.
 List<Trigger> getTriggers()
           
 boolean getUseExistingConfig()
          Return the value of the useExistingConfig property.
(package private)  boolean persistentEquals(DatabaseConfig other)
          For unit tests, checks that the database configuration attributes that are saved persistently are equal.
 DatabaseConfig setAllowCreate(boolean allowCreate)
          Configures the Environment.openDatabase method to create the database if it does not already exist.
 void setAllowCreateVoid(boolean allowCreate)
           
 DatabaseConfig setBtreeComparator(Class<? extends Comparator<byte[]>> btreeComparatorClass)
          By default, a byte by byte lexicographic comparison is used for btree keys.
 DatabaseConfig setBtreeComparator(Comparator<byte[]> btreeComparator)
          By default, a byte by byte lexicographic comparison is used for btree keys.
(package private)  void setBtreeComparatorInternal(Comparator<byte[]> comparator, boolean byClassName)
          Used to set the comparator when filling in a configuration from an existing database.
 void setBtreeComparatorVoid(Class<? extends Comparator<byte[]>> btreeComparatorClass)
           
 void setBtreeComparatorVoid(Comparator<byte[]> btreeComparator)
           
 DatabaseConfig setCacheMode(CacheMode cacheMode)
          Sets the default CacheMode used for operations performed on this database.
 DatabaseConfig setCacheModeStrategy(CacheModeStrategy strategy)
           
 void setCacheModeStrategyVoid(CacheModeStrategy strategy)
           
 void setCacheModeVoid(CacheMode cacheMode)
           
 DatabaseConfig setDeferredWrite(boolean deferredWrite)
          Sets the deferred-write option.
 void setDeferredWriteVoid(boolean deferredWrite)
           
 DatabaseConfig setDuplicateComparator(Class<? extends Comparator<byte[]>> duplicateComparatorClass)
          By default, a byte by byte lexicographic comparison is used for duplicate data items in a duplicate set.
 DatabaseConfig setDuplicateComparator(Comparator<byte[]> duplicateComparator)
          By default, a byte by byte lexicographic comparison is used for duplicate data items in a duplicate set.
(package private)  void setDuplicateComparatorInternal(Comparator<byte[]> comparator, boolean byClassName)
          Used to set the comparator when filling in a configuration from an existing database.
 void setDuplicateComparatorVoid(Class<? extends Comparator<byte[]>> duplicateComparatorClass)
           
 void setDuplicateComparatorVoid(Comparator<byte[]> duplicateComparator)
           
 DatabaseConfig setExclusiveCreate(boolean exclusiveCreate)
          Configure the Environment.openDatabase method to fail if the database already exists.
 void setExclusiveCreateVoid(boolean exclusiveCreate)
           
 DatabaseConfig setKeyPrefixing(boolean keyPrefixing)
          Configure the database to support key prefixing.
 void setKeyPrefixingVoid(boolean keyPrefixing)
           
 DatabaseConfig setNodeMaxDupTreeEntries(int nodeMaxDupTreeEntries)
          Deprecated. this property no longer has any effect; setNodeMaxEntries(int) should be used instead.
 void setNodeMaxDupTreeEntriesVoid(int nodeMaxDupTreeEntries)
           
 DatabaseConfig setNodeMaxEntries(int nodeMaxEntries)
          Configures the Environment.openDatabase method to have a B+Tree fanout of nodeMaxEntries.
 void setNodeMaxEntriesVoid(int nodeMaxEntries)
           
 DatabaseConfig setOverrideBtreeComparator(boolean override)
          Sets to true if the database exists and the btree comparator specified in this configuration object should override the current comparator.
 void setOverrideBtreeComparatorVoid(boolean override)
           
 DatabaseConfig setOverrideDuplicateComparator(boolean override)
          Sets to true if the database exists and the duplicate comparator specified in this configuration object should override the current comparator.
 void setOverrideDuplicateComparatorVoid(boolean override)
           
 DatabaseConfig setOverrideTriggers(boolean override)
           
 void setOverrideTriggersVoid(boolean override)
           
 DatabaseConfig setReadOnly(boolean readOnly)
          Configures the database in read-only mode.
 void setReadOnlyVoid(boolean readOnly)
           
(package private)  void setReplicated(boolean replicated)
          For internal use only.
 DatabaseConfig setSortedDuplicates(boolean sortedDuplicates)
          Configures the database to support records with duplicate keys.
 void setSortedDuplicatesVoid(boolean sortedDuplicates)
           
 DatabaseConfig setTemporary(boolean temporary)
          Sets the temporary database option.
 void setTemporaryVoid(boolean temporary)
           
 DatabaseConfig setTransactional(boolean transactional)
          Encloses the database open within a transaction.
 void setTransactionalVoid(boolean transactional)
           
 DatabaseConfig setTriggers(List<Trigger> triggers)
           
 void setTriggersVoid(List<Trigger> triggers)
           
 DatabaseConfig setUseExistingConfig(boolean useExistingConfig)
          Setting useExistingConfig to true allows a program to open a database without knowing a prior what its configuration is.
 void setUseExistingConfigVoid(boolean useExistingConfig)
           
 String toString()
          Returns the values for each configuration attribute.
(package private)  void validate(DatabaseConfig config)
          For JCA Database handle caching.
(package private)  void validateForNewDb()
          Checks that this database configuration is valid for a new, non-existant database.
(package private)  void validateOnDbOpen(String databaseName, boolean dbIsReplicated)
          Perform validations at database open time on the completed DbConfig object.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT

public static final DatabaseConfig DEFAULT
An instance created using the default constructor is initialized with the system's default settings.

Constructor Detail

DatabaseConfig

public DatabaseConfig()
An instance created using the default constructor is initialized with the system's default settings.

Method Detail

setAllowCreate

public DatabaseConfig setAllowCreate(boolean allowCreate)
Configures the Environment.openDatabase method to create the database if it does not already exist.

Parameters:
allowCreate - If true, configure the Environment.openDatabase method to create the database if it does not already exist.
Returns:
this

setAllowCreateVoid

public void setAllowCreateVoid(boolean allowCreate)

getAllowCreate

public boolean getAllowCreate()
Returns true if the Environment.openDatabase method is configured to create the database if it does not already exist.

This method may be called at any time during the life of the application.

Returns:
true if the Environment.openDatabase method is configured to create the database if it does not already exist.

setExclusiveCreate

public DatabaseConfig setExclusiveCreate(boolean exclusiveCreate)
Configure the Environment.openDatabase method to fail if the database already exists.

The exclusiveCreate mode is only meaningful if specified with the allowCreate mode.

Parameters:
exclusiveCreate - If true, configure the Environment.openDatabase method to fail if the database already exists.
Returns:
this

setExclusiveCreateVoid

public void setExclusiveCreateVoid(boolean exclusiveCreate)

getExclusiveCreate

public boolean getExclusiveCreate()
Returns true if the Environment.openDatabase method is configured to fail if the database already exists.

This method may be called at any time during the life of the application.

Returns:
true if the Environment.openDatabase method is configured to fail if the database already exists.

setSortedDuplicates

public DatabaseConfig setSortedDuplicates(boolean sortedDuplicates)
Configures the database to support records with duplicate keys.

When duplicate keys are configured for a database, key prefixing is also implicitly configured. Without key prefixing, databases with duplicates would store keys inefficiently. Key prefixing is therefore mandatory for databases with duplicates.

Although two records may have the same key, they may not also have the same data item. Two identical records, that have the same key and data, may not be stored in a database.

The ordering of duplicates in the database is determined by the duplicate comparison function. See setDuplicateComparator(java.util.Comparator). If the application does not specify a duplicate comparison function, a default lexical comparison will be used.

If a primary database is to be associated with one or more secondary databases, it may not be configured for duplicates.

Calling this method affects the database, including all threads of control accessing the database.

If the database already exists when the database is opened, any database configuration specified by this method must be the same as the existing database or an error will be returned.

Parameters:
sortedDuplicates - If true, configure the database to support duplicate data items. A value of false is illegal to this method, that is, once set, the configuration cannot be cleared.
Returns:
this

setSortedDuplicatesVoid

public void setSortedDuplicatesVoid(boolean sortedDuplicates)

getSortedDuplicates

public boolean getSortedDuplicates()
Returns true if the database is configured to support records with duplicate keys.

This method may be called at any time during the life of the application.

Returns:
true if the database is configured to support records with duplicate keys.

getKeyPrefixing

public boolean getKeyPrefixing()
Returns the key prefixing configuration. Note that key prefixing is always enabled for a database with duplicates configured.

Returns:
true if key prefixing has been enabled in this database.

setKeyPrefixing

public DatabaseConfig setKeyPrefixing(boolean keyPrefixing)
Configure the database to support key prefixing. Key prefixing causes the representation of keys in the b-tree internal nodes to be split between the common prefix of all keys and the suffixes. Using this may result in a more space-efficient representation in both the in-memory and on-disk formats, but at some possible performance cost.

When duplicate keys are configured for a database, key prefixing is also implicitly configured. Without key prefixing, databases with duplicates would store keys inefficiently. Key prefixing is therefore mandatory for databases with duplicates.

Parameters:
keyPrefixing - If true, enables keyPrefixing for the database.
Returns:
this
Throws:
IllegalStateException - if the keyPrefixing argument is false and setSortedDuplicates(boolean) has been called to configure duplicates. Key prefixing is therefore mandatory for databases with duplicates.

setKeyPrefixingVoid

public void setKeyPrefixingVoid(boolean keyPrefixing)

setTransactional

public DatabaseConfig setTransactional(boolean transactional)
Encloses the database open within a transaction.

If the call succeeds, the open operation will be recoverable. If the call fails, no database will have been created.

All future operations on this database, which are not explicitly enclosed in a transaction by the application, will be enclosed in in a transaction within the library.

Parameters:
transactional - If true, enclose the database open within a transaction.
Returns:
this

setTransactionalVoid

public void setTransactionalVoid(boolean transactional)

getTransactional

public boolean getTransactional()
Returns true if the database open is enclosed within a transaction.

This method may be called at any time during the life of the application.

Returns:
true if the database open is enclosed within a transaction.

setReadOnly

public DatabaseConfig setReadOnly(boolean readOnly)
Configures the database in read-only mode.

Any attempt to modify items in the database will fail, regardless of the actual permissions of any underlying files.

Parameters:
readOnly - If true, configure the database in read-only mode.
Returns:
this

setReadOnlyVoid

public void setReadOnlyVoid(boolean readOnly)

getReadOnly

public boolean getReadOnly()
Returns true if the database is configured in read-only mode.

This method may be called at any time during the life of the application.

Returns:
true if the database is configured in read-only mode.

setNodeMaxEntries

public DatabaseConfig setNodeMaxEntries(int nodeMaxEntries)
Configures the Environment.openDatabase method to have a B+Tree fanout of nodeMaxEntries.

The nodeMaxEntries parameter is only meaningful if specified with the allowCreate mode. See EnvironmentConfig.NODE_MAX_ENTRIES for the valid value range, and the default value.

Parameters:
nodeMaxEntries - The maximum children per B+Tree node.
Returns:
this

setNodeMaxEntriesVoid

public void setNodeMaxEntriesVoid(int nodeMaxEntries)

setNodeMaxDupTreeEntries

public DatabaseConfig setNodeMaxDupTreeEntries(int nodeMaxDupTreeEntries)
Deprecated. this property no longer has any effect; setNodeMaxEntries(int) should be used instead.


setNodeMaxDupTreeEntriesVoid

public void setNodeMaxDupTreeEntriesVoid(int nodeMaxDupTreeEntries)

getNodeMaxEntries

public int getNodeMaxEntries()
Returns the maximum number of children a B+Tree node can have.

This method may be called at any time during the life of the application.

Returns:
The maximum number of children a B+Tree node can have.

getNodeMaxDupTreeEntries

public int getNodeMaxDupTreeEntries()
Deprecated. this property no longer has any effect and zero is always returned; getNodeMaxEntries() should be used instead.


setBtreeComparator

public DatabaseConfig setBtreeComparator(Comparator<byte[]> btreeComparator)
By default, a byte by byte lexicographic comparison is used for btree keys. To customize the comparison, supply a different Comparator.

Note that there are two ways to set the comparator: by specifying the class or by specifying a serializable object. This method is used to specify a serializable object. The comparator class must implement java.util.Comparator and must be serializable. JE will serialize the Comparator and deserialize it when subsequently opening the database.

If a comparator needs to be initialized before it is used or needs access to the environment's ClassLoader property, it may implement the DatabaseComparator interface.

The Comparator.compare() method is passed the byte arrays that are stored in the database. If you know how your data is organized in the byte array, then you can write a comparison routine that directly examines the contents of the arrays. Otherwise, you have to reconstruct your original objects, and then perform the comparison. See the Getting Started Guide for examples.

WARNING: There are several special considerations that must be taken into account when implementing a comparator.

A special type of comparator is a partial comparator, which compares a proper subset (not all bytes) of the key. A partial comparator allows uniquely identifying a record by a partial key value. For example, the key could contain multiple fields but could uniquely identify the record with a single field. The partial comparator could then compare only the single identifying field. A query (Cursor.getSearchKey, for example) could then be performed by passing a partial key that contains only the identifying field.

The comparator for an existing database will not be overridden unless setOverrideBtreeComparator() is set to true.

Returns:
this

setBtreeComparatorVoid

public void setBtreeComparatorVoid(Comparator<byte[]> btreeComparator)

setBtreeComparator

public DatabaseConfig setBtreeComparator(Class<? extends Comparator<byte[]>> btreeComparatorClass)
By default, a byte by byte lexicographic comparison is used for btree keys. To customize the comparison, supply a different Comparator.

Note that there are two ways to set the comparator: by specifying the class or by specifying a serializable object. This method is used to specify a Comparator class. The comparator class must implement java.util.Comparator and must have a public zero-parameter constructor. JE will store the class name and instantiate the Comparator by class name (using Class.forName and newInstance) when subsequently opening the database. Because the Comparator is instantiated using its default constructor, it should not be dependent on other constructor parameters.

The Comparator.compare() method is passed the byte arrays that are stored in the database. If you know how your data is organized in the byte array, then you can write a comparison routine that directly examines the contents of the arrays. Otherwise, you have to reconstruct your original objects, and then perform the comparison. See the Getting Started Guide for examples.

If a comparator needs to be initialized before it is used or needs access to the environment's ClassLoader property, it may implement the DatabaseComparator interface.

WARNING: There are several special considerations that must be taken into account when implementing a comparator.

A special type of comparator is a partial comparator, which compares a proper subset (not all bytes) of the key. A partial comparator allows uniquely identifying a record by a partial key value. For example, the key could contain multiple fields but could uniquely identify the record with a single field. The partial comparator could then compare only the single identifying field. A query (Cursor.getSearchKey, for example) could then be performed by passing a partial key that contains only the identifying field.

The comparator for an existing database will not be overridden unless setOverrideBtreeComparator() is set to true.

Returns:
this

setBtreeComparatorVoid

public void setBtreeComparatorVoid(Class<? extends Comparator<byte[]>> btreeComparatorClass)

getBtreeComparator

public Comparator<byte[]> getBtreeComparator()
Returns the Comparator used for key comparison on this database.


getBtreeComparatorByClassName

public boolean getBtreeComparatorByClassName()
Returns true if the btree comparator is set by class name, not by serializable Comparator object

Returns:
true if the comparator is set by class name, not by serializable Comparator object.

setOverrideBtreeComparator

public DatabaseConfig setOverrideBtreeComparator(boolean override)
Sets to true if the database exists and the btree comparator specified in this configuration object should override the current comparator.

Parameters:
override - Set to true to override the existing comparator.
Returns:
this

setOverrideBtreeComparatorVoid

public void setOverrideBtreeComparatorVoid(boolean override)

getOverrideBtreeComparator

public boolean getOverrideBtreeComparator()
Returns the override setting for the btree comparator.


setDuplicateComparator

public DatabaseConfig setDuplicateComparator(Comparator<byte[]> duplicateComparator)
By default, a byte by byte lexicographic comparison is used for duplicate data items in a duplicate set. To customize the comparison, supply a different Comparator.

Note that there are two ways to set the comparator: by specifying the class or by specifying a serializable object. This method is used to specify a serializable object. The comparator class must implement java.util.Comparator and must be serializable. JE will serialize the Comparator and deserialize it when subsequently opening the database.

The Comparator.compare() method is passed the byte arrays that are stored in the database. If you know how your data is organized in the byte array, then you can write a comparison routine that directly examines the contents of the arrays. Otherwise, you have to reconstruct your original objects, and then perform the comparison. See the Getting Started Guide for examples.

If a comparator needs to be initialized before it is used or needs access to the environment's ClassLoader property, it may implement the DatabaseComparator interface.

WARNING: There are several special considerations that must be taken into account when implementing a comparator.

A special type of comparator is a partial comparator, which is a comparator that compares a proper subset (not all bytes) of the data. A partial comparator allows uniquely identifying a record within a duplicate set by a partial data value. For example, the data could contain multiple fields but could uniquely identify the record with a single field. The partial comparator could then compare only the single identifying field. A query (Cursor.getSearchBoth, for example) could then be performed by passing a partial data value that contains only the identifying field.

When using a partial comparator, it is possible to update the data for a duplicate record, as long as only the non-identifying fields in the data are changed. See Cursor.putCurrent for more information.

The comparator for an existing database will not be overridden unless setOverrideDuplicateComparator() is set to true.


setDuplicateComparatorVoid

public void setDuplicateComparatorVoid(Comparator<byte[]> duplicateComparator)

setDuplicateComparator

public DatabaseConfig setDuplicateComparator(Class<? extends Comparator<byte[]>> duplicateComparatorClass)
By default, a byte by byte lexicographic comparison is used for duplicate data items in a duplicate set. To customize the comparison, supply a different Comparator.

Note that there are two ways to set the comparator: by specifying the class or by specifying a serializable object. This method is used to specify a Comparator class. The comparator class must implement java.util.Comparator and must have a public zero-parameter constructor. JE will store the class name and instantiate the Comparator by class name (using Class.forName and newInstance) when subsequently opening the database. Because the Comparator is instantiated using its default constructor, it should not be dependent on other constructor parameters.

The Comparator.compare() method is passed the byte arrays that are stored in the database. If you know how your data is organized in the byte array, then you can write a comparison routine that directly examines the contents of the arrays. Otherwise, you have to reconstruct your original objects, and then perform the comparison. See the Getting Started Guide for examples.

If a comparator needs to be initialized before it is used or needs access to the environment's ClassLoader property, it may implement the DatabaseComparator interface.

WARNING: There are several special considerations that must be taken into account when implementing a comparator.

A special type of comparator is a partial comparator, which is a comparator that compares a proper subset (not all bytes) of the data. A partial comparator allows uniquely identifying a record within a duplicate set by a partial data value. For example, the data could contain multiple fields but could uniquely identify the record with a single field. The partial comparator could then compare only the single identifying field. A query (Cursor.getSearchBoth, for example) could then be performed by passing a partial data value that contains only the identifying field.

When using a partial comparator, it is possible to update the data for a duplicate record, as long as only the non-identifying fields in the data are changed. See Cursor.putCurrent for more information.

The comparator for an existing database will not be overridden unless setOverrideDuplicateComparator() is set to true.

Returns:
this

setDuplicateComparatorVoid

public void setDuplicateComparatorVoid(Class<? extends Comparator<byte[]>> duplicateComparatorClass)

getDuplicateComparator

public Comparator<byte[]> getDuplicateComparator()
Returns the Comparator used for duplicate record comparison on this database.


getDuplicateComparatorByClassName

public boolean getDuplicateComparatorByClassName()
Returns true if the duplicate comparator is set by class name, not by serializable Comparator object.

Returns:
true if the duplicate comparator is set by class name, not by serializable Comparator object.

setOverrideDuplicateComparator

public DatabaseConfig setOverrideDuplicateComparator(boolean override)
Sets to true if the database exists and the duplicate comparator specified in this configuration object should override the current comparator.

Parameters:
override - Set to true to override the existing comparator.
Returns:
this

setOverrideDuplicateComparatorVoid

public void setOverrideDuplicateComparatorVoid(boolean override)

getOverrideDuplicateComparator

public boolean getOverrideDuplicateComparator()
Returns the override setting for the duplicate comparator.


setTriggers

public DatabaseConfig setTriggers(List<Trigger> triggers)
Parameters:
triggers - the list of database triggers to be associated with the environment.
Returns:
this
Throws:
IllegalArgumentException - If the triggers in the list do not have unique names, have conflicting types (e.g. only a subset implement ReplicatedDatabaseTrigger), or do not implement ReplicatedDatabaseTrigger for a replicated database.

setTriggersVoid

public void setTriggersVoid(List<Trigger> triggers)

getTriggers

public List<Trigger> getTriggers()

setOverrideTriggers

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

setOverrideTriggersVoid

public void setOverrideTriggersVoid(boolean override)

getOverrideTriggers

public boolean getOverrideTriggers()

setTemporary

public DatabaseConfig setTemporary(boolean temporary)
Sets the temporary database option.

Temporary databases operate internally in deferred-write mode to provide reduced disk I/O and increased concurrency. But unlike an ordinary deferred-write database, the information in a temporary database is not durable or persistent.

A temporary database is not flushed to disk when the database is closed or when a checkpoint is performed, and the Database.sync method may not be called. When all handles for a temporary database are closed, the database is automatically removed. If a crash occurs before closing a temporary database, the database will be automatically removed when the environment is re-opened.

Note that although temporary databases can page to disk if the cache is not large enough to hold the databases, they are much more efficient if the database remains in memory. See the JE FAQ on the Oracle Technology Network site for information on how to estimate the cache size needed by a given database.

See the Getting Started Guide, Database chapter for a full description of temporary databases.

Parameters:
temporary - if true, the database will be opened as a temporary database.
Returns:
this

setTemporaryVoid

public void setTemporaryVoid(boolean temporary)

getTemporary

public boolean getTemporary()
Returns the temporary database option.

Returns:
boolean if true, the database is temporary.

setDeferredWrite

public DatabaseConfig setDeferredWrite(boolean deferredWrite)
Sets the deferred-write option.

Deferred-write databases have reduced disk I/O and improved concurrency. Disk I/O is reduced when data records are frequently modified or deleted. The information in a deferred-write database is not guaranteed to be durable or persistent until Database.close() or Database.sync() is called, or a checkpoint is performed. Since the usual write ahead logging system is relaxed in order to improve performance, if the environment crashes before a Database.sync() or Database.close(), none, all, or a unpredictable set of the operations previously done may be persistent.

After a deferred-write database is closed it may be re-opened as an ordinary transactional or non-transactional database. For example, this can be used to initially load a large data set in deferred-write mode and then switch to transactional mode for subsequent operations.

Note that although deferred-write databases can page to disk if the cache is not large enough to hold the databases, they are much more efficient if the database remains in memory. See the JE FAQ on the Oracle Technology Network site for information on how to estimate the cache size needed by a given database.

See the Getting Started Guide, Database chapter for a full description of deferred-write databases.

Parameters:
deferredWrite - if true, the database will be opened as a deferred-write database.
Returns:
this

setDeferredWriteVoid

public void setDeferredWriteVoid(boolean deferredWrite)

getDeferredWrite

public boolean getDeferredWrite()
Returns the deferred-write option.

Returns:
boolean if true, deferred-write is enabled.

setBtreeComparatorInternal

void setBtreeComparatorInternal(Comparator<byte[]> comparator,
                                boolean byClassName)
Used to set the comparator when filling in a configuration from an existing database.


setDuplicateComparatorInternal

void setDuplicateComparatorInternal(Comparator<byte[]> comparator,
                                    boolean byClassName)
Used to set the comparator when filling in a configuration from an existing database.


setUseExistingConfig

public DatabaseConfig setUseExistingConfig(boolean useExistingConfig)
Setting useExistingConfig to true allows a program to open a database without knowing a prior what its configuration is. For example, if you want to open a database without knowing whether it contains sorted duplicates or not, you can set this property to true. In general, this is used by the JE utilities, to avoid having to know the configuration of a database. The databases should be opened readOnly when this property is set to true.

Parameters:
useExistingConfig - true if this Database should be opened using the existing configuration.
Returns:
this

setUseExistingConfigVoid

public void setUseExistingConfigVoid(boolean useExistingConfig)

getUseExistingConfig

public boolean getUseExistingConfig()
Return the value of the useExistingConfig property.

Returns:
the value of the useExistingConfig property.

setCacheMode

public DatabaseConfig setCacheMode(CacheMode cacheMode)
Sets the default CacheMode used for operations performed on this database. If this property is non-null, it overrides the default specified using EnvironmentMutableConfig.setCacheMode(com.sleepycat.je.CacheMode) for operations on this database. The default cache mode may be overridden on a per-record or per-operation basis using Cursor.setCacheMode(com.sleepycat.je.CacheMode).

Parameters:
cacheMode - is the default CacheMode used for operations performed on this database. If null is specified, the environment default will be used.
Since:
4.0.97
See Also:
for further details.

setCacheModeVoid

public void setCacheModeVoid(CacheMode cacheMode)

getCacheMode

public CacheMode getCacheMode()
Returns the default CacheMode used for operations performed on this database, or null if the environment default is used.

Returns:
the default CacheMode used for operations performed on this database, or null if the environment default is used.
Since:
4.0.97
See Also:
setCacheMode(com.sleepycat.je.CacheMode)

setCacheModeStrategy

public DatabaseConfig setCacheModeStrategy(CacheModeStrategy strategy)
Parameters:
strategy - is the CacheModeStrategy used for operations performed on this database. If null is specified, the environment default will be used.
Since:
4.0.97
See Also:
for further details.

setCacheModeStrategyVoid

public void setCacheModeStrategyVoid(CacheModeStrategy strategy)

getCacheModeStrategy

public CacheModeStrategy getCacheModeStrategy()
Returns:
the default CacheModeStrategy used for operations performed on this database, or null if the environment default is used.
Since:
4.0.97
See Also:
setCacheModeStrategy(com.sleepycat.je.CacheModeStrategy)

setReplicated

void setReplicated(boolean replicated)
For internal use only.


getReplicated

boolean getReplicated()
For internal use only.


cloneConfig

public DatabaseConfig cloneConfig()
Deprecated. As of JE 4.0.13, replaced by clone().

Returns a copy of this configuration object.


clone

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

Overrides:
clone in class Object

validate

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

Throws:
IllegalArgumentException - via JEConnection.openDatabase.
DatabaseException

validateForNewDb

void validateForNewDb()
                throws DatabaseException
Checks that this database configuration is valid for a new, non-existant database.

Throws:
IllegalArgumentException - via Environment.openDatabase and openSecondaryDatabase
DatabaseException

persistentEquals

boolean persistentEquals(DatabaseConfig other)
For unit tests, checks that the database configuration attributes that are saved persistently are equal.


validateOnDbOpen

void validateOnDbOpen(String databaseName,
                      boolean dbIsReplicated)
Perform validations at database open time on the completed DbConfig object. Inter-attribute checks are done here.


checkTriggers

boolean checkTriggers(List<Trigger> triggerList)
Checks that the triggers in the list have consistent definitions.

Parameters:
triggerList - the list of triggers to be checked
Returns:
true if the list consists of just replicated triggers, false if it consists entirely of non-replicated triggers.
Throws:
IllegalArgumentException - if the list had triggers with duplicate names or the types were not consistent.

combineConfig

static DatabaseConfig combineConfig(DatabaseImpl dbImpl,
                                    DatabaseConfig dbHandleConfig)
Combine the per-Database handle and Database-wide properties for a database handle.

Parameters:
dbImpl - the underlying DatabaseImpl for a database handle, which provides the Database-wide properties
dbHandleConfig - DatabaseConfig field for the same database handle, which provides the per-Database properties.
Returns:
a DatabaseConfig which includes the correct Database-wide and per-Database handle properties.

toString

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

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


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