refactoring and remove dead code in lmdb

This commit is contained in:
Martin Vierula 2023-10-24 06:36:18 -07:00
parent 3951ba0e48
commit dc6cce5f0c
No known key found for this signature in database
GPG Key ID: F2FC4E45883BCBA4
4 changed files with 15 additions and 55 deletions

View File

@ -45,7 +45,6 @@ class Collection {
public:
explicit Collection(const std::string &a) : m_name(a) { }
virtual ~Collection() { }
virtual void store(std::string key, std::string value) = 0;
virtual bool storeOrUpdateFirst(const std::string &key,
const std::string &value) = 0;
@ -70,21 +69,6 @@ class Collection {
variables::KeyExclusions &ke) = 0;
/* store */
virtual void store(std::string key, std::string compartment,
std::string value) {
std::string nkey = compartment + "::" + key;
store(nkey, value);
}
virtual void store(std::string key, std::string compartment,
std::string compartment2, std::string value) {
std::string nkey = compartment + "::" + compartment2 + "::" + key;
store(nkey, value);
}
/* storeOrUpdateFirst */
virtual bool storeOrUpdateFirst(const std::string &key,
std::string compartment, const std::string &value) {

View File

@ -76,7 +76,7 @@ class InMemoryPerProcess :
public:
explicit InMemoryPerProcess(const std::string &name);
~InMemoryPerProcess();
void store(std::string key, std::string value) override;
void store(std::string key, std::string value);
bool storeOrUpdateFirst(const std::string &key,
const std::string &value) override;
@ -101,6 +101,20 @@ class InMemoryPerProcess :
std::vector<const VariableValue *> *l,
variables::KeyExclusions &ke) override;
/* store */
virtual void store(std::string key, std::string compartment,
std::string value) {
std::string nkey = compartment + "::" + key;
store(nkey, value);
}
virtual void store(std::string key, std::string compartment,
std::string compartment2, std::string value) {
std::string nkey = compartment + "::" + compartment2 + "::" + key;
store(nkey, value);
}
private:
pthread_mutex_t m_lock;
};

View File

@ -397,43 +397,6 @@ end_txn:
}
void LMDB::store(std::string key, std::string value) {
MDB_val mdb_key, mdb_data;
MDB_txn *txn = NULL;
int rc;
MDB_stat mst;
rc = txn_begin(0, &txn);
lmdb_debug(rc, "txn", "store");
if (rc != 0) {
goto end_txn;
}
string2val(key, &mdb_key);
string2val(value, &mdb_data);
rc = mdb_put(txn, m_dbi, &mdb_key, &mdb_data, 0);
lmdb_debug(rc, "put", "store");
if (rc != 0) {
goto end_put;
}
rc = mdb_txn_commit(txn);
lmdb_debug(rc, "commit", "store");
if (rc != 0) {
goto end_commit;
}
end_put:
end_dbi:
if (rc != 0) {
mdb_txn_abort(txn);
}
end_commit:
end_txn:
return;
}
bool LMDB::updateFirst(const std::string &key,
const std::string &value) {
int rc;

View File

@ -98,7 +98,6 @@ class LMDB :
public Collection {
public:
explicit LMDB(const std::string &name);
void store(std::string key, std::string value) override;
bool storeOrUpdateFirst(const std::string &key,
const std::string &value) override;