Commit 7bb616af authored by Matthieu Dorier's avatar Matthieu Dorier
Browse files

falling back to bypassing batching and async engine if they are not initialized

parent fe8457c9
......@@ -60,7 +60,10 @@ ProductID DataSet::storeRawData(WriteBatch& batch, const std::string& key, const
}
// forward the call to the datastore's store function
ItemDescriptor id(m_impl->m_uuid);
if(batch.m_impl)
return batch.m_impl->storeRawProduct(id, key, value, vsize);
else
return m_impl->m_datastore->storeRawProduct(id, key, value, vsize);
}
ProductID DataSet::storeRawData(AsyncEngine& async, const std::string& key, const char* value, size_t vsize) {
......@@ -69,7 +72,10 @@ ProductID DataSet::storeRawData(AsyncEngine& async, const std::string& key, cons
}
// forward the call to the async engine's store function
ItemDescriptor id(m_impl->m_uuid);
if(async.m_impl)
return async.m_impl->storeRawProduct(id, key, value, vsize);
else
return m_impl->m_datastore->storeRawProduct(id, key, value, vsize);
}
bool DataSet::loadRawData(const std::string& key, std::string& buffer) const {
......@@ -156,7 +162,10 @@ Run DataSet::createRun(WriteBatch& batch, const RunNumber& runNumber) {
if(InvalidRunNumber == runNumber) {
throw Exception("Trying to create a Run with InvalidRunNumber");
}
if(batch.m_impl)
batch.m_impl->createItem(m_impl->m_uuid, runNumber);
else
m_impl->m_datastore->createItem(m_impl->m_uuid, runNumber);
return Run(std::make_shared<ItemImpl>(
m_impl->m_datastore,
m_impl->m_uuid,
......@@ -167,7 +176,10 @@ Run DataSet::createRun(AsyncEngine& async, const RunNumber& runNumber) {
if(InvalidRunNumber == runNumber) {
throw Exception("Trying to create a Run with InvalidRunNumber");
}
if(async.m_impl)
async.m_impl->createItem(m_impl->m_uuid, runNumber);
else
m_impl->m_datastore->createItem(m_impl->m_uuid, runNumber);
return Run(std::make_shared<ItemImpl>(
m_impl->m_datastore,
m_impl->m_uuid,
......
......@@ -57,7 +57,10 @@ ProductID Event::storeRawData(WriteBatch& batch, const std::string& key, const c
}
// forward the call to the batch's store function
auto& id = m_impl->m_descriptor;
if(batch.m_impl)
return batch.m_impl->storeRawProduct(id, key, value, vsize);
else
return m_impl->m_datastore->storeRawProduct(id, key, value, vsize);
}
ProductID Event::storeRawData(AsyncEngine& async, const std::string& key, const char* value, size_t vsize) {
......@@ -66,7 +69,10 @@ ProductID Event::storeRawData(AsyncEngine& async, const std::string& key, const
}
// forward the call to the async engine's store function
auto& id = m_impl->m_descriptor;
if(async.m_impl)
return async.m_impl->storeRawProduct(id, key, value, vsize);
else
return m_impl->m_datastore->storeRawProduct(id, key, value, vsize);
}
bool Event::loadRawData(const std::string& key, std::string& buffer) const {
......
......@@ -60,7 +60,10 @@ ProductID Run::storeRawData(WriteBatch& batch, const std::string& key, const cha
}
// forward the call to the batch's store function
const ItemDescriptor& id = m_impl->m_descriptor;
if(batch.m_impl)
return batch.m_impl->storeRawProduct(id, key, value, vsize);
else
return m_impl->m_datastore->storeRawProduct(id, key, value, vsize);
}
ProductID Run::storeRawData(AsyncEngine& async, const std::string& key, const char* value, size_t vsize) {
......@@ -69,7 +72,10 @@ ProductID Run::storeRawData(AsyncEngine& async, const std::string& key, const ch
}
// forward the call to the async engine's store function
const ItemDescriptor& id = m_impl->m_descriptor;
if(async.m_impl)
return async.m_impl->storeRawProduct(id, key, value, vsize);
else
return m_impl->m_datastore->storeRawProduct(id, key, value, vsize);
}
bool Run::loadRawData(const std::string& key, std::string& buffer) const {
......@@ -125,7 +131,10 @@ SubRun Run::createSubRun(WriteBatch& batch, const SubRunNumber& subRunNumber) {
throw Exception("Calling Run member function on an invalid Run object");
}
ItemDescriptor& id = m_impl->m_descriptor;
if(batch.m_impl)
batch.m_impl->createItem(id.dataset, id.run, subRunNumber);
else
m_impl->m_datastore->createItem(id.dataset, id.run, subRunNumber);
auto new_subrun_impl = std::make_shared<ItemImpl>(m_impl->m_datastore, id.dataset, id.run, subRunNumber);
return SubRun(std::move(new_subrun_impl));
}
......@@ -135,7 +144,10 @@ SubRun Run::createSubRun(AsyncEngine& async, const SubRunNumber& subRunNumber) {
throw Exception("Calling Run member function on an invalid Run object");
}
ItemDescriptor& id = m_impl->m_descriptor;
if(async.m_impl)
async.m_impl->createItem(id.dataset, id.run, subRunNumber);
else
m_impl->m_datastore->createItem(id.dataset, id.run, subRunNumber);
auto new_subrun_impl = std::make_shared<ItemImpl>(m_impl->m_datastore, id.dataset, id.run, subRunNumber);
return SubRun(std::move(new_subrun_impl));
}
......
......@@ -60,7 +60,10 @@ ProductID SubRun::storeRawData(WriteBatch& batch, const std::string& key, const
}
// forward the call to the batch's store function
auto& id = m_impl->m_descriptor;
if(batch.m_impl)
return batch.m_impl->storeRawProduct(id, key, value, vsize);
else
return m_impl->m_datastore->storeRawProduct(id, key, value, vsize);
}
ProductID SubRun::storeRawData(AsyncEngine& async, const std::string& key, const char* value, size_t vsize) {
......@@ -69,7 +72,10 @@ ProductID SubRun::storeRawData(AsyncEngine& async, const std::string& key, const
}
// forward the call to async engine's store function
auto& id = m_impl->m_descriptor;
if(async.m_impl)
return async.m_impl->storeRawProduct(id, key, value, vsize);
else
return m_impl->m_datastore->storeRawProduct(id, key, value, vsize);
}
bool SubRun::loadRawData(const std::string& key, std::string& buffer) const {
......@@ -121,7 +127,10 @@ Event SubRun::createEvent(WriteBatch& batch, const EventNumber& eventNumber) {
throw Exception("Calling SubRun member function on invalid SubRun object");
}
auto& id = m_impl->m_descriptor;
if(batch.m_impl)
batch.m_impl->createItem(id.dataset, id.run, id.subrun, eventNumber);
else
m_impl->m_datastore->createItem(id.dataset, id.run, id.subrun, eventNumber);
return Event(std::make_shared<ItemImpl>(m_impl->m_datastore, id.dataset, id.run, id.subrun, eventNumber));
}
......@@ -130,7 +139,10 @@ Event SubRun::createEvent(AsyncEngine& async, const EventNumber& eventNumber) {
throw Exception("Calling SubRun member function on invalid SubRun object");
}
auto& id = m_impl->m_descriptor;
if(async.m_impl)
async.m_impl->createItem(id.dataset, id.run, id.subrun, eventNumber);
else
m_impl->m_datastore->createItem(id.dataset, id.run, id.subrun, eventNumber);
return Event(std::make_shared<ItemImpl>(m_impl->m_datastore, id.dataset, id.run, id.subrun, eventNumber));
}
......
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