Commit 9854b9a1 authored by Matthieu Dorier's avatar Matthieu Dorier

changed parenthesis into brakets for access to runs, subruns, and events

parent 65c43208
......@@ -372,7 +372,7 @@ class DataSet : public KeyValueContainer {
const RunSet& runs() const;
/**
* @brief Accesses an existing run using the ()
* @brief Accesses an existing run using the []
* operator. If no run corresponds to the provided run number,
* the function returns a Run instance d such that
* r.valid() is false.
......@@ -381,7 +381,7 @@ class DataSet : public KeyValueContainer {
*
* @return a Run corresponding to the provided run number.
*/
Run operator()(const RunNumber& runNumber) const;
Run operator[](const RunNumber& runNumber) const;
};
}
......
......@@ -282,7 +282,7 @@ class Run : public KeyValueContainer {
const_iterator upper_bound(const SubRunNumber&) const;
/**
* @brief Accesses an existing ubun using the ()
* @brief Accesses an existing ubun using the []
* operator. If no run corresponds to the provided subrun number,
* the function returns a SubRun instance r such that
* r.valid() is false.
......@@ -291,7 +291,7 @@ class Run : public KeyValueContainer {
*
* @return a SubRun corresponding to the provided subrun number.
*/
SubRun operator()(const SubRunNumber& subRunNumber) const;
SubRun operator[](const SubRunNumber& subRunNumber) const;
/**
* @brief Creates a SubRun within this Run, with the provided
......
......@@ -83,7 +83,7 @@ class RunSet {
class iterator;
/**
* @brief Accesses an existing Run using the ()
* @brief Accesses an existing Run using the []
* operator. If no Run correspond to the provided number,
* the function returns a Run instance r such that
* r.valid() is false.
......@@ -92,7 +92,7 @@ class RunSet {
*
* @return a Run corresponding to the provided number.
*/
Run operator()(const RunNumber& runNumber);
Run operator[](const RunNumber& runNumber);
/**
* @brief Searches this RunSet for a Run with
......
......@@ -271,7 +271,7 @@ class SubRun : public KeyValueContainer {
const_iterator upper_bound(const SubRunNumber&) const;
/**
* @brief Accesses an existing event using the ()
* @brief Accesses an existing event using the []
* operator. If no run corresponds to the provided run number,
* the function returns a Run instance d such that
* r.valid() is false.
......@@ -280,7 +280,7 @@ class SubRun : public KeyValueContainer {
*
* @return an Event corresponding to the provided event number.
*/
Event operator()(const EventNumber& eventNumber) const;
Event operator[](const EventNumber& eventNumber) const;
/**
* @brief Creates an Event within this SubRun, with the provided
......
......@@ -144,7 +144,7 @@ DataSet DataSet::operator[](const std::string& datasetName) const {
return std::move(*it);
}
Run DataSet::operator()(const RunNumber& runNumber) const {
Run DataSet::operator[](const RunNumber& runNumber) const {
auto it = runs().find(runNumber);
return std::move(*it);
}
......
......@@ -97,7 +97,7 @@ SubRun Run::createSubRun(const SubRunNumber& subRunNumber) {
return SubRun(m_impl->m_datastore, m_impl->m_level+1, parent, subRunNumber);
}
SubRun Run::operator()(const SubRunNumber& subRunNumber) const {
SubRun Run::operator[](const SubRunNumber& subRunNumber) const {
auto it = find(subRunNumber);
return std::move(*it);
}
......
......@@ -25,7 +25,7 @@ RunSet::RunSet(DataSet* ds)
RunSet::~RunSet() {}
Run RunSet::operator()(const RunNumber& runNumber) {
Run RunSet::operator[](const RunNumber& runNumber) {
auto it = find(runNumber);
return std::move(*it);
}
......
......@@ -94,7 +94,7 @@ Event SubRun::createEvent(const EventNumber& eventNumber) {
return Event(m_impl->m_datastore, m_impl->m_level+1, parent, eventNumber);
}
Event SubRun::operator()(const EventNumber& eventNumber) const {
Event SubRun::operator[](const EventNumber& eventNumber) const {
auto it = find(eventNumber);
return std::move(*it);
}
......
......@@ -307,10 +307,17 @@ class DataStore::Impl {
DataStoreEntryPtr entry = make_datastore_entry(level, ss.str());
auto ph = m_sdskv_ph[provider_idx];
auto db_id = m_sdskv_db[provider_idx];
// check if the key exists
hg_size_t vsize;
int ret = sdskv_length(ph, db_id, entry->raw(), entry->length(), &vsize);
if(ret == HG_SUCCESS) return false; // key already exists
if(ret != SDSKV_ERR_UNKNOWN_KEY) { // there was a problem with sdskv
throw Exception("Could not check if key exists in SDSKV (sdskv_length error)");
}
std::cerr << "[LOG] store (level=" << (int)level
<< ", container=\"" << containerName << "\", object=\""
<< objectName << "\")" << std::endl;
int ret = sdskv_put(ph, db_id, entry->raw(), entry->length(), data.data(), data.size());
ret = sdskv_put(ph, db_id, entry->raw(), entry->length(), data.data(), data.size());
if(ret != SDSKV_SUCCESS) {
throw Exception("Could not put key/value pair in SDSKV (sdskv_put error)");
}
......
......@@ -25,9 +25,13 @@ target_link_libraries(SubRunTest cppunit hepnos hepnos-service)
add_executable(EventTest EventTest.cpp HEPnOSTestMain.cpp)
target_link_libraries(EventTest cppunit hepnos hepnos-service)
add_executable(LoadStoreTest LoadStoreTest.cpp HEPnOSTestMain.cpp)
target_link_libraries(LoadStoreTest cppunit hepnos hepnos-service boost_serialization)
add_test(NAME DataStoreTest COMMAND run-test.sh ./DataStoreTest)
add_test(NAME DataSetTest COMMAND run-test.sh ./DataSetTest)
add_test(NAME RunSetTest COMMAND run-test.sh ./RunSetTest)
add_test(NAME RunTest COMMAND run-test.sh ./RunTest)
add_test(NAME SubRunTest COMMAND run-test.sh ./SubRunTest)
add_test(NAME EventTest COMMAND run-test.sh ./EventTest)
add_test(NAME LoadStoreTest COMMAND run-test.sh ./LoadStoreTest)
......@@ -158,7 +158,7 @@ void DataSetTest::testCreateRuns() {
CPPUNIT_ASSERT(mds.valid());
{
Run r = mds(45);
Run r = mds[45];
CPPUNIT_ASSERT(!r.valid());
CPPUNIT_ASSERT(r.number() == InvalidRunNumber);
}
......
......@@ -49,24 +49,24 @@ void RunSetTest::testFillDataStore() {
CPPUNIT_ASSERT(r5.valid());
}
void RunSetTest::testParenthesisOperator() {
void RunSetTest::testBraketOperator() {
DataSet mds = (*datastore)["matthieu"];
CPPUNIT_ASSERT(mds.valid());
// check that accessing a Run that does not exist
// yields a non-valid Run instance
Run r6 = mds(43);
Run r6 = mds[43];
CPPUNIT_ASSERT(!r6.valid());
// check that accessing a run that exists yields
// a valid Run instance with correct information
Run r2 = mds(45);
Run r2 = mds[45];
CPPUNIT_ASSERT(r2.valid());
CPPUNIT_ASSERT(45 == r2.number());
CPPUNIT_ASSERT_EQUAL_STR("matthieu", r2.container());
// check that we access the same Run using the runs() function
// to go through the RunSet
Run r22 = mds.runs()(45);
Run r22 = mds.runs()[45];
CPPUNIT_ASSERT(r2 == r22);
}
......@@ -153,10 +153,10 @@ void RunSetTest::testLowerUpperBounds() {
void RunSetTest::testCreateSubRuns() {
DataSet mds = (*datastore)["matthieu"];
CPPUNIT_ASSERT(mds.valid());
Run r2 = mds(45);
Run r2 = mds[45];
{
SubRun sr = r2(73);
SubRun sr = r2[73];
CPPUNIT_ASSERT(!sr.valid());
CPPUNIT_ASSERT(sr.number() == InvalidSubRunNumber);
}
......
......@@ -10,7 +10,7 @@ class RunSetTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( RunSetTest );
CPPUNIT_TEST( testFillDataStore );
CPPUNIT_TEST( testParenthesisOperator );
CPPUNIT_TEST( testBraketOperator );
CPPUNIT_TEST( testFind );
CPPUNIT_TEST( testBeginEnd );
CPPUNIT_TEST( testLowerUpperBounds );
......@@ -23,7 +23,7 @@ class RunSetTest : public CppUnit::TestFixture
void tearDown();
void testFillDataStore();
void testParenthesisOperator();
void testBraketOperator();
void testFind();
void testBeginEnd();
void testLowerUpperBounds();
......
......@@ -20,7 +20,7 @@ void RunTest::testFillDataStore() {
void RunTest::testCreateSubRuns() {
DataSet mds = (*datastore)["matthieu"];
CPPUNIT_ASSERT(mds.valid());
Run r1 = mds(42);
Run r1 = mds[42];
SubRun sr10 = r1.createSubRun(10);
CPPUNIT_ASSERT(sr10.valid());
......@@ -39,20 +39,20 @@ void RunTest::testCreateSubRuns() {
CPPUNIT_ASSERT(38 == sr38.number());
}
void RunTest::testParenthesisOperator() {
void RunTest::testBraketOperator() {
DataSet mds = (*datastore)["matthieu"];
CPPUNIT_ASSERT(mds.valid());
Run r1 = mds(42);
Run r1 = mds[42];
CPPUNIT_ASSERT(r1.valid());
// check access to non-existing SubRun
SubRun sr0 = r1(12);
SubRun sr0 = r1[12];
CPPUNIT_ASSERT(!sr0.valid());
CPPUNIT_ASSERT(sr0.number() == InvalidSubRunNumber);
// check access to existing SubRun
SubRun sr13 = r1(13);
SubRun sr13 = r1[13];
CPPUNIT_ASSERT(sr13.valid());
CPPUNIT_ASSERT(13 == sr13.number());
}
......@@ -60,7 +60,7 @@ void RunTest::testParenthesisOperator() {
void RunTest::testFind() {
DataSet mds = (*datastore)["matthieu"];
CPPUNIT_ASSERT(mds.valid());
Run r1 = mds(42);
Run r1 = mds[42];
CPPUNIT_ASSERT(r1.valid());
// test calling find for a SubRun that does not exist
{
......@@ -84,7 +84,7 @@ void RunTest::testFind() {
void RunTest::testBeginEnd() {
DataSet mds = (*datastore)["matthieu"];
CPPUNIT_ASSERT(mds.valid());
Run r1 = mds(42);
Run r1 = mds[42];
CPPUNIT_ASSERT(r1.valid());
std::vector<SubRunNumber> numbers = {10, 13, 23, 38};
......@@ -98,7 +98,7 @@ void RunTest::testBeginEnd() {
void RunTest::testLowerUpperBounds() {
DataSet mds = (*datastore)["matthieu"];
CPPUNIT_ASSERT(mds.valid());
Run r1 = mds(42);
Run r1 = mds[42];
CPPUNIT_ASSERT(r1.valid());
{
......
......@@ -11,7 +11,7 @@ class RunTest : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE( RunTest );
CPPUNIT_TEST( testFillDataStore );
CPPUNIT_TEST( testCreateSubRuns );
CPPUNIT_TEST( testParenthesisOperator );
CPPUNIT_TEST( testBraketOperator );
CPPUNIT_TEST( testFind );
CPPUNIT_TEST( testBeginEnd );
CPPUNIT_TEST( testLowerUpperBounds );
......@@ -24,7 +24,7 @@ class RunTest : public CppUnit::TestFixture
void testFillDataStore();
void testCreateSubRuns();
void testParenthesisOperator();
void testBraketOperator();
void testFind();
void testBeginEnd();
void testLowerUpperBounds();
......
......@@ -21,9 +21,9 @@ void SubRunTest::testFillDataStore() {
void SubRunTest::testCreateEvents() {
DataSet mds = (*datastore)["matthieu"];
CPPUNIT_ASSERT(mds.valid());
Run r1 = mds(42);
Run r1 = mds[42];
CPPUNIT_ASSERT(r1.valid());
SubRun sr1 = r1(3);
SubRun sr1 = r1[3];
CPPUNIT_ASSERT(sr1.valid());
Event e10 = sr1.createEvent(10);
......@@ -43,21 +43,21 @@ void SubRunTest::testCreateEvents() {
CPPUNIT_ASSERT(38 == e38.number());
}
void SubRunTest::testParenthesisOperator() {
void SubRunTest::testBraketOperator() {
DataSet mds = (*datastore)["matthieu"];
CPPUNIT_ASSERT(mds.valid());
Run r1 = mds(42);
Run r1 = mds[42];
CPPUNIT_ASSERT(r1.valid());
SubRun sr1 = r1(3);
SubRun sr1 = r1[3];
CPPUNIT_ASSERT(sr1.valid());
// check access to non-existing SubRun
Event e0 = sr1(12);
Event e0 = sr1[12];
CPPUNIT_ASSERT(!e0.valid());
CPPUNIT_ASSERT(e0.number() == InvalidEventNumber);
// check access to existing SubRun
Event e13 = sr1(13);
Event e13 = sr1[13];
CPPUNIT_ASSERT(e13.valid());
CPPUNIT_ASSERT(13 == e13.number());
}
......@@ -65,9 +65,9 @@ void SubRunTest::testParenthesisOperator() {
void SubRunTest::testFind() {
DataSet mds = (*datastore)["matthieu"];
CPPUNIT_ASSERT(mds.valid());
Run r1 = mds(42);
Run r1 = mds[42];
CPPUNIT_ASSERT(r1.valid());
SubRun sr1 = r1(3);
SubRun sr1 = r1[3];
CPPUNIT_ASSERT(sr1.valid());
// test calling find for a SubRun that does not exist
{
......@@ -91,9 +91,9 @@ void SubRunTest::testFind() {
void SubRunTest::testBeginEnd() {
DataSet mds = (*datastore)["matthieu"];
CPPUNIT_ASSERT(mds.valid());
Run r1 = mds(42);
Run r1 = mds[42];
CPPUNIT_ASSERT(r1.valid());
SubRun sr1 = r1(3);
SubRun sr1 = r1[3];
CPPUNIT_ASSERT(sr1.valid());
std::vector<EventNumber> numbers = {10, 13, 23, 38};
......@@ -107,9 +107,9 @@ void SubRunTest::testBeginEnd() {
void SubRunTest::testLowerUpperBounds() {
DataSet mds = (*datastore)["matthieu"];
CPPUNIT_ASSERT(mds.valid());
Run r1 = mds(42);
Run r1 = mds[42];
CPPUNIT_ASSERT(r1.valid());
SubRun sr1 = r1(3);
SubRun sr1 = r1[3];
CPPUNIT_ASSERT(sr1.valid());
{
......
......@@ -11,7 +11,7 @@ class SubRunTest : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE( SubRunTest );
CPPUNIT_TEST( testFillDataStore );
CPPUNIT_TEST( testCreateEvents );
CPPUNIT_TEST( testParenthesisOperator );
CPPUNIT_TEST( testBraketOperator );
CPPUNIT_TEST( testFind );
CPPUNIT_TEST( testBeginEnd );
CPPUNIT_TEST( testLowerUpperBounds );
......@@ -24,7 +24,7 @@ class SubRunTest : public CppUnit::TestFixture
void testFillDataStore();
void testCreateEvents();
void testParenthesisOperator();
void testBraketOperator();
void testFind();
void testBeginEnd();
void testLowerUpperBounds();
......
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