Commit b1e7da34 authored by Matthieu Dorier's avatar Matthieu Dorier

store now takes only one call

parent ca74a8b4
......@@ -228,20 +228,14 @@ class DataStore::Impl {
}
ch_placement_find_closest(m_chi_sdskv, name_hash, 1, &sdskv_db_idx);
const auto& db = m_databases[sdskv_db_idx];
// check if the key exists
bool key_exists;
try {
key_exists = db.exists(key);
std::cerr << "In store(), key_exists = " << key_exists << " for key = " << key << std::endl;
} catch(sdskv::exception& ex) {
throw Exception("Could not check if key exists in SDSKV (sdskv::database::exists error)");
}
if(key_exists) return ProductID();
try {
db.put(key, data);
} catch(sdskv::exception& ex) {
throw Exception("Could not put key/value pair in SDSKV (sdskv::database::put error)");
if(ex.error() == SDSKV_ERR_KEYEXISTS) {
return ProductID();
} else {
throw Exception("Could not put key/value pair in SDSKV (sdskv::database::put error: " +std::string(ex.what()) + ")");
}
}
return product_id;
}
......
......@@ -75,6 +75,7 @@ void hepnos_run_service(MPI_Comm comm, const char* config_file, const char* conn
config.db_name = db_name.c_str();
config.db_path = db_path.c_str();
config.db_type = db_type;
config.db_no_overwrite = 1;
db_id = provider->attach_database(config);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment