|
Berkeley DB version 4.2.52 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sleepycat.bdb.DataStore
Represents a Berkeley DB database in the role of a primary data store. A
store may be used by itself or along with one or more DataIndex
objects. A store is typically accessed by passing it to the constructor of
one of the collection classes in the com.sleepycat.bdb.collection
package. For example:
Db db = new Db(env, 0); db.open(null, "store.db", null, Db.DB_BTREE, dbOpenFlags, 0); DataStore store = new DataStore(db, keyFormat, valueFormat, keyAssigner); StoredMap map = new StoredMap(store, keyBinding, valueBinding, writeAllowed);
All access methods may be used with BDB. However, some access methods may only be used with certain types of collection views, and some access methods impose restrictions on the way collection views are used.
A store is always associated with the environment of its underlying database, which is the first parameter to the {Db#Db} constructor. There are three types of environments in Berkeley DB.
Environment | Access Mode | Berkeley DB Flags |
---|---|---|
Data Store | single-threaded access | Db.DB_INIT_MPOOL |
Concurrent Data Store | single-writer multiple-reader access | Db.DB_INIT_CDB | Db.DB_INIT_MPOOL |
Transactional Data Store | transactional access for any number of readers and writers | Db.DB_INIT_TXN | Db.DB_INIT_LOCK | Db.DB_INIT_MPOOL |
The flags shown are the minimum required for creating the Berkeley DB environment. Many other Berkeley DB options are also available. For details on creating and configuring the environment see the Berkeley DB documentation.
All three environments may be used within BDB. However, the Concurrent Data Store Environment imposes the restriction that only one writable cursor may be open at a time. This means that if you have a writable iterator for a data store open, then you cannot obtain another writable iterator for the same data store and you cannot perform other write operations through a collection for that data store (since this also uses a write cursor).
Constructor Summary | |
DataStore(Db db,
DataFormat keyFormat,
DataFormat valueFormat,
PrimaryKeyAssigner keyAssigner)
Creates a store from a previously opened Db object. |
Method Summary | |
void |
close()
Closes the store and all associated indices. |
DbEnv |
getEnv()
Returns the environment associated with this store. |
Iterator |
getIndices()
Returns the indices associated with this store. |
PrimaryKeyAssigner |
getKeyAssigner()
Returns the key assigner associated with this store. |
DataFormat |
getKeyFormat()
Returns the key format associated with this store. |
DataFormat |
getValueFormat()
Returns the value format associated with this store. |
String |
toString()
Returns a printable string identifying the filename and datbase name of the store. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public DataStore(Db db, DataFormat keyFormat, DataFormat valueFormat, PrimaryKeyAssigner keyAssigner)
db
- the previously opened Db object.keyFormat
- the data format for keys.valueFormat
- the data format for values.keyAssigner
- an object for assigning keys or null if no automatic
key assignment is used.Method Detail |
public void close() throws DbException
DbException
public final DbEnv getEnv()
public final DataFormat getKeyFormat()
public final PrimaryKeyAssigner getKeyAssigner()
public final DataFormat getValueFormat()
public final Iterator getIndices()
DataIndex
and may also be of class
ForeignKeyIndex
.
public String toString()
toString
in class Object
|
Berkeley DB version 4.2.52 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |