more duplicates test, misinterpreted something about duplicates, had to fallback
This commit is contained in:
parent
06e1aca45a
commit
180c40370c
8 changed files with 126 additions and 89 deletions
14
src/base.h
14
src/base.h
|
@ -48,12 +48,6 @@ class Cache;
|
|||
|
||||
typedef MDB_txn* TransactionID; /**<I'm going to use transaction pointers as transaction IDs*/
|
||||
|
||||
enum Duplicates { /**<Duplicates mode:*/
|
||||
uniqueKey, /** - no duplicate keys allowed*/
|
||||
uniquePair, /** - no duplicate key <b>AND</b> value pairs allowed*/
|
||||
full /** - any configuration of duplicates goes*/
|
||||
};
|
||||
|
||||
class Base {
|
||||
friend class iStorage;
|
||||
public:
|
||||
|
@ -75,7 +69,7 @@ public:
|
|||
void abortTransaction(TransactionID id) const;
|
||||
|
||||
template <class K, class V>
|
||||
LMDBAL::Storage<K, V>* addStorage(const std::string& storageName, Duplicates duplicates = uniqueKey);
|
||||
LMDBAL::Storage<K, V>* addStorage(const std::string& storageName, bool duplicates = false);
|
||||
|
||||
template <class K, class V>
|
||||
LMDBAL::Cache<K, V>* addCache(const std::string& storageName);
|
||||
|
@ -121,7 +115,7 @@ private:
|
|||
* The LMDBAL::Base must be closed
|
||||
*
|
||||
* \param[in] storageName - storage name
|
||||
* \param[in] duplicates - LMDBAL::Duplicates duplicates mode (uniqueKey by default)
|
||||
* \param[in] duplicates - true if key duplicates are allowed (false by default)
|
||||
*
|
||||
* \returns storage pointer. LMDBAL::Base keeps the ownership of the added storage, you don't need to destoroy it
|
||||
*
|
||||
|
@ -132,7 +126,7 @@ private:
|
|||
* \exception LMDBAL::StorageDuplicate thrown if somebody tries to add storage with repeating name
|
||||
*/
|
||||
template <class K, class V>
|
||||
LMDBAL::Storage<K, V>* LMDBAL::Base::addStorage(const std::string& storageName, Duplicates duplicates) {
|
||||
LMDBAL::Storage<K, V>* LMDBAL::Base::addStorage(const std::string& storageName, bool duplicates) {
|
||||
if (opened)
|
||||
throw Opened(name, "add storage " + storageName);
|
||||
|
||||
|
@ -164,7 +158,7 @@ LMDBAL::Cache<K, V> * LMDBAL::Base::addCache(const std::string& storageName) {
|
|||
if (opened)
|
||||
throw Opened(name, "add cache " + storageName);
|
||||
|
||||
Cache<K, V>* cache = new Cache<K, V>(this, storageName, uniqueKey);
|
||||
Cache<K, V>* cache = new Cache<K, V>(this, storageName, false);
|
||||
std::pair<Storages::const_iterator, bool> pair = storages.insert(std::make_pair(storageName, (iStorage*)cache));
|
||||
if (!pair.second)
|
||||
throw StorageDuplicate(name, storageName);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue