|
Berkeley DB Java Edition version 1.7.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.je.DatabaseConfig
Specify the attributes of a database.
Constructor Summary | |
DatabaseConfig()
An instance created using the default constructor is initialized with the system's default settings. |
Method Summary | |
boolean |
getAllowCreate()
Return if the Environment.openDatabase method is configured
to create the database if it does not already exist. |
Comparator |
getBtreeComparator()
Returns the Comparator used for key comparison on this database. |
Comparator |
getDuplicateComparator()
Returns the Comparator used for duplicate data item comparison on this database. |
boolean |
getExclusiveCreate()
Return if the Environment.openDatabase method is configured
to fail if the database already exists. |
boolean |
getOverrideBtreeComparator()
Returns the override setting for the btree comparator. |
boolean |
getOverrideDuplicateComparator()
Returns the override setting for the duplicate comparator. |
boolean |
getReadOnly()
Return if the database is configured in read-only mode. |
boolean |
getSortedDuplicates()
Return if the database is configured to support sorted duplicate data items. |
boolean |
getTransactional()
Return if the database open is enclosed within a transaction. |
void |
setAllowCreate(boolean allowCreate)
Configure the Environment.openDatabase method to create
the database if it does not already exist. |
void |
setBtreeComparator(Class btreeComparator)
By default, a byte by byte lexicographic comparison is used for btree keys. |
void |
setDuplicateComparator(Class duplicateComparator)
By default, a byte by byte lexicographic comparison is used for duplicate data items in a duplicate set. |
void |
setExclusiveCreate(boolean exclusiveCreate)
Configure the Environment.openDatabase method to fail if
the database already exists. |
void |
setOverrideBtreeComparator(boolean override)
Set to true if the database exists and the btree comparator specified in this configuration object should override the current comparator. |
void |
setOverrideDuplicateComparator(boolean override)
Set to true if the database exists and the duplicate comparator specified in this configuration object should override the current comparator. |
void |
setReadOnly(boolean readOnly)
Configure the database in read-only mode. |
void |
setSortedDuplicates(boolean sortedDuplicates)
Configure the database to support sorted, duplicate data items. |
void |
setTransactional(boolean transactional)
Enclose the database open within a transaction. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DatabaseConfig()
Method Detail |
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 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 boolean getSortedDuplicates()
This method may be called at any time during the life of the application.
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 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
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 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 boolean getTransactional()
This method may be called at any time during the life of the application.
public void setBtreeComparator(Class btreeComparator)
The btreeComparator class must implement java.util.Comparator.
JE will instantiate the Comparator with a zero-parameter constructor, so the Comparator should not be dependent on constructor parameters. In addition, although it is possible to change the comparator for an existing database, care must be taken that the new comparator provides compatible results with the previous comparator, or database corruption will occur.
The Comparator.compare() method is passed the byte arrays that are stored in the database. If you know how your data is organized in the byte array, then you can write a comparison routine that directly examines the contents of the arrays. Otherwise, you have to reconstruct your original objects, and then perform the comparison. See the Getting Started Guide for examples.
The comparator for an existing database will not be overridden unless setOverrideBtreeComparator() is set to true.
public Comparator getBtreeComparator()
public void setOverrideBtreeComparator(boolean override)
override
- Set to true to override the existing comparator.public boolean getOverrideBtreeComparator()
public void setDuplicateComparator(Class duplicateComparator)
The duplicateComparator class must implement java.util.Comparator.
JE will instantiate the Comparator with a zero-parameter constructor, so the Comparator should not be dependent on constructor parameters. In addition, although it is possible to change the comparator for an existing database, care must be taken that the new comparator provides compatible results with the previous comparator, or database corruption will occur.
The Comparator.compare() method is passed the byte arrays that are stored in the database. If you know how your data is organized in the byte array, then you can write a comparison routine that directly examines the contents of the arrays. Otherwise, you have to reconstruct your original objects, and then perform the comparison. See the Getting Started Guide for examples.
The comparator for an existing database will not be overridden unless setOverrideDuplicateComparator() is set to true.
public Comparator getDuplicateComparator()
public void setOverrideDuplicateComparator(boolean override)
override
- Set to true to override the existing comparator.public boolean getOverrideDuplicateComparator()
|
Berkeley DB Java Edition version 1.7.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |