Class DatabaseConfig
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
SecondaryConfig
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DatabaseConfigAn instance created using the default constructor is initialized with the system's default settings. -
Constructor Summary
ConstructorsConstructorDescriptionAn instance created using the default constructor is initialized with the system's default settings. -
Method Summary
Modifier and TypeMethodDescriptionReturns a copy of this configuration object.booleanReturn true if theEnvironment.openDatabasemethod is configured to create the database if it does not already exist.Return the custom Comparator used for btree keys.Get the Btree compression callbacks.intReturn the minimum number of key/data pairs intended to be stored on any single Btree leaf page.Return the Btree prefix callback.booleanReturn true if the Btree is configured to support retrieval by record number.intReturn the database byte order; a byte order of 4,321 indicates a big endian order, and a byte order of 1,234 indicates a little endian order.booleanReturn if the underlying database files were created on an architecture of the same byte order as the current one.intReturn the number of shared memory buffer pools, that is, the number of caches.longReturn the size of the shared memory buffer pool, that is, the cache.booleanReturn true if the database environment is configured to do checksum verification of pages read into the cache from the backing filestore.Return the directory a database will/has been created in or looked for.booleanDeprecated.Return the duplicate data item comparison callback.booleanReturn true if the database has been configured to perform encryption.Return the function to be called if an error occurs.Return the prefix string that appears before error messages.Return the an OutputStream for displaying error messages.booleanReturn true if theEnvironment.openDatabasemethod is configured to fail if the database already exists.Return the object's methods to be called to provide feedback.Return the Comparator used to compare keys in a Hash database.Return the database-specific hash function.intReturn the hash table density.intReturn the estimate of the final size of the hash table.longReturn the number of pages in a region of the database.longReturn the maximum on-disk database file size.Return the function to be called with an informational message.Return the an OutputStream for displaying informational messages.longgetMode()Return the mode used to create files.booleanReturn true if the database is configured for multiversion concurrency control.booleanReturn true if the library is configured to not map this database into memory.Return whether theDatabasehandle is configured to obtain a write lock on the entire database.intReturn the size of the pages used to hold items in the database, in bytes.Return the function to be called if the database environment panics.File[]Return the array of directories the database extents should be created in or looked for.Return the function to be called to determine which partition a key resides in.Return the array of keys the database is configured to partition with.intReturn the number of partitions the database is configured for.Return the the cache priority for pages referenced by this handle.intReturn the size of the extents used to hold pages in a Queue database, specified as a number of pages.booleanReturn true if theDatabase.consumemethod is configured to return key/data pairs in order, always returning the key/data item from the head of the queue.booleanReturn true if the database is configured in read-only mode.booleanReturn true if the database is configured to support read uncommitted.intReturn the delimiting byte used to mark the end of a record in the backing source file for the Recno access method.intReturn the database record length, in bytes.Return the function to call after the record number has been selected but before the data has been stored into the database.intReturn the padding character for short, fixed-length records for the Queue and Recno access methods.Return the name of an underlying flat text database file that is read to initialize a transient record number index.booleanReturn true if the logical record numbers are mutable, and change as records are added to and deleted from the database.booleanReturn true if the Btree has been configured to not do reverse splits.booleanReturn true if the any specified backing source file will be read in its entirety when the database is opened.booleanReturn true if the database is configured to support sorted duplicate data items.booleanReturn true if the database open is enclosed within a transaction.booleanReturn true if the database environment is configured to not write log records for this database.booleanReturn true if the database has been configured to be physically truncated by truncating the underlying file, discarding all previous databases it might have held.getType()Return the type of the database.booleanReturn true if the database is configured to support duplicate data items.voidsetAllowCreate(boolean allowCreate) Configure theEnvironment.openDatabasemethod to create the database if it does not already exist.voidsetBtreeComparator(Comparator btreeComparator) By default, a byte by byte lexicographic comparison is used for btree keys.voidsetBtreeCompressor(BtreeCompressor btreeCompressor) Set the Btree compression callbacks.voidsetBtreeMinKey(int btMinKey) Set the minimum number of key/data pairs intended to be stored on any single Btree leaf page.voidsetBtreePrefixCalculator(BtreePrefixCalculator btreePrefixCalculator) Set the Btree prefix callback.voidsetBtreeRecordNumbers(boolean btreeRecordNumbers) Configure the Btree to support retrieval by record number.voidsetByteOrder(int byteOrder) Set the byte order for integers in the stored database metadata.voidsetCacheCount(int cacheCount) Set the number of shared memory buffer pools, that is, the number of caches.voidsetCacheSize(long cacheSize) Set the size of the shared memory buffer pool, that is, the size of the cache.voidsetChecksum(boolean checksum) Configure the database environment to do checksum verification of pages read into the cache from the backing filestore.voidsetCreateDir(File createDir) Specify which directory a database should be created in or looked for.voidsetDirtyRead(boolean dirtyRead) Deprecated.This has been replaced bysetReadUncommitted(boolean)to conform to ANSI database isolation terminology.voidsetDuplicateComparator(Comparator duplicateComparator) Set the duplicate data item comparison callback.voidsetEncrypted(String password) Set the password used to perform encryption and decryption.voidsetErrorHandler(ErrorHandler errorHandler) Set the function to be called if an error occurs.voidsetErrorPrefix(String errorPrefix) Set the prefix string that appears before error messages.voidsetErrorStream(OutputStream errorStream) Set an OutputStream for displaying error messages.voidsetExclusiveCreate(boolean exclusiveCreate) Configure theEnvironment.openDatabasemethod to fail if the database already exists.voidsetFeedbackHandler(FeedbackHandler feedbackHandler) Set an object whose methods are called to provide feedback.voidsetHashComparator(Comparator hashComparator) Set the Hash key comparison function.voidSet a database-specific hash function.voidsetHashFillFactor(int hashFillFactor) Set the desired density within the hash table.voidsetHashNumElements(int hashNumElements) Set an estimate of the final size of the hash table.voidsetHeapRegionSize(int npages) Sets the number of pages in a region of a database configured to use the Heap access method.voidsetHeapsize(long bytes) Set the maximum on-disk database file size used by a database configured to use the Heap access method.voidsetMessageHandler(MessageHandler messageHandler) Set a function to be called with an informational message.voidsetMessageStream(OutputStream messageStream) Set an OutputStream for displaying informational messages.voidsetMode(int mode) On UNIX systems or in IEEE/ANSI Std 1003.1 (POSIX) environments, files created by the database open are created with modemode(as described in thechmod(2) manual page) and modified by the process' umask value at the time of creation (see theumask(2) manual page).voidsetMultiversion(boolean multiversion) Configured the database with support for multiversion concurrency control.voidsetNoMMap(boolean noMMap) Configure the library to not map this database into memory.voidsetNoWaitDbExclusiveLock(Boolean noWaitDbExclLock) Configure theDatabasehandle to obtain a write lock on the entire database.voidsetPageSize(int pageSize) Set the size of the pages used to hold items in the database, in bytes.voidsetPanicHandler(PanicHandler panicHandler) Set the function to be called if the database environment panics.voidsetPartitionByCallback(int parts, PartitionHandler partitionHandler) Enable or disable database partitioning, and set the callback that will be used for the partitioning.voidsetPartitionByRange(int parts, MultipleDataEntry keys) Enable or disable database partitioning, and set key ranges that will be used for the partitioning.voidsetPartitionDirs(File[] dirs) Specify the array of directories the database extents should be created in or looked for.voidsetPriority(CacheFilePriority priority) Set the cache priority for pages referenced by the DB handle.voidsetQueueExtentSize(int queueExtentSize) Set the size of the extents used to hold pages in a Queue database, specified as a number of pages.voidsetQueueInOrder(boolean queueInOrder) ConfigureDatabase.consumeto return key/data pairs in order, always returning the key/data item from the head of the queue.voidsetReadOnly(boolean readOnly) Configure the database in read-only mode.voidsetReadUncommitted(boolean readUncommitted) Configure the database to support read uncommitted.voidsetRecordDelimiter(int recordDelimiter) Set the delimiting byte used to mark the end of a record in the backing source file for the Recno access method.voidsetRecordLength(int recordLength) Specify the database record length, in bytes.voidsetRecordNumberAppender(RecordNumberAppender recnoAppender) ConfigureDatabase.appendto call the function after the record number has been selected but before the data has been stored into the database.voidsetRecordPad(int recordPad) Set the padding character for short, fixed-length records for the Queue and Recno access methods.voidsetRecordSource(File recordSource) Set the underlying source file for the Recno access method.voidsetRenumbering(boolean renumbering) Configure the logical record numbers to be mutable, and change as records are added to and deleted from the database.voidsetReverseSplitOff(boolean reverseSplitOff) Configure the Btree to not do reverse splits.voidsetSnapshot(boolean snapshot) Specify that any specified backing source file be read in its entirety when the database is opened.voidsetSortedDuplicates(boolean sortedDuplicates) Configure the database to support sorted, duplicate data items.voidsetTransactional(boolean transactional) Enclose the database open within a transaction.voidsetTransactionNotDurable(boolean transactionNotDurable) Configure the database environment to not write log records for this database.voidsetTruncate(boolean truncate) Configure the database to be physically truncated by truncating the underlying file, discarding all previous databases it might have held.voidsetType(DatabaseType type) Configure the type of the database.voidsetUnsortedDuplicates(boolean unsortedDuplicates) Configure the database to support unsorted duplicate data items.
-
Field Details
-
DEFAULT
An instance created using the default constructor is initialized with the system's default settings.
-
-
Constructor Details
-
DatabaseConfig
public DatabaseConfig()An instance created using the default constructor is initialized with the system's default settings.
-
-
Method Details
-
cloneConfig
Returns a copy of this configuration object. -
setAllowCreate
public void setAllowCreate(boolean allowCreate) Configure theEnvironment.openDatabasemethod to create the database if it does not already exist.- Parameters:
allowCreate- If true, configure theEnvironment.openDatabasemethod to create the database if it does not already exist.
-
getAllowCreate
public boolean getAllowCreate()Return true if theEnvironment.openDatabasemethod 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.openDatabasemethod is configured to create the database if it does not already exist.
-
setBtreeComparator
By default, a byte by byte lexicographic comparison is used for btree keys. To customize the comparison, supply a different Comparator.The
comparemethod is passed the byte arrays representing keys 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. -
getBtreeComparator
Return the custom Comparator used for btree keys.- Returns:
- the custom Comparator used for btree keys, or null if the default comparison function will be used.
-
setBtreeMinKey
public void setBtreeMinKey(int btMinKey) Set the minimum number of key/data pairs intended to be stored on any single Btree leaf page.This value is used to determine if key or data items will be stored on overflow pages instead of Btree leaf pages. The value must be at least 2; if the value is not explicitly set, a value of 2 is used.
This method configures a database, not only operations performed using the specified
Databasehandle.This method may not be called after the database is opened. If the database already exists when it is opened, the information specified to this method will be ignored.
- Parameters:
btMinKey- The minimum number of key/data pairs intended to be stored on any single Btree leaf page.
-
getBtreeMinKey
public int getBtreeMinKey()Return the minimum number of key/data pairs intended to be stored on any single Btree leaf page.This method may be called at any time during the life of the application.
- Returns:
- The minimum number of key/data pairs intended to be stored on any single Btree leaf page.
-
setByteOrder
public void setByteOrder(int byteOrder) Set the byte order for integers in the stored database metadata.The host byte order of the machine where the process is running will be used if no byte order is set.
The access methods provide no guarantees about the byte ordering of the application data stored in the database, and applications are responsible for maintaining any necessary ordering.
This method configures a database, not only operations performed using the specified
Databasehandle.This method may not be called after the database is opened. If the database already exists when it is opened, the information specified to this method will be ignored. If creating additional databases in a single physical file, information specified to this method will be ignored and the byte order of the existing databases will be used.
- Parameters:
byteOrder- The byte order as an integer; for example, big endian order is the number 4,321, and little endian order is the number 1,234.
-
getByteOrder
public int getByteOrder()Return the database byte order; a byte order of 4,321 indicates a big endian order, and a byte order of 1,234 indicates a little endian order.This method may be called at any time during the life of the application.
- Returns:
- The database byte order; a byte order of 4,321 indicates a big endian order, and a byte order of 1,234 indicates a little endian order.
-
getByteSwapped
public boolean getByteSwapped()Return if the underlying database files were created on an architecture of the same byte order as the current one.This information may be used to determine whether application data needs to be adjusted for this architecture or not.
This method may not be called before the database has been opened.
- Returns:
- Return false if the underlying database files were created on an architecture of the same byte order as the current one, and true if they were not (that is, big-endian on a little-endian machine, or vice versa).
-
setBtreeCompressor
Set the Btree compression callbacks. -
getBtreeCompressor
Get the Btree compression callbacks. -
setBtreePrefixCalculator
Set the Btree prefix callback. The prefix callback is used to determine the amount by which keys stored on the Btree internal pages can be safely truncated without losing their uniqueness. See the Btree prefix comparison section of the Berkeley DB Reference Guide for more details about how this works. The usefulness of this is data-dependent, but can produce significantly reduced tree sizes and search times in some data sets.If no prefix callback or key comparison callback is specified by the application, a default lexical comparison function is used to calculate prefixes. If no prefix callback is specified and a key comparison callback is specified, no prefix function is used. It is an error to specify a prefix function without also specifying a Btree key comparison function.
-
getBtreePrefixCalculator
Return the Btree prefix callback.This method may be called at any time during the life of the application.
- Returns:
- The Btree prefix callback.
-
setCacheSize
public void setCacheSize(long cacheSize) Set the size of the shared memory buffer pool, that is, the size of the cache.The cache should be the size of the normal working data set of the application, with some small amount of additional memory for unusual situations. (Note: the working set is not the same as the number of pages accessed simultaneously, and is usually much larger.)
The default cache size is 256KB, and may not be specified as less than 20KB. Any cache size less than 500MB is automatically increased by 25% to account for buffer pool overhead; cache sizes larger than 500MB are used as specified. The current maximum size of a single cache is 4GB. (All sizes are in powers-of-two, that is, 256KB is 2^18 not 256,000.)
Because databases opened within database environments use the cache specified to the environment, it is an error to attempt to configure a cache size in a database created within an environment.
This method may not be called after the database is opened.
This method may be called at any time during the life of the application.
- Parameters:
cacheSize- The size of the shared memory buffer pool, that is, the size of the cache.- Throws:
DatabaseException- if a failure occurs.
-
getCacheSize
public long getCacheSize()Return the size of the shared memory buffer pool, that is, the cache.This method may be called at any time during the life of the application.
- Returns:
- The size of the shared memory buffer pool, that is, the cache.
-
setCreateDir
Specify which directory a database should be created in or looked for.- Parameters:
createDir- The directory will be used to create or locate the database file specified in the openDatabase method call. The directory must be one of the directories in the environment list specified by EnvironmentConfig.addDataDirectory.- Throws:
DatabaseException- if a failure occurs.
-
getCreateDir
Return the directory a database will/has been created in or looked for.This method may be called at any time during the life of the application.
- Returns:
- The directory a database will/has been created in or looked for.
-
setCacheCount
public void setCacheCount(int cacheCount) Set the number of shared memory buffer pools, that is, the number of caches.It is possible to specify caches larger than 4GB and/or large enough they cannot be allocated contiguously on some architectures. For example, some releases of Solaris limit the amount of memory that may be allocated contiguously by a process. This method allows applications to break the cache broken up into a number of equally sized, separate pieces of memory.
Because databases opened within database environments use the cache specified to the environment, it is an error to attempt to configure multiple caches in a database created within an environment.
This method may not be called after the database is opened.
This method may be called at any time during the life of the application.
- Parameters:
cacheCount- The number of shared memory buffer pools, that is, the number of caches.- Throws:
DatabaseException- if a failure occurs.
-
getCacheCount
public int getCacheCount()Return the number of shared memory buffer pools, that is, the number of caches.This method may be called at any time during the life of the application.
- Returns:
- The number of shared memory buffer pools, that is, the number of caches.
-
setChecksum
public void setChecksum(boolean checksum) Configure the database environment to do checksum verification of pages read into the cache from the backing filestore.Berkeley DB uses the SHA1 Secure Hash Algorithm if encryption is also configured for this database, and a general hash algorithm if it is not.
Calling this method only affects the specified
Databasehandle (and any other library handles opened within the scope of that handle).If the database already exists when the database is opened, any database configuration specified by this method will be ignored. If creating additional databases in a file, the checksum behavior specified must be consistent with the existing databases in the file or an error will be returned.
- Parameters:
checksum- If true, configure the database environment to do checksum verification of pages read into the cache from the backing filestore. A value of false is illegal to this method, that is, once set, the configuration cannot be cleared.
-
getChecksum
public boolean getChecksum()Return true if the database environment is configured to do checksum verification of pages read into the cache from the backing filestore.This method may be called at any time during the life of the application.
- Returns:
- True if the database environment is configured to do checksum verification of pages read into the cache from the backing filestore.
-
setReadUncommitted
public void setReadUncommitted(boolean readUncommitted) Configure the database to support read uncommitted.Read operations on the database may request the return of modified but not yet committed data. This flag must be specified on all
Databasehandles used to perform read uncommitted or database updates, otherwise requests for read uncommitted may not be honored and the read may block.- Parameters:
readUncommitted- If true, configure the database to support read uncommitted.
-
getReadUncommitted
public boolean getReadUncommitted()Return true if the database is configured to support read uncommitted.This method may be called at any time during the life of the application.
- Returns:
- True if the database is configured to support read uncommitted.
-
setDirtyRead
public void setDirtyRead(boolean dirtyRead) Deprecated.This has been replaced bysetReadUncommitted(boolean)to conform to ANSI database isolation terminology.Configure the database to support read uncommitted.Read operations on the database may request the return of modified but not yet committed data. This flag must be specified on all
Databasehandles used to perform read uncommitted or database updates, otherwise requests for read uncommitted may not be honored and the read may block.- Parameters:
dirtyRead- If true, configure the database to support read uncommitted.
-
getDirtyRead
public boolean getDirtyRead()Deprecated.This has been replaced bygetReadUncommitted()to conform to ANSI database isolation terminology.Return true if the database is configured to support read uncommitted.This method may be called at any time during the life of the application.
- Returns:
- True if the database is configured to support read uncommitted.
-
setDuplicateComparator
Set the duplicate data item comparison callback. The comparison function is called whenever it is necessary to compare a data item specified by the application with a data item currently stored in the database. This comparator is only used ifDatabaseConfig.setSortedDuplicatesis also configured.If no comparison function is specified, the data items are compared lexically, with shorter data items collating before longer data items.
The
comparemethod is passed the byte arrays representing data items 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.- Parameters:
duplicateComparator- the comparison callback for duplicate data items.
-
getDuplicateComparator
Return the duplicate data item comparison callback.- Returns:
- the duplicate data item Comparator, or null if the default Comparator will be used.
-
setEncrypted
Set the password used to perform encryption and decryption.Because databases opened within environments use the password specified to the environment, it is an error to attempt to set a password in a database created within an environment.
Berkeley DB uses the Rijndael/AES (also known as the Advanced Encryption Standard and Federal Information Processing Standard (FIPS) 197) algorithm for encryption or decryption.
-
getEncrypted
public boolean getEncrypted()Return true if the database has been configured to perform encryption.This method may be called at any time during the life of the application.
- Returns:
- True if the database has been configured to perform encryption.
-
setErrorHandler
Set the function to be called if an error occurs.When an error occurs in the Berkeley DB library, an exception is thrown. In some cases, however, the error information returned to the application may be insufficient to completely describe the cause of the error, especially during initial application debugging.
The
EnvironmentConfig.setErrorHandlerandDatabaseConfig.setErrorHandlermethods are used to enhance the mechanism for reporting error messages to the application. In some cases, when an error occurs, Berkeley DB will invoke the ErrorHandler's object error method. It is up to this method to display the error message in an appropriate manner.Alternatively, applications can use
EnvironmentConfig.setErrorStreamandDatabaseConfig.setErrorStreamto display the additional information via an output stream. Applications should not mix these approaches.This error-logging enhancement does not slow performance or significantly increase application size, and may be run during normal operation as well as during application debugging.
For
Databasehandles opened inside of database environments, calling this method affects the entire environment and is equivalent to callingEnvironmentConfig.setErrorHandler.This method may be called at any time during the life of the application.
- Parameters:
errorHandler- The function to be called if an error occurs.
-
getErrorHandler
Return the function to be called if an error occurs.This method may be called at any time during the life of the application.
- Returns:
- The function to be called if an error occurs.
-
setErrorPrefix
Set the prefix string that appears before error messages.For
Databasehandles opened inside of database environments, calling this method affects the entire environment and is equivalent to callingEnvironmentConfig.setErrorPrefix.This method may be called at any time during the life of the application.
- Parameters:
errorPrefix- The prefix string that appears before error messages.
-
getErrorPrefix
Return the prefix string that appears before error messages.This method may be called at any time during the life of the application.
- Returns:
- The prefix string that appears before error messages.
-
setErrorStream
Set an OutputStream for displaying error messages.When an error occurs in the Berkeley DB library, an exception is thrown. In some cases, however, the error information returned to the application may be insufficient to completely describe the cause of the error, especially during initial application debugging.
The
EnvironmentConfig.setErrorStreamandDatabaseConfig.setErrorStreammethods are used to enhance the mechanism for reporting error messages to the application by setting a OutputStream to be used for displaying additional Berkeley DB error messages. In some cases, when an error occurs, Berkeley DB will output an additional error message to the specified stream.The error message will consist of the prefix string and a colon (":") (if a prefix string was previously specified using
EnvironmentConfig.setErrorPrefixorDatabaseConfig.setErrorPrefix), an error string, and a trailing newline character.Setting errorStream to null unconfigures the interface.
Alternatively, applications can use
EnvironmentConfig.setErrorHandlerandDatabaseConfig.setErrorHandlerto capture the additional error information in a way that does not use output streams. Applications should not mix these approaches.This error-logging enhancement does not slow performance or significantly increase application size, and may be run during normal operation as well as during application debugging.
This method may be called at any time during the life of the application.
- Parameters:
errorStream- The application-specified OutputStream for error messages.
-
getErrorStream
Return the an OutputStream for displaying error messages.This method may be called at any time during the life of the application.
- Returns:
- The an OutputStream for displaying error messages.
-
setExclusiveCreate
public void setExclusiveCreate(boolean exclusiveCreate) Configure theEnvironment.openDatabasemethod to fail if the database already exists.The exclusiveCreate mode is only meaningful if specified with the allowCreate mode.
- Parameters:
exclusiveCreate- If true, configure theEnvironment.openDatabasemethod to fail if the database already exists.
-
getExclusiveCreate
public boolean getExclusiveCreate()Return true if theEnvironment.openDatabasemethod 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.openDatabasemethod is configured to fail if the database already exists.
-
setFeedbackHandler
Set an object whose methods are called to provide feedback.Some operations performed by the Berkeley DB library can take non-trivial amounts of time. This method can be used by applications to monitor progress within these operations. When an operation is likely to take a long time, Berkeley DB will call the object's methods with progress information.
It is up to the object's methods to display this information in an appropriate manner.
This method configures only operations performed using a single a
EnvironmenthandleThis method may be called at any time during the life of the application.
- Parameters:
feedbackHandler- An object whose methods are called to provide feedback.
-
getFeedbackHandler
Return the object's methods to be called to provide feedback.This method may be called at any time during the life of the application.
- Returns:
- The object's methods to be called to provide feedback.
-
setHashFillFactor
public void setHashFillFactor(int hashFillFactor) Set the desired density within the hash table.If no value is specified, the fill factor will be selected dynamically as pages are filled.
The density is an approximation of the number of keys allowed to accumulate in any one bucket, determining when the hash table grows or shrinks. If you know the average sizes of the keys and data in your data set, setting the fill factor can enhance performance. A reasonable rule computing fill factor is to set it to the following:
(pagesize - 32) / (average_key_size + average_data_size + 8)This method configures a database, not only operations performed using the specified
Databasehandle.This method may not be called after the database is opened. If the database already exists when it is opened, the information specified to this method will be ignored.
- Parameters:
hashFillFactor- The desired density within the hash table.
-
getHashFillFactor
public int getHashFillFactor()Return the hash table density.This method may be called at any time during the life of the application.
- Returns:
- The hash table density.
-
setHashComparator
Set the Hash key comparison function. The comparison function is called whenever it is necessary to compare a key specified by the application with a key currently stored in the database.If no comparison function is specified, a byte-by-byte comparison is performed.
The
comparemethod is passed the byte arrays representing keys 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. -
getHashComparator
Return the Comparator used to compare keys in a Hash database.This method may be called at any time during the life of the application.
- Returns:
- The Comparator used to compare keys in a Hash database.
-
setHasher
Set a database-specific hash function.If no hash function is specified, a default hash function is used. Because no hash function performs equally well on all possible data, the user may find that the built-in hash function performs poorly with a particular data set.
This method configures operations performed using the specified
Databaseobject, not all operations performed on the underlying database.This method may not be called after the database is opened. If the database already exists when it is opened, the information specified to this method must be the same as that historically used to create the database or corruption can occur.
- Parameters:
hasher- A database-specific hash function.
-
getHasher
Return the database-specific hash function.This method may be called at any time during the life of the application.
- Returns:
- The database-specific hash function.
-
setHashNumElements
public void setHashNumElements(int hashNumElements) Set an estimate of the final size of the hash table.In order for the estimate to be used when creating the database, the
DatabaseConfig.setHashFillFactormethod must also be called. If the estimate or fill factor are not set or are set too low, hash tables will still expand gracefully as keys are entered, although a slight performance degradation may be noticed.This method configures a database, not only operations performed using the specified
Databasehandle.This method may not be called after the database is opened. If the database already exists when it is opened, the information specified to this method will be ignored.
- Parameters:
hashNumElements- An estimate of the final size of the hash table.
-
getHashNumElements
public int getHashNumElements()Return the estimate of the final size of the hash table.This method may be called at any time during the life of the application.
- Returns:
- The estimate of the final size of the hash table.
-
setHeapsize
public void setHeapsize(long bytes) Set the maximum on-disk database file size used by a database configured to use the Heap access method. If this method is never called, the database's file size can grow without bound. If this method is called, then the heap file can never grow larger than the limit defined by this method. In that case, attempts to update or create records in a Heap database that has reached its maximum size will throw aHeapFullException.The size specified to this method must be at least three times the database page size. That is, a Heap database must contain at least three database pages. You can set the database page size using
setPageSize(int).This method may not be called after the database is opened. Further, if this method is called on an existing Heap database, the size specified here must match the size used to create the database. Note, however, that specifying an incorrect size to this method will not result in an error return until the database is opened.
- Parameters:
bytes- The maximum on-disk database file size.
-
getHeapsize
public long getHeapsize()Return the maximum on-disk database file size.This method may be called at any time during the life of the application.
- Returns:
- The maximum on-disk database file size.
-
setHeapRegionSize
public void setHeapRegionSize(int npages) Sets the number of pages in a region of a database configured to use the Heap access method. If this method is never called, the default region size for the database's page size will be used. You can set the database page size usingsetPageSize(int).This method may not be called after the database is opened. Further, if this method is called on an existing Heap database, the value specified here will be ignored. If the specified region size is larger than the maximum region size for the database's page size, an error will be returned when the database is opened. The maximum allowable region size will be included in the error message.
- Parameters:
npages- The size of the region, in pages.
-
getHeapRegionSize
public long getHeapRegionSize()Return the number of pages in a region of the database.This method may be called at any time during the life of the application.
- Returns:
- The size of the region, in pages.
-
setMessageHandler
Set a function to be called with an informational message.There are interfaces in the Berkeley DB library which either directly output informational messages or statistical information, or configure the library to output such messages when performing other operations,
EnvironmentConfig.setVerboseDeadlockfor example.The
EnvironmentConfig.setMessageHandlerandDatabaseConfig.setMessageHandlermethods are used to display these messages for the application.Setting messageHandler to null unconfigures the interface.
Alternatively, you can use
EnvironmentConfig.setMessageStreamandDatabaseConfig.setMessageStreamto send the additional information directly to an output streams. You should not mix these approaches.For
Databasehandles opened inside of database environments, calling this method affects the entire environment and is equivalent to callingEnvironmentConfig.setMessageHandler.This method may be called at any time during the life of the application.
- Parameters:
messageHandler- The application-specified function for informational messages.
-
getMessageHandler
Return the function to be called with an informational message.This method may be called at any time during the life of the application.
- Returns:
- The function to be called with an informational message.
-
setMessageStream
Set an OutputStream for displaying informational messages.There are interfaces in the Berkeley DB library which either directly output informational messages or statistical information, or configure the library to output such messages when performing other operations,
EnvironmentConfig.setVerboseDeadlockfor example.The
EnvironmentConfig.setMessageStreamandDatabaseConfig.setMessageStreammethods are used to display these messages for the application. In this case, the message will include a trailing newline character.Setting messageStream to null unconfigures the interface.
Alternatively, you can use
EnvironmentConfig.setMessageHandlerandDatabaseConfig.setMessageHandlerto capture the additional information in a way that does not use output streams. You should not mix these approaches.For
Databasehandles opened inside of database environments, calling this method affects the entire environment and is equivalent to callingEnvironmentConfig.setMessageStream.This method may be called at any time during the life of the application.
- Parameters:
messageStream- The application-specified OutputStream for informational messages.
-
getMessageStream
Return the an OutputStream for displaying informational messages.This method may be called at any time during the life of the application.
- Returns:
- The an OutputStream for displaying informational messages.
-
setMode
public void setMode(int mode) On UNIX systems or in IEEE/ANSI Std 1003.1 (POSIX) environments, files created by the database open are created with modemode(as described in thechmod(2) manual page) and modified by the process' umask value at the time of creation (see theumask(2) manual page). Created files are owned by the process owner; the group ownership of created files is based on the system and directory defaults, and is not further specified by Berkeley DB. System shared memory segments created by the database open are created with modemode, unmodified by the process' umask value. Ifmodeis 0, the database open will use a default mode of readable and writable by both owner and group.On Windows systems, the mode parameter is ignored.
- Parameters:
mode- the mode used to create files
-
getMode
public long getMode()Return the mode used to create files.This method may be called at any time during the life of the application.
- Returns:
- The mode used to create files.
-
setMultiversion
public void setMultiversion(boolean multiversion) Configured the database with support for multiversion concurrency control. This will cause updates to the database to follow a copy-on-write protocol, which is required to support Snapshot Isolation. SeeTransactionConfig.setSnapshot(boolean)) for more information. Multiversion access requires that the database be opened in a transaction and is not supported for queue databases.- Parameters:
multiversion- If true, configure the database with support for multiversion concurrency control.
-
getMultiversion
public boolean getMultiversion()Return true if the database is configured for multiversion concurrency control.This method may be called at any time during the life of the application.
- Returns:
- True if the database is configured for multiversion concurrency control.
-
setNoMMap
public void setNoMMap(boolean noMMap) Configure the library to not map this database into memory.- Parameters:
noMMap- If true, configure the library to not map this database into memory.
-
getNoMMap
public boolean getNoMMap()Return true if the library is configured to not map this database into memory.This method may be called at any time during the life of the application.
- Returns:
- True if the library is configured to not map this database into memory.
-
setNoWaitDbExclusiveLock
Configure theDatabasehandle to obtain a write lock on the entire database.This method may not be called after the database is opened.
- Parameters:
noWaitDbExclLock- If True, configure theDatabasehandle to obtain a write lock on the entire database. When the database is opened it will immediately throwLockNotGrantedExceptionif it cannot obtain the exclusive lock immediately. If False, configure theDatabasehandle to obtain a write lock on the entire database. When the database is opened, it will block until it can obtain the exclusive lock. If null, do not configure theDatabasehandle to obtain a write lock on the entire database.Handles configured for a write lock on the entire database can only have one active transaction at a time.
-
getNoWaitDbExclusiveLock
Return whether theDatabasehandle is configured to obtain a write lock on the entire database.This method may be called at any time during the life of the application.
- Returns:
- True if the
Databasehandle is configured for immediate exclusive database locking. In this case, the locking operation will error out if it cannot immediately obtain an exclusive lock. False if theDatabasehandle is configured for exclusive database locking. In this case, it will block until it can obtain the exclusive database lock when database is opened. Null if theDatabasehandle is not configured for exclusive locking.
-
setPageSize
public void setPageSize(int pageSize) Set the size of the pages used to hold items in the database, in bytes.The minimum page size is 512 bytes, the maximum page size is 64K bytes, and the page size must be a power-of-two. If the page size is not explicitly set, one is selected based on the underlying filesystem I/O block size. The automatically selected size has a lower limit of 512 bytes and an upper limit of 16K bytes.
This method configures a database, not only operations performed using the specified
Databasehandle.This method may not be called after the database is opened. If the database already exists when it is opened, the information specified to this method will be ignored. If creating additional databases in a file, the page size specified must be consistent with the existing databases in the file or an error will be returned.
- Parameters:
pageSize- The size of the pages used to hold items in the database, in bytes.
-
getPageSize
public int getPageSize()Return the size of the pages used to hold items in the database, in bytes.This method may be called at any time during the life of the application.
- Returns:
- The size of the pages used to hold items in the database, in bytes.
-
setPanicHandler
Set the function to be called if the database environment panics.Errors can occur in the Berkeley DB library where the only solution is to shut down the application and run recovery (for example, if Berkeley DB is unable to allocate heap memory). In such cases, the Berkeley DB methods will throw a
RunRecoveryException. It is often easier to simply exit the application when such errors occur rather than gracefully return up the stack. This method specifies a function to be called whenRunRecoveryExceptionis about to be thrown from a Berkeley DB method.For
Databasehandles opened inside of database environments, calling this method affects the entire environment and is equivalent to callingEnvironmentConfig.setPanicHandler.This method may be called at any time during the life of the application.
- Parameters:
panicHandler- The function to be called if the database environment panics.
-
getPanicHandler
Return the function to be called if the database environment panics.This method may be called at any time during the life of the application.
- Returns:
- The function to be called if the database environment panics.
-
setPartitionByCallback
Enable or disable database partitioning, and set the callback that will be used for the partitioning.This method may only be called before opening a database.
- Parameters:
parts- The number of partitions that will be created.partitionHandler- The function to be called to determine which partition a key resides in.
-
setPartitionByRange
Enable or disable database partitioning, and set key ranges that will be used for the partitioning.This method may only be called before opening a database.
- Parameters:
parts- The number of partitions that will be created.keys- A MultipleDatabaseEntry that contains the boundary keys for partitioning.
-
getPartitionHandler
Return the function to be called to determine which partition a key resides in.This method may be called at any time during the life of the application.
- Returns:
- The function to be called to determine which partition a key resides in.
-
getPartitionParts
public int getPartitionParts()Return the number of partitions the database is configured for.This method may be called at any time during the life of the application.
- Returns:
- The number of partitions the database is configured for.
-
getPartitionKeys
Return the array of keys the database is configured to partition with.This method may be called at any time during the life of the application.
- Returns:
- The array of keys the database is configured to partition with.
-
setPartitionDirs
Specify the array of directories the database extents should be created in or looked for. If the number of directories is less than the number of partitions, the directories will be used in a round robin fasion.This method may only be called before the database is opened.
- Parameters:
dirs- The array of directories the database extents should be created in or looked for.
-
getPartitionDirs
Return the array of directories the database extents should be created in or looked for. If the number of directories is less than the number of partitions, the directories will be used in a round robin fasion.This method may be called at any time during the life of the application.
- Returns:
- The array of directories the database extents should be created in or looked for.
-
setPriority
Set the cache priority for pages referenced by the DB handle.The priority of a page biases the replacement algorithm to be more or less likely to discard a page when space is needed in the buffer pool. The bias is temporary, and pages will eventually be discarded if they are not referenced again. The priority setting is only advisory, and does not guarantee pages will be treated in a specific way.
- Parameters:
priority- The desired cache priority.
-
getPriority
Return the the cache priority for pages referenced by this handle.This method may be called at any time during the life of the application.
- Returns:
- The the cache priority for pages referenced by this handle.
-
setQueueExtentSize
public void setQueueExtentSize(int queueExtentSize) Set the size of the extents used to hold pages in a Queue database, specified as a number of pages.Each extent is created as a separate physical file. If no extent size is set, the default behavior is to create only a single underlying database file.
This method configures a database, not only operations performed using the specified
Databasehandle.This method may not be called after the database is opened. If the database already exists when it is opened, the information specified to this method will be ignored.
- Parameters:
queueExtentSize- The number of pages in a Queue database extent.
-
getQueueExtentSize
public int getQueueExtentSize()Return the size of the extents used to hold pages in a Queue database, specified as a number of pages.This method may be called at any time during the life of the application.
- Returns:
- The size of the extents used to hold pages in a Queue database, specified as a number of pages.
-
setQueueInOrder
public void setQueueInOrder(boolean queueInOrder) ConfigureDatabase.consumeto return key/data pairs in order, always returning the key/data item from the head of the queue.The default behavior of queue databases is optimized for multiple readers, and does not guarantee that record will be retrieved in the order they are added to the queue. Specifically, if a writing thread adds multiple records to an empty queue, reading threads may skip some of the initial records when the next call to retrieve a key/data pair returns.
This flag configures the
Database.consumemethod to verify that the record being returned is in fact the head of the queue. This will increase contention and reduce concurrency when there are many reading threads.Calling this method only affects the specified
Databasehandle (and any other library handles opened within the scope of that handle).- Parameters:
queueInOrder- If true, configure theDatabase.consumemethod to return key/data pairs in order, always returning the key/data item from the head of the queue. A value of false is illegal to this method, that is, once set, the configuration cannot be cleared.
-
getQueueInOrder
public boolean getQueueInOrder()Return true if theDatabase.consumemethod is configured to return key/data pairs in order, always returning the key/data item from the head of the queue.This method may be called at any time during the life of the application.
- Returns:
- True if the
Database.consumemethod is configured to return key/data pairs in order, always returning the key/data item from the head of the queue.
-
setReadOnly
public void setReadOnly(boolean readOnly) Configure 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.
-
getReadOnly
public boolean getReadOnly()Return 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.
-
setRecordNumberAppender
ConfigureDatabase.appendto call the function after the record number has been selected but before the data has been stored into the database.This method configures operations performed using the specified
Databaseobject, not all operations performed on the underlying database.This method may not be called after the database is opened.
- Parameters:
recnoAppender- The function to call after the record number has been selected but before the data has been stored into the database.
-
getRecordNumberAppender
Return the function to call after the record number has been selected but before the data has been stored into the database.This method may be called at any time during the life of the application.
- Returns:
- The function to call after the record number has been selected but before the data has been stored into the database.
-
setRecordDelimiter
public void setRecordDelimiter(int recordDelimiter) Set the delimiting byte used to mark the end of a record in the backing source file for the Recno access method.This byte is used for variable length records if a backing source file is specified. If a backing source file is specified and no delimiting byte was specified, newline characters (that is, ASCII 0x0a) are interpreted as end-of-record markers.
This method configures a database, not only operations performed using the specified
Databasehandle.This method may not be called after the database is opened. If the database already exists when it is opened, the information specified to this method will be ignored.
- Parameters:
recordDelimiter- The delimiting byte used to mark the end of a record in the backing source file for the Recno access method.
-
getRecordDelimiter
public int getRecordDelimiter()Return the delimiting byte used to mark the end of a record in the backing source file for the Recno access method.This method may be called at any time during the life of the application.
- Returns:
- The delimiting byte used to mark the end of a record in the backing source file for the Recno access method.
-
setRecordLength
public void setRecordLength(int recordLength) Specify the database record length, in bytes.For the Queue access method, specify the record length. For the Queue access method, the record length must be enough smaller than the database's page size that at least one record plus the database page's metadata information can fit on each database page.
For the Recno access method, specify the records are fixed-length, not byte-delimited, and the record length.
Any records added to the database that are less than the specified length are automatically padded (see
DatabaseConfig.setRecordPadfor more information).Any attempt to insert records into the database that are greater than the specified length will cause the call to fail.
This method configures a database, not only operations performed using the specified
Databasehandle.This method may not be called after the database is opened. If the database already exists when it is opened, the information specified to this method will be ignored.
- Parameters:
recordLength- The database record length, in bytes.
-
getRecordLength
public int getRecordLength()Return the database record length, in bytes.This method may be called at any time during the life of the application.
- Returns:
- The database record length, in bytes.
-
setBtreeRecordNumbers
public void setBtreeRecordNumbers(boolean btreeRecordNumbers) Configure the Btree to support retrieval by record number.Logical record numbers in Btree databases are mutable in the face of record insertion or deletion.
Maintaining record counts within a Btree introduces a serious point of contention, namely the page locations where the record counts are stored. In addition, the entire database must be locked during both insertions and deletions, effectively single-threading the database for those operations. Configuring a Btree for retrieval by record number can result in serious performance degradation for some applications and data sets.
Retrieval by record number may not be configured for a Btree that also supports duplicate data items.
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:
btreeRecordNumbers- If true, configure the Btree to support retrieval by record number. A value of false is illegal to this method, that is, once set, the configuration cannot be cleared.
-
getBtreeRecordNumbers
public boolean getBtreeRecordNumbers()Return true if the Btree is configured to support retrieval by record number.This method may be called at any time during the life of the application.
- Returns:
- True if the Btree is configured to support retrieval by record number.
-
setRecordPad
public void setRecordPad(int recordPad) Set the padding character for short, fixed-length records for the Queue and Recno access methods.If no pad character is specified, "space" characters (that is, ASCII 0x20) are used for padding.
This method configures a database, not only operations performed using the specified
Databasehandle.This method may not be called after the database is opened. If the database already exists when it is opened, the information specified to this method will be ignored.
- Parameters:
recordPad- The padding character for short, fixed-length records for the Queue and Recno access methods.
-
getRecordPad
public int getRecordPad()Return the padding character for short, fixed-length records for the Queue and Recno access methods.This method may be called at any time during the life of the application.
- Returns:
- The padding character for short, fixed-length records for the Queue and Recno access methods.
-
setRecordSource
Set the underlying source file for the Recno access method.The purpose of the source file is to provide fast access and modification to databases that are normally stored as flat text files.
The recordSource parameter specifies an underlying flat text database file that is read to initialize a transient record number index. In the case of variable length records, the records are separated, as specified by the
DatabaseConfig.setRecordDelimitermethod. For example, standard UNIX byte stream files can be interpreted as a sequence of variable length records separated by newline characters (that is, ASCII 0x0a).In addition, when cached data would normally be written back to the underlying database file (for example, the
Database.closeorDatabase.syncmethods are called), the in-memory copy of the database will be written back to the source file.By default, the backing source file is read lazily; that is, records are not read from the file until they are requested by the application. If multiple processes (not threads) are accessing a Recno database concurrently, and are either inserting or deleting records, the backing source file must be read in its entirety before more than a single process accesses the database, and only that process should specify the backing source file as part of opening the database. See the
DatabaseConfig.setSnapshotmethod for more information.Reading and writing the backing source file cannot be transaction-protected because it involves filesystem operations that are not part of the
Databasetransaction methodology. For this reason, if a temporary database is used to hold the records, it is possible to lose the contents of the source file, for example, if the system crashes at the right instant. If a file is used to hold the database, normal database recovery on that file can be used to prevent information loss, although it is still possible that the contents of the source file will be lost if the system crashes.The source file must already exist (but may be zero-length) when the database is opened.
It is not an error to specify a read-only source file when creating a database, nor is it an error to modify the resulting database. However, any attempt to write the changes to the backing source file using either the
Database.syncorDatabase.closemethods will fail, of course. Specify the noSync argument to theDatabase.closemethod to stop it from attempting to write the changes to the backing file; instead, they will be silently discarded.For all of the previous reasons, the source file is generally used to specify databases that are read-only for Berkeley DB applications; and that are either generated on the fly by software tools or modified using a different mechanism -- for example, a text editor.
This method configures operations performed using the specified
Databaseobject, not all operations performed on the underlying database.This method may not be called after the database is opened. If the database already exists when it is opened, the information specified to this method must be the same as that historically used to create the database or corruption can occur.
- Parameters:
recordSource- The name of an underlying flat text database file that is read to initialize a transient record number index. In the case of variable length records, the records are separated, as specified by theDatabaseConfig.setRecordDelimitermethod. For example, standard UNIX byte stream files can be interpreted as a sequence of variable length records separated by newline characters (that is, ASCII 0x0a).
-
getRecordSource
Return the name of an underlying flat text database file that is read to initialize a transient record number index.This method may be called at any time during the life of the application.
- Returns:
- The name of an underlying flat text database file that is read to initialize a transient record number index.
-
setRenumbering
public void setRenumbering(boolean renumbering) Configure the logical record numbers to be mutable, and change as records are added to and deleted from the database.For example, the deletion of record number 4 causes records numbered 5 and greater to be renumbered downward by one. If a cursor was positioned to record number 4 before the deletion, it will refer to the new record number 4, if any such record exists, after the deletion. If a cursor was positioned after record number 4 before the deletion, it will be shifted downward one logical record, continuing to refer to the same record as it did before.
Creating new records will cause the creation of multiple records if the record number is more than one greater than the largest record currently in the database. For example, creating record 28, when record 25 was previously the last record in the database, will create records 26 and 27 as well as 28. Attempts to retrieve records that were created in this manner will result in an error return of
OperationStatus.KEYEMPTY.If a created record is not at the end of the database, all records following the new record will be automatically renumbered upward by one. For example, the creation of a new record numbered 8 causes records numbered 8 and greater to be renumbered upward by one. If a cursor was positioned to record number 8 or greater before the insertion, it will be shifted upward one logical record, continuing to refer to the same record as it did before.
For these reasons, concurrent access to a Recno database configured with mutable record numbers may be largely meaningless, although it is supported.
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:
renumbering- If true, configure the logical record numbers to be mutable, and change as records are added to and deleted from the database. A value of false is illegal to this method, that is, once set, the configuration cannot be cleared.
-
getRenumbering
public boolean getRenumbering()Return true if the logical record numbers are mutable, and change as records are added to and deleted from the database.This method may be called at any time during the life of the application.
- Returns:
- True if the logical record numbers are mutable, and change as records are added to and deleted from the database.
-
setReverseSplitOff
public void setReverseSplitOff(boolean reverseSplitOff) Configure the Btree to not do reverse splits.As pages are emptied in a database, the Btree implementation attempts to coalesce empty pages into higher-level pages in order to keep the database as small as possible and minimize search time. This can hurt performance in applications with cyclical data demands; that is, applications where the database grows and shrinks repeatedly. For example, because Berkeley DB does page-level locking, the maximum level of concurrency in a database of two pages is far smaller than that in a database of 100 pages, so a database that has shrunk to a minimal size can cause severe deadlocking when a new cycle of data insertion begins.
Calling this method only affects the specified
Databasehandle (and any other library handles opened within the scope of that handle).- Parameters:
reverseSplitOff- If true, configure the Btree to not do reverse splits. A value of false is illegal to this method, that is, once set, the configuration cannot be cleared.
-
getReverseSplitOff
public boolean getReverseSplitOff()Return true if the Btree has been configured to not do reverse splits.This method may be called at any time during the life of the application.
- Returns:
- True if the Btree has been configured to not do reverse splits.
-
setSortedDuplicates
public void setSortedDuplicates(boolean sortedDuplicates) Configure the database to support sorted, duplicate data items.Insertion when the key of the key/data pair being inserted already exists in the database will be successful. The ordering of duplicates in the database is determined by the duplicate comparison function.
If the application does not specify a duplicate data item 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.
A Btree that supports duplicate data items cannot also be configured for retrieval by record number.
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.
-
getSortedDuplicates
public boolean getSortedDuplicates()Return true if the database is configured to support sorted duplicate data items.This method may be called at any time during the life of the application.
- Returns:
- True if the database is configured to support sorted duplicate data items.
-
setUnsortedDuplicates
public void setUnsortedDuplicates(boolean unsortedDuplicates) Configure the database to support unsorted duplicate data items.Insertion when the key of the key/data pair being inserted already exists in the database will be successful. The ordering of duplicates in the database is determined by the order of insertion, unless the ordering is otherwise specified by use of a database cursor operation.
If a primary database is to be associated with one or more secondary databases, it may not be configured for duplicates.
Sorted duplicates are preferred to unsorted duplicates for performance reasons. Unsorted duplicates should only be used by applications wanting to order duplicate data items manually.
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:
unsortedDuplicates- If true, configure the database to support unsorted duplicate data items. A value of false is illegal to this method, that is, once set, the configuration cannot be cleared.
-
getUnsortedDuplicates
public boolean getUnsortedDuplicates()Return true if the database is configured to support duplicate data items.This method may be called at any time during the life of the application.
- Returns:
- True if the database is configured to support duplicate data items.
-
setSnapshot
public void setSnapshot(boolean snapshot) Specify that any specified backing source file be read in its entirety when the database is opened.If this flag is not specified, the backing source file may be read lazily.
Calling this method only affects the specified
Databasehandle (and any other library handles opened within the scope of that handle).- Parameters:
snapshot- If true, any specified backing source file will be read in its entirety when the database is opened. A value of false is illegal to this method, that is, once set, the configuration cannot be cleared.
-
getSnapshot
public boolean getSnapshot()Return true if the any specified backing source file will be read in its entirety when the database is opened.This method may be called at any time during the life of the application.
- Returns:
- True if the any specified backing source file will be read in its entirety when the database is opened.
-
getTransactional
public boolean getTransactional()Return 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.
-
setTransactional
public void setTransactional(boolean transactional) Enclose 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.
-
setTransactionNotDurable
public void setTransactionNotDurable(boolean transactionNotDurable) Configure the database environment to not write log records for this database.This means that updates of this database exhibit the ACI (atomicity, consistency, and isolation) properties, but not D (durability); that is, database integrity will be maintained, but if the application or system fails, integrity will not persist. The database file must be verified and/or restored from backup after a failure. In order to ensure integrity after application shut down, the database must be flushed to disk before the database handles are closed, or all database changes must be flushed from the database environment cache using
Environment.checkpoint.All database handles for a single physical file must call this method, including database handles for different databases in a physical file.
Calling this method only affects the specified
Databasehandle (and any other library handles opened within the scope of that handle).- Parameters:
transactionNotDurable- If true, configure the database environment to not write log records for this database. A value of false is illegal to this method, that is, once set, the configuration cannot be cleared.
-
getTransactionNotDurable
public boolean getTransactionNotDurable()Return true if the database environment is configured to not write log records for this database.This method may be called at any time during the life of the application.
- Returns:
- True if the database environment is configured to not write log records for this database.
-
setTruncate
public void setTruncate(boolean truncate) Configure the database to be physically truncated by truncating the underlying file, discarding all previous databases it might have held.Underlying filesystem primitives are used to implement this configuration. For this reason, it is applicable only to a physical file and cannot be used to discard databases within a file.
This configuration option cannot be lock or transaction-protected, and it is an error to specify it in a locking or transaction-protected database environment.
- Parameters:
truncate- If true, configure the database to be physically truncated by truncating the underlying file, discarding all previous databases it might have held.
-
getTruncate
public boolean getTruncate()Return true if the database has been configured to be physically truncated by truncating the underlying file, discarding all previous databases it might have held.This method may be called at any time during the life of the application.
- Returns:
- True if the database has been configured to be physically truncated by truncating the underlying file, discarding all previous databases it might have held.
-
setType
Configure the type of the database.If they type is DB_UNKNOWN, the database must already exist.
- Parameters:
type- The type of the database.
-
getType
Return the type of the database.This method may be used to determine the type of the database after opening it.
This method may not be called before the database has been opened.
- Returns:
- The type of the database.
-
getReadUncommitted()to conform to ANSI database isolation terminology.