Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sds
HEP
HEPnOS
Commits
756aeb5e
Commit
756aeb5e
authored
Feb 18, 2020
by
Matthieu Dorier
Browse files
Runs are now using the uuid of their DataSet instead of the full path
parent
591250eb
Changes
9
Hide whitespace changes
Inline
Side-by-side
include/hepnos/Run.hpp
View file @
756aeb5e
...
...
@@ -151,14 +151,6 @@ class Run : public KeyValueContainer {
*/
const
RunNumber
&
number
()
const
;
/**
* @brief Returns the full name of the DataSet containing
* this Run.
*
* @return the full name of the DataSet containing this Run.
*/
const
std
::
string
&
container
()
const
;
class
const_iterator
;
class
iterator
;
...
...
include/hepnos/UUID.hpp
View file @
756aeb5e
...
...
@@ -44,6 +44,8 @@ struct UUID {
static
UUID
generate
();
void
randomize
();
bool
operator
==
(
const
UUID
&
other
)
const
;
};
template
<
typename
T
>
...
...
src/DataSet.cpp
View file @
756aeb5e
...
...
@@ -130,26 +130,27 @@ Run DataSet::createRun(const RunNumber& runNumber) {
if
(
InvalidRunNumber
==
runNumber
)
{
throw
Exception
(
"Trying to create a Run with InvalidRunNumber"
);
}
std
::
string
parent
=
fullname
();
std
::
string
parent
_uuid
=
m_impl
->
m_uuid
.
to_string
();
std
::
string
runStr
=
makeKeyStringFromNumber
(
runNumber
);
m_impl
->
m_datastore
->
store
(
m_impl
->
m_level
+
1
,
parent
,
runStr
);
return
Run
(
std
::
make_shared
<
RunImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
parent
),
runNumber
));
m_impl
->
m_datastore
->
store
(
m_impl
->
m_level
+
1
,
parent_uuid
,
runStr
);
return
Run
(
std
::
make_shared
<
RunImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
m_impl
->
m_uuid
,
runNumber
));
}
Run
DataSet
::
createRun
(
WriteBatch
&
batch
,
const
RunNumber
&
runNumber
)
{
if
(
InvalidRunNumber
==
runNumber
)
{
throw
Exception
(
"Trying to create a Run with InvalidRunNumber"
);
}
std
::
string
parent
=
fullname
();
std
::
string
parent
_uuid
=
m_impl
->
m_uuid
.
to_string
();
std
::
string
runStr
=
makeKeyStringFromNumber
(
runNumber
);
batch
.
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
runStr
);
batch
.
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
_uuid
,
runStr
);
return
Run
(
std
::
make_shared
<
RunImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
parent
)
,
runNumber
));
m_impl
->
m_uuid
,
runNumber
));
}
DataSet
DataSet
::
operator
[](
const
std
::
string
&
datasetName
)
const
{
...
...
src/Run.cpp
View file @
756aeb5e
...
...
@@ -14,7 +14,7 @@ namespace hepnos {
Run
::
iterator
RunImpl
::
m_end
;
Run
::
Run
()
:
m_impl
(
std
::
make_shared
<
RunImpl
>
(
nullptr
,
0
,
std
::
make_shared
<
std
::
string
>
(
""
),
InvalidRunNumber
))
{}
:
m_impl
(
std
::
make_shared
<
RunImpl
>
(
nullptr
,
0
,
UUID
(
),
InvalidRunNumber
))
{}
Run
::
Run
(
std
::
shared_ptr
<
RunImpl
>&&
impl
)
:
m_impl
(
std
::
move
(
impl
))
{
}
...
...
@@ -34,17 +34,17 @@ Run Run::next() const {
std
::
vector
<
std
::
string
>
keys
;
size_t
s
=
m_impl
->
m_datastore
->
nextKeys
(
m_impl
->
m_level
,
*
m_impl
->
m_dataset_
name
,
m_impl
->
m_level
,
m_impl
->
m_dataset_
uuid
.
to_string
()
,
m_impl
->
makeKeyStringFromRunNumber
(),
keys
,
1
);
if
(
s
==
0
)
return
Run
();
size_t
i
=
m_impl
->
m_dataset_name
->
size
()
+
1
;
size_t
i
=
33
;
if
(
keys
[
0
].
size
()
<=
i
)
return
Run
();
RunNumber
rn
=
parseNumberFromKeyString
<
RunNumber
>
(
&
keys
[
0
][
i
]);
if
(
rn
==
InvalidRunNumber
)
return
Run
();
return
Run
(
std
::
make_shared
<
RunImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
,
m_impl
->
m_dataset_
name
,
m_impl
->
m_dataset_
uuid
,
rn
));
}
...
...
@@ -105,13 +105,6 @@ const RunNumber& Run::number() const {
return
m_impl
->
m_run_number
;
}
const
std
::
string
&
Run
::
container
()
const
{
if
(
!
valid
())
{
throw
Exception
(
"Calling Run member function on an invalid Run object"
);
}
return
*
m_impl
->
m_dataset_name
;
}
SubRun
Run
::
createSubRun
(
const
SubRunNumber
&
subRunNumber
)
{
if
(
!
valid
())
{
throw
Exception
(
"Calling Run member function on an invalid Run object"
);
...
...
src/RunImpl.hpp
View file @
756aeb5e
...
...
@@ -21,24 +21,23 @@ class RunImpl {
std
::
shared_ptr
<
DataStoreImpl
>
m_datastore
;
uint8_t
m_level
;
std
::
shared_ptr
<
std
::
string
>
m_dataset_
name
;
UUID
m_dataset_
uuid
;
RunNumber
m_run_number
;
static
Run
::
iterator
m_end
;
RunImpl
(
const
std
::
shared_ptr
<
DataStoreImpl
>&
ds
,
uint8_t
level
,
const
std
::
shared_ptr
<
std
::
string
>&
dataset
,
const
UUID
&
uuid
,
const
RunNumber
&
rn
)
:
m_datastore
(
ds
)
,
m_level
(
level
)
,
m_dataset_
name
(
dataset
)
,
m_dataset_
uuid
(
uuid
)
,
m_run_number
(
rn
)
{}
bool
operator
==
(
const
RunImpl
&
other
)
const
{
if
(
m_run_number
!=
other
.
m_run_number
)
return
false
;
if
(
m_dataset_name
==
other
.
m_dataset_name
)
return
true
;
return
*
m_dataset_name
==
*
other
.
m_dataset_name
;
return
(
m_run_number
==
other
.
m_run_number
)
&&
(
m_dataset_uuid
==
other
.
m_dataset_uuid
);
}
std
::
string
makeKeyStringFromRunNumber
()
const
{
...
...
@@ -46,11 +45,11 @@ class RunImpl {
}
std
::
string
container
()
const
{
return
*
m_dataset_
name
;
return
m_dataset_
uuid
.
to_string
()
;
}
std
::
string
fullpath
()
const
{
return
*
m_dataset_name
+
"/"
+
makeKeyStringFromRunNumber
();
return
container
()
+
"/"
+
makeKeyStringFromRunNumber
();
}
};
...
...
src/RunSet.cpp
View file @
756aeb5e
...
...
@@ -39,17 +39,17 @@ DataStore RunSet::datastore() const {
RunSet
::
iterator
RunSet
::
find
(
const
RunNumber
&
runNumber
)
{
int
ret
;
std
::
string
parent
=
m_impl
->
fullname
();
std
::
string
parent
_uuid
=
m_impl
->
m_uuid
.
to_string
();
std
::
string
strNum
=
makeKeyStringFromNumber
(
runNumber
);
auto
datastore
=
m_impl
->
m_datastore
;
auto
level
=
m_impl
->
m_level
;
bool
b
=
datastore
->
exists
(
level
+
1
,
parent
,
strNum
);
bool
b
=
datastore
->
exists
(
level
+
1
,
parent
_uuid
,
strNum
);
if
(
!
b
)
return
end
();
return
iterator
(
std
::
make_shared
<
RunImpl
>
(
datastore
,
level
+
1
,
std
::
make_shared
<
std
::
string
>
(
parent
)
,
m_impl
->
m_uuid
,
runNumber
));
}
...
...
@@ -64,9 +64,8 @@ RunSet::iterator RunSet::begin() {
auto
ds_level
=
m_impl
->
m_level
;
auto
datastore
=
m_impl
->
m_datastore
;
std
::
string
container
=
m_impl
->
fullname
();
auto
new_run_impl
=
std
::
make_shared
<
RunImpl
>
(
datastore
,
ds_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
container
)
,
0
);
ds_level
+
1
,
m_impl
->
m_uuid
,
0
);
Run
run
(
std
::
move
(
new_run_impl
));
run
=
run
.
next
();
...
...
@@ -103,7 +102,7 @@ RunSet::iterator RunSet::lower_bound(const RunNumber& lb) {
Run
run
(
std
::
make_shared
<
RunImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
m_impl
->
fullname
())
,
0
));
m_impl
->
m_uuid
,
0
));
run
=
run
.
next
();
if
(
!
run
.
valid
())
return
end
();
else
return
iterator
(
run
);
...
...
@@ -117,7 +116,7 @@ RunSet::iterator RunSet::lower_bound(const RunNumber& lb) {
Run
run
(
std
::
make_shared
<
RunImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
m_impl
->
fullname
())
,
lb
-
1
));
m_impl
->
m_uuid
,
lb
-
1
));
run
=
run
.
next
();
if
(
!
run
.
valid
())
return
end
();
else
return
iterator
(
run
);
...
...
@@ -131,8 +130,8 @@ RunSet::const_iterator RunSet::lower_bound(const RunNumber& lb) const {
RunSet
::
iterator
RunSet
::
upper_bound
(
const
RunNumber
&
ub
)
{
Run
run
(
std
::
make_shared
<
RunImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
m_impl
->
fullname
())
,
ub
));
m_impl
->
m_level
+
1
,
m_impl
->
m_uuid
,
ub
));
run
=
run
.
next
();
if
(
!
run
.
valid
())
return
end
();
else
return
iterator
(
run
);
...
...
src/UUID.cpp
View file @
756aeb5e
...
...
@@ -22,4 +22,9 @@ UUID UUID::generate() {
return
result
;
}
bool
UUID
::
operator
==
(
const
UUID
&
other
)
const
{
int
c
=
memcmp
(
data
,
other
.
data
,
sizeof
(
data
));
return
c
==
0
;
}
}
test/DataSetTest.cpp
View file @
756aeb5e
...
...
@@ -28,7 +28,6 @@ void DataSetTest::testFillDataStore() {
hepnos
::
Exception
);
// correct dataset creation
DataSet
ds1
=
mds
.
createDataSet
(
"ds1"
);
std
::
cerr
<<
"AAAA"
<<
std
::
endl
;
// assert the characteristics of the created dataset
CPPUNIT_ASSERT
(
ds1
.
valid
());
CPPUNIT_ASSERT_EQUAL_STR
(
"ds1"
,
ds1
.
name
());
...
...
@@ -36,21 +35,15 @@ void DataSetTest::testFillDataStore() {
CPPUNIT_ASSERT_EQUAL_STR
(
"/matthieu/ds1"
,
ds1
.
fullname
());
// assert access from DataStore using full path
DataSet
matthieu_ds1
=
root
[
"matthieu/ds1"
];
std
::
cerr
<<
"BBBB"
<<
std
::
endl
;
CPPUNIT_ASSERT
(
matthieu_ds1
.
valid
());
CPPUNIT_ASSERT
(
matthieu_ds1
==
ds1
);
std
::
cerr
<<
"CCCC"
<<
std
::
endl
;
// create a dataset inside ds1
DataSet
ds11
=
ds1
.
createDataSet
(
"ds11"
);
std
::
cerr
<<
"DDDD"
<<
std
::
endl
;
CPPUNIT_ASSERT
(
ds11
.
valid
());
std
::
cerr
<<
"EEEE"
<<
std
::
endl
;
// access ds11 using path from "matthieu"
DataSet
ds1_ds11
=
mds
[
"ds1/ds11"
];
std
::
cerr
<<
"FFFF"
<<
std
::
endl
;
CPPUNIT_ASSERT
(
ds1_ds11
.
valid
());
CPPUNIT_ASSERT
(
ds1_ds11
==
ds11
);
std
::
cerr
<<
"GGGG"
<<
std
::
endl
;
// assert comparison with a default-constructed dataset
DataSet
ds0
;
CPPUNIT_ASSERT
(
ds0
!=
ds1
);
...
...
@@ -59,11 +52,8 @@ void DataSetTest::testFillDataStore() {
DataSet
ds2
=
ds1
.
next
();
CPPUNIT_ASSERT
(
!
ds2
.
valid
());
// create more datasets
std
::
cerr
<<
"HHHH"
<<
std
::
endl
;
DataSet
ds3
=
mds
.
createDataSet
(
"ds3"
);
std
::
cerr
<<
"IIII"
<<
std
::
endl
;
ds2
=
mds
.
createDataSet
(
"ds2"
);
std
::
cerr
<<
"JJJJ"
<<
std
::
endl
;
// assert that these are valid
CPPUNIT_ASSERT
(
ds2
.
valid
());
CPPUNIT_ASSERT
(
ds3
.
valid
());
...
...
@@ -72,9 +62,7 @@ void DataSetTest::testFillDataStore() {
CPPUNIT_ASSERT
(
ds3
==
ds2
.
next
());
// create more datasets for future tests
DataSet
ds4
=
mds
.
createDataSet
(
"dsB"
);
std
::
cerr
<<
"KKKK"
<<
std
::
endl
;
DataSet
ds5
=
mds
.
createDataSet
(
"dsD"
);
std
::
cerr
<<
"LLLL"
<<
std
::
endl
;
CPPUNIT_ASSERT
(
ds4
.
valid
());
CPPUNIT_ASSERT
(
ds5
.
valid
());
}
...
...
@@ -193,7 +181,6 @@ void DataSetTest::testCreateRuns() {
Run
r
=
mds
.
createRun
(
45
);
CPPUNIT_ASSERT
(
r
.
valid
());
CPPUNIT_ASSERT
(
45
==
r
.
number
());
CPPUNIT_ASSERT_EQUAL_STR
(
"/matthieu"
,
r
.
container
());
}
}
test/RunSetTest.cpp
View file @
756aeb5e
...
...
@@ -26,7 +26,6 @@ void RunSetTest::testFillDataStore() {
// assert the characteristics of the created dataset
CPPUNIT_ASSERT
(
r1
.
valid
());
CPPUNIT_ASSERT
(
42
==
r1
.
number
());
CPPUNIT_ASSERT_EQUAL_STR
(
"/matthieu"
,
r1
.
container
());
// assert comparison with a default-constructed run
CPPUNIT_ASSERT
(
r0
!=
r1
);
CPPUNIT_ASSERT
(
!
(
r0
==
r1
));
...
...
@@ -62,7 +61,6 @@ void RunSetTest::testBraketOperator() {
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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment