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).
@author Mark Hayes
|
|
|
|
|
|