|
Berkeley DB version 5.3.28 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sleepycat.db.DatabaseConfig
public class DatabaseConfig
Specify the attributes of a database.
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 | |
---|---|
DatabaseConfig |
cloneConfig()
Returns a copy of this configuration object. |
boolean |
getAllowCreate()
Return true if the Environment.openDatabase method is configured
to create the database if it does not already exist. |
Comparator |
getBtreeComparator()
Return the custom Comparator used for btree keys. |
BtreeCompressor |
getBtreeCompressor()
Get the Btree compression callbacks. |
int |
getBtreeMinKey()
Return the minimum number of key/data pairs intended to be stored on any single Btree leaf page. |
BtreePrefixCalculator |
getBtreePrefixCalculator()
Return the Btree prefix callback. |
boolean |
getBtreeRecordNumbers()
Return true if the Btree is configured to support retrieval by record number. |
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. |
boolean |
getByteSwapped()
Return if the underlying database files were created on an architecture of the same byte order as the current one. |
int |
getCacheCount()
Return the number of shared memory buffer pools, that is, the number of caches. |
long |
getCacheSize()
Return the size of the shared memory buffer pool, that is, the cache. |
boolean |
getChecksum()
Return true if the database environment is configured to do checksum verification of pages read into the cache from the backing filestore. |
File |
getCreateDir()
Return the directory a database will/has been created in or looked for. |
boolean |
getDirtyRead()
Deprecated. This has been replaced by getReadUncommitted() to conform to ANSI
database isolation terminology. |
Comparator |
getDuplicateComparator()
Return the duplicate data item comparison callback. |
boolean |
getEncrypted()
Return true if the database has been configured to perform encryption. |
ErrorHandler |
getErrorHandler()
Return the function to be called if an error occurs. |
String |
getErrorPrefix()
Return the prefix string that appears before error messages. |
OutputStream |
getErrorStream()
Return the an OutputStream for displaying error messages. |
boolean |
getExclusiveCreate()
Return true if the Environment.openDatabase method is configured
to fail if the database already exists. |
FeedbackHandler |
getFeedbackHandler()
Return the object's methods to be called to provide feedback. |
Comparator |
getHashComparator()
Return the Comparator used to compare keys in a Hash database. |
Hasher |
getHasher()
Return the database-specific hash function. |
int |
getHashFillFactor()
Return the hash table density. |
int |
getHashNumElements()
Return the estimate of the final size of the hash table. |
long |
getHeapRegionSize()
Return the number of pages in a region of the database. |
long |
getHeapsize()
Return the maximum on-disk database file size. |
MessageHandler |
getMessageHandler()
Return the function to be called with an informational message. |
OutputStream |
getMessageStream()
Return the an OutputStream for displaying informational messages. |
long |
getMode()
Return the mode used to create files. |
boolean |
getMultiversion()
Return true if the database is configured for multiversion concurrency control. |
boolean |
getNoMMap()
Return true if the library is configured to not map this database into memory. |
Boolean |
getNoWaitDbExclusiveLock()
Return whether the Database handle is
configured to obtain a write lock on the entire database. |
int |
getPageSize()
Return the size of the pages used to hold items in the database, in bytes. |
PanicHandler |
getPanicHandler()
Return the function to be called if the database environment panics. |
File[] |
getPartitionDirs()
Return the array of directories the database extents should be created in or looked for. |
PartitionHandler |
getPartitionHandler()
Return the function to be called to determine which partition a key resides in. |
DatabaseEntry |
getPartitionKeys()
Return the array of keys the database is configured to partition with. |
int |
getPartitionParts()
Return the number of partitions the database is configured for. |
CacheFilePriority |
getPriority()
Return the the cache priority for pages referenced by this handle. |
int |
getQueueExtentSize()
Return the size of the extents used to hold pages in a Queue database, specified as a number of pages. |
boolean |
getQueueInOrder()
Return true if the Database.consume method is configured to return
key/data pairs in order, always returning the key/data item from the
head of the queue. |
boolean |
getReadOnly()
Return true if the database is configured in read-only mode. |
boolean |
getReadUncommitted()
Return true if the database is configured to support read uncommitted. |
int |
getRecordDelimiter()
Return the delimiting byte used to mark the end of a record in the backing source file for the Recno access method. |
int |
getRecordLength()
Return the database record length, in bytes. |
RecordNumberAppender |
getRecordNumberAppender()
Return the function to call after the record number has been selected but before the data has been stored into the database. |
int |
getRecordPad()
Return the padding character for short, fixed-length records for the Queue and Recno access methods. |
File |
getRecordSource()
Return the name of an underlying flat text database file that is read to initialize a transient record number index. |
boolean |
getRenumbering()
Return true if the logical record numbers are mutable, and change as records are added to and deleted from the database. |
boolean |
getReverseSplitOff()
Return true if the Btree has been configured to not do reverse splits. |
boolean |
getSnapshot()
Return true if the any specified backing source file will be read in its entirety when the database is opened. |
boolean |
getSortedDuplicates()
Return true if the database is configured to support sorted duplicate data items. |
boolean |
getTransactional()
Return true if the database open is enclosed within a transaction. |
boolean |
getTransactionNotDurable()
Return true if the database environment is configured to not write log records for this database. |
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. |
DatabaseType |
getType()
Return the type of the database. |
boolean |
getUnsortedDuplicates()
Return true if the database is configured to support duplicate data items. |
void |
setAllowCreate(boolean allowCreate)
Configure the Environment.openDatabase method to create
the database if it does not already exist. |
void |
setBtreeComparator(Comparator btreeComparator)
By default, a byte by byte lexicographic comparison is used for btree keys. |
void |
setBtreeCompressor(BtreeCompressor btreeCompressor)
Set the Btree compression callbacks. |
void |
setBtreeMinKey(int btMinKey)
Set the minimum number of key/data pairs intended to be stored on any single Btree leaf page. |
void |
setBtreePrefixCalculator(BtreePrefixCalculator btreePrefixCalculator)
Set the Btree prefix callback. |
void |
setBtreeRecordNumbers(boolean btreeRecordNumbers)
Configure the Btree to support retrieval by record number. |
void |
setByteOrder(int byteOrder)
Set the byte order for integers in the stored database metadata. |
void |
setCacheCount(int cacheCount)
Set the number of shared memory buffer pools, that is, the number of caches. |
void |
setCacheSize(long cacheSize)
Set the size of the shared memory buffer pool, that is, the size of the cache. |
void |
setChecksum(boolean checksum)
Configure the database environment to do checksum verification of pages read into the cache from the backing filestore. |
void |
setCreateDir(File createDir)
Specify which directory a database should be created in or looked for. |
void |
setDirtyRead(boolean dirtyRead)
Deprecated. This has been replaced by setReadUncommitted(boolean) to conform to ANSI
database isolation terminology. |
void |
setDuplicateComparator(Comparator duplicateComparator)
Set the duplicate data item comparison callback. |
void |
setEncrypted(String password)
Set the password used to perform encryption and decryption. |
void |
setErrorHandler(ErrorHandler errorHandler)
Set the function to be called if an error occurs. |
void |
setErrorPrefix(String errorPrefix)
Set the prefix string that appears before error messages. |
void |
setErrorStream(OutputStream errorStream)
Set an OutputStream for displaying error messages. |
void |
setExclusiveCreate(boolean exclusiveCreate)
Configure the Environment.openDatabase method to fail if
the database already exists. |
void |
setFeedbackHandler(FeedbackHandler feedbackHandler)
Set an object whose methods are called to provide feedback. |
void |
setHashComparator(Comparator hashComparator)
Set the Hash key comparison function. |
void |
setHasher(Hasher hasher)
Set a database-specific hash function. |
void |
setHashFillFactor(int hashFillFactor)
Set the desired density within the hash table. |
void |
setHashNumElements(int hashNumElements)
Set an estimate of the final size of the hash table. |
void |
setHeapRegionSize(int npages)
Sets the number of pages in a region of a database configured to use the Heap access method. |
void |
setHeapsize(long bytes)
Set the maximum on-disk database file size used by a database configured to use the Heap access method. |
void |
setMessageHandler(MessageHandler messageHandler)
Set a function to be called with an informational message. |
void |
setMessageStream(OutputStream messageStream)
Set an OutputStream for displaying informational messages. |
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 mode mode
(as described in the chmod (2) manual page) and modified
by the process' umask value at the time of creation (see the
umask (2) manual page). |
void |
setMultiversion(boolean multiversion)
Configured the database with support for multiversion concurrency control. |
void |
setNoMMap(boolean noMMap)
Configure the library to not map this database into memory. |
void |
setNoWaitDbExclusiveLock(Boolean noWaitDbExclLock)
Configure the Database handle to obtain a
write lock on the entire database. |
void |
setPageSize(int pageSize)
Set the size of the pages used to hold items in the database, in bytes. |
void |
setPanicHandler(PanicHandler panicHandler)
Set the function to be called if the database environment panics. |
void |
setPartitionByCallback(int parts,
PartitionHandler partitionHandler)
Enable or disable database partitioning, and set the callback that will be used for the partitioning. |
void |
setPartitionByRange(int parts,
MultipleDataEntry keys)
Enable or disable database partitioning, and set key ranges that will be used for the partitioning. |
void |
setPartitionDirs(File[] dirs)
Specify the array of directories the database extents should be created in or looked for. |
void |
setPriority(CacheFilePriority priority)
Set the cache priority for pages referenced by the DB handle. |
void |
setQueueExtentSize(int queueExtentSize)
Set the size of the extents used to hold pages in a Queue database, specified as a number of pages. |
void |
setQueueInOrder(boolean queueInOrder)
Configure Database.consume to return key/data pairs in
order, always returning the key/data item from the head of the
queue. |
void |
setReadOnly(boolean readOnly)
Configure the database in read-only mode. |
void |
setReadUncommitted(boolean readUncommitted)
Configure the database to support read uncommitted. |
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. |
void |
setRecordLength(int recordLength)
Specify the database record length, in bytes. |
void |
setRecordNumberAppender(RecordNumberAppender recnoAppender)
Configure Database.append to call the function after the
record number has been selected but before the data has been stored
into the database. |
void |
setRecordPad(int recordPad)
Set the padding character for short, fixed-length records for the Queue and Recno access methods. |
void |
setRecordSource(File recordSource)
Set the underlying source file for the Recno access method. |
void |
setRenumbering(boolean renumbering)
Configure the logical record numbers to be mutable, and change as records are added to and deleted from the database. |
void |
setReverseSplitOff(boolean reverseSplitOff)
Configure the Btree to not do reverse splits. |
void |
setSnapshot(boolean snapshot)
Specify that any specified backing source file be read in its entirety when the database is opened. |
void |
setSortedDuplicates(boolean sortedDuplicates)
Configure the database to support sorted, duplicate data items. |
void |
setTransactional(boolean transactional)
Enclose the database open within a transaction. |
void |
setTransactionNotDurable(boolean transactionNotDurable)
Configure the database environment to not write log records for this database. |
void |
setTruncate(boolean truncate)
Configure the database to be physically truncated by truncating the underlying file, discarding all previous databases it might have held. |
void |
setType(DatabaseType type)
Configure the type of the database. |
void |
setUnsortedDuplicates(boolean unsortedDuplicates)
Configure the database to support unsorted duplicate data items. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final DatabaseConfig DEFAULT
Constructor Detail |
---|
public DatabaseConfig()
Method Detail |
---|
public DatabaseConfig cloneConfig()
public void setAllowCreate(boolean allowCreate)
Environment.openDatabase
method to create
the database if it does not already exist.
allowCreate
- If true, configure the Environment.openDatabase
method to
create the database if it does not already exist.public boolean getAllowCreate()
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.
Environment.openDatabase
method is configured
to create the database if it does not already exist.public void setBtreeComparator(Comparator btreeComparator)
The compare
method 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.
public Comparator getBtreeComparator()
public void setBtreeMinKey(int btMinKey)
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 Database
handle.
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.
btMinKey
- The minimum number of key/data pairs intended to be stored on any
single Btree leaf page.public int getBtreeMinKey()
This method may be called at any time during the life of the application.
public void setByteOrder(int byteOrder)
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 Database
handle.
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.
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.public int getByteOrder()
This method may be called at any time during the life of the application.
public boolean getByteSwapped()
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.
public void setBtreeCompressor(BtreeCompressor btreeCompressor)
public BtreeCompressor getBtreeCompressor()
public void setBtreePrefixCalculator(BtreePrefixCalculator btreePrefixCalculator)
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.
public BtreePrefixCalculator getBtreePrefixCalculator()
This method may be called at any time during the life of the application.
public void setCacheSize(long cacheSize)
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.
cacheSize
- The size of the shared memory buffer pool, that is, the size of the
cache.
DatabaseException
- if a failure occurs.public long getCacheSize()
This method may be called at any time during the life of the application.
public void setCreateDir(File createDir)
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.
DatabaseException
- if a failure occurs.public File getCreateDir()
This method may be called at any time during the life of the application.
public void setCacheCount(int cacheCount)
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.
cacheCount
- The number of shared memory buffer pools, that is, the number of caches.
DatabaseException
- if a failure occurs.public int getCacheCount()
This method may be called at any time during the life of the application.
public void setChecksum(boolean checksum)
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 Database
handle
(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.
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.public boolean getChecksum()
This method may be called at any time during the life of the application.
public void setReadUncommitted(boolean readUncommitted)
Read operations on the database may request the return of modified
but not yet committed data. This flag must be specified on all
Database
handles used to perform read uncommitted or database
updates, otherwise requests for read uncommitted may not be honored and
the read may block.
readUncommitted
- If true, configure the database to support read uncommitted.public boolean getReadUncommitted()
This method may be called at any time during the life of the application.
public void setDirtyRead(boolean dirtyRead)
setReadUncommitted(boolean)
to conform to ANSI
database isolation terminology.
Read operations on the database may request the return of modified
but not yet committed data. This flag must be specified on all
Database
handles used to perform read uncommitted or database
updates, otherwise requests for read uncommitted may not be honored and
the read may block.
dirtyRead
- If true, configure the database to support read uncommitted.
public boolean getDirtyRead()
getReadUncommitted()
to conform to ANSI
database isolation terminology.
This method may be called at any time during the life of the application.
public void setDuplicateComparator(Comparator duplicateComparator)
DatabaseConfig.setSortedDuplicates
is also configured.
If no comparison function is specified, the data items are compared lexically, with shorter data items collating before longer data items.
The compare
method 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.
duplicateComparator
- the comparison callback for duplicate data items.public Comparator getDuplicateComparator()
public void setEncrypted(String password)
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.
public boolean getEncrypted()
This method may be called at any time during the life of the application.
public void setErrorHandler(ErrorHandler errorHandler)
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.setErrorHandler
and DatabaseConfig.setErrorHandler
methods 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.setErrorStream
and DatabaseConfig.setErrorStream
to
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 Database
handles opened inside of database environments,
calling this method affects the entire environment and is equivalent to
calling EnvironmentConfig.setErrorHandler
.
This method may be called at any time during the life of the application.
errorHandler
- The function to be called if an error occurs.public ErrorHandler getErrorHandler()
This method may be called at any time during the life of the application.
public void setErrorPrefix(String errorPrefix)
For Database
handles opened inside of database environments,
calling this method affects the entire environment and is equivalent to
calling EnvironmentConfig.setErrorPrefix
.
This method may be called at any time during the life of the application.
errorPrefix
- The prefix string that appears before error messages.public String getErrorPrefix()
This method may be called at any time during the life of the application.
public void setErrorStream(OutputStream errorStream)
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.setErrorStream
and
DatabaseConfig.setErrorStream
methods 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.setErrorPrefix
or DatabaseConfig.setErrorPrefix
), an error string, and a trailing newline character.
Setting errorStream to null unconfigures the interface.
Alternatively, applications can use EnvironmentConfig.setErrorHandler
and DatabaseConfig.setErrorHandler
to 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.
errorStream
- The application-specified OutputStream for error messages.public OutputStream getErrorStream()
This method may be called at any time during the life of the application.
public void setExclusiveCreate(boolean exclusiveCreate)
Environment.openDatabase
method to fail if
the database already exists.
The exclusiveCreate mode is only meaningful if specified with the allowCreate mode.
exclusiveCreate
- If true, configure the Environment.openDatabase
method to
fail if the database already exists.public boolean getExclusiveCreate()
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.
Environment.openDatabase
method is configured
to fail if the database already exists.public void setFeedbackHandler(FeedbackHandler feedbackHandler)
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
Environment
handle
This method may be called at any time during the life of the application.
feedbackHandler
- An object whose methods are called to provide feedback.public FeedbackHandler getFeedbackHandler()
This method may be called at any time during the life of the application.
public void setHashFillFactor(int hashFillFactor)
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 Database
handle.
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.
hashFillFactor
- The desired density within the hash table.public int getHashFillFactor()
This method may be called at any time during the life of the application.
public void setHashComparator(Comparator hashComparator)
If no comparison function is specified, a byte-by-byte comparison is performed.
The compare
method 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.
public Comparator getHashComparator()
This method may be called at any time during the life of the application.
public void setHasher(Hasher hasher)
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
Database
object, 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.
hasher
- A database-specific hash function.public Hasher getHasher()
This method may be called at any time during the life of the application.
public void setHashNumElements(int hashNumElements)
In order for the estimate to be used when creating the database, the
DatabaseConfig.setHashFillFactor
method 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 Database
handle.
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.
hashNumElements
- An estimate of the final size of the hash table.public int getHashNumElements()
This method may be called at any time during the life of the application.
public void setHeapsize(long bytes)
HeapFullException
.
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.
bytes
- The maximum on-disk database file size.public long getHeapsize()
This method may be called at any time during the life of the application.
public void setHeapRegionSize(int npages)
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 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.
npages
- The size of the region, in pages.public long getHeapRegionSize()
This method may be called at any time during the life of the application.
public void setMessageHandler(MessageHandler messageHandler)
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.setVerboseDeadlock
for example.
The EnvironmentConfig.setMessageHandler
and
DatabaseConfig.setMessageHandler
methods are used to display
these messages for the application.
Setting messageHandler to null unconfigures the interface.
Alternatively, you can use EnvironmentConfig.setMessageStream
and DatabaseConfig.setMessageStream
to send the additional
information directly to an output streams. You should not mix these
approaches.
For Database
handles opened inside of database environments,
calling this method affects the entire environment and is equivalent to
calling EnvironmentConfig.setMessageHandler
.
This method may be called at any time during the life of the application.
messageHandler
- The application-specified function for informational messages.public MessageHandler getMessageHandler()
This method may be called at any time during the life of the application.
public void setMessageStream(OutputStream messageStream)
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.setVerboseDeadlock
for example.
The EnvironmentConfig.setMessageStream
and
DatabaseConfig.setMessageStream
methods 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.setMessageHandler
and DatabaseConfig.setMessageHandler
to capture the additional
information in a way that does not use output streams. You should not
mix these approaches.
For Database
handles opened inside of database environments,
calling this method affects the entire environment and is equivalent to
calling EnvironmentConfig.setMessageStream
.
This method may be called at any time during the life of the application.
messageStream
- The application-specified OutputStream for informational messages.public OutputStream getMessageStream()
This method may be called at any time during the life of the application.
public void setMode(int mode)
mode
(as described in the chmod
(2) manual page) and modified
by the process' umask value at the time of creation (see the
umask
(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 mode mode
, unmodified by the process' umask
value. If mode
is 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.
mode
- the mode used to create filespublic long getMode()
This method may be called at any time during the life of the application.
public void setMultiversion(boolean multiversion)
TransactionConfig.setSnapshot(boolean)
) for more information.
Multiversion access requires that the database be opened
in a transaction and is not supported for queue databases.
multiversion
- If true, configure the database with support for multiversion concurrency
control.public boolean getMultiversion()
This method may be called at any time during the life of the application.
public void setNoMMap(boolean noMMap)
noMMap
- If true, configure the library to not map this database into memory.public boolean getNoMMap()
This method may be called at any time during the life of the application.
public void setNoWaitDbExclusiveLock(Boolean noWaitDbExclLock)
Database
handle to obtain a
write lock on the entire database.
This method may not be called after the database is opened.
noWaitDbExclLock
- If True, configure the Database
handle to
obtain a write lock on the entire database. When the database is opened it will
immediately throw
LockNotGrantedException
if it
cannot obtain the exclusive lock immediately. If False, configure the
Database
handle 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 the
Database
handle 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.
public Boolean getNoWaitDbExclusiveLock()
Database
handle 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.
Database
handle 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 the
Database
handle 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 the
Database
handle is not configured for
exclusive locking.public void setPageSize(int pageSize)
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 Database
handle.
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.
pageSize
- The size of the pages used to hold items in the database, in bytes.public int getPageSize()
This method may be called at any time during the life of the application.
public void setPanicHandler(PanicHandler panicHandler)
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 when RunRecoveryException
is about to be thrown from a
Berkeley DB method.
For Database
handles opened inside of database environments,
calling this method affects the entire environment and is equivalent to
calling EnvironmentConfig.setPanicHandler
.
This method may be called at any time during the life of the application.
panicHandler
- The function to be called if the database environment panics.public PanicHandler getPanicHandler()
This method may be called at any time during the life of the application.
public void setPartitionByCallback(int parts, PartitionHandler partitionHandler)
This method may only be called before opening a database.
parts
- The number of partitions that will be created.
partitionHandler
- The function to be called to determine which partition a key resides in.public void setPartitionByRange(int parts, MultipleDataEntry keys)
This method may only be called before opening a database.
parts
- The number of partitions that will be created.
keys
- A MultipleDatabaseEntry that contains the boundary keys for partitioning.public PartitionHandler getPartitionHandler()
This method may be called at any time during the life of the application.
public int getPartitionParts()
This method may be called at any time during the life of the application.
public DatabaseEntry getPartitionKeys()
This method may be called at any time during the life of the application.
public void setPartitionDirs(File[] dirs)
This method may only be called before the database is opened.
dirs
- The array of directories the database extents should be created in or looked
for.public File[] getPartitionDirs()
This method may be called at any time during the life of the application.
public void setPriority(CacheFilePriority priority)
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.
priority
- The desired cache priority.public CacheFilePriority getPriority()
This method may be called at any time during the life of the application.
public void setQueueExtentSize(int queueExtentSize)
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 Database
handle.
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.
queueExtentSize
- The number of pages in a Queue database extent.public int getQueueExtentSize()
This method may be called at any time during the life of the application.
public void setQueueInOrder(boolean queueInOrder)
Database.consume
to 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.consume
method 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 Database
handle
(and any other library handles opened within the scope of that handle).
queueInOrder
- If true, configure the Database.consume
method 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.public boolean getQueueInOrder()
Database.consume
method 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.
Database.consume
method is configured to return
key/data pairs in order, always returning the key/data item from the
head of the queue.public void setReadOnly(boolean readOnly)
Any attempt to modify items in the database will fail, regardless of the actual permissions of any underlying files.
readOnly
- If true, configure the database in read-only mode.public boolean getReadOnly()
This method may be called at any time during the life of the application.
public void setRecordNumberAppender(RecordNumberAppender recnoAppender)
Database.append
to 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
Database
object, not all operations performed on the underlying
database.
This method may not be called after the database is opened.
recnoAppender
- The function to call after the record number has been selected but
before the data has been stored into the database.public RecordNumberAppender getRecordNumberAppender()
This method may be called at any time during the life of the application.
public void setRecordDelimiter(int recordDelimiter)
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 Database
handle.
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.
recordDelimiter
- The delimiting byte used to mark the end of a record in the backing
source file for the Recno access method.public int getRecordDelimiter()
This method may be called at any time during the life of the application.
public void setRecordLength(int recordLength)
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.setRecordPad
for 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 Database
handle.
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.
recordLength
- The database record length, in bytes.public int getRecordLength()
This method may be called at any time during the life of the application.
public void setBtreeRecordNumbers(boolean btreeRecordNumbers)
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.
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.public boolean getBtreeRecordNumbers()
This method may be called at any time during the life of the application.
public void setRecordPad(int recordPad)
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 Database
handle.
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.
recordPad
- The padding character for short, fixed-length records for the Queue
and Recno access methods.public int getRecordPad()
This method may be called at any time during the life of the application.
public void setRecordSource(File recordSource)
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.setRecordDelimiter
method. 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.close
or Database.sync
methods 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.setSnapshot
method 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 Database
transaction 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.sync
or Database.close
methods will fail, of course. Specify the noSync argument to the
Database.close
method 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
Database
object, 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.
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 the
DatabaseConfig.setRecordDelimiter
method. 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).public File getRecordSource()
This method may be called at any time during the life of the application.
public void setRenumbering(boolean renumbering)
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.
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.public boolean getRenumbering()
This method may be called at any time during the life of the application.
public void setReverseSplitOff(boolean reverseSplitOff)
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 Database
handle
(and any other library handles opened within the scope of that handle).
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.public boolean getReverseSplitOff()
This method may be called at any time during the life of the application.
public void setSortedDuplicates(boolean sortedDuplicates)
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.
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.public boolean getSortedDuplicates()
This method may be called at any time during the life of the application.
public void setUnsortedDuplicates(boolean unsortedDuplicates)
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.
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.public boolean getUnsortedDuplicates()
This method may be called at any time during the life of the application.
public void setSnapshot(boolean snapshot)
If this flag is not specified, the backing source file may be read lazily.
Calling this method only affects the specified Database
handle
(and any other library handles opened within the scope of that handle).
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.public boolean getSnapshot()
This method may be called at any time during the life of the application.
public boolean getTransactional()
This method may be called at any time during the life of the application.
public void setTransactional(boolean transactional)
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.
transactional
- If true, enclose the database open within a transaction.public void setTransactionNotDurable(boolean transactionNotDurable)
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 Database
handle
(and any other library handles opened within the scope of that handle).
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.public boolean getTransactionNotDurable()
This method may be called at any time during the life of the application.
public void setTruncate(boolean truncate)
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.
truncate
- If true, configure the database to be physically truncated by truncating
the underlying file, discarding all previous databases it might have
held.public boolean getTruncate()
This method may be called at any time during the life of the application.
public void setType(DatabaseType type)
If they type is DB_UNKNOWN, the database must already exist.
type
- The type of the database.public DatabaseType getType()
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.
|
Berkeley DB version 5.3.28 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |