Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sds
HEP
HEPnOS
Commits
86650843
Commit
86650843
authored
Jan 30, 2020
by
Matthieu Dorier
Browse files
removing the use of boost if type is POD
parent
41e684e6
Changes
14
Hide whitespace changes
Inline
Side-by-side
include/hepnos/DataSet.hpp
View file @
86650843
...
...
@@ -162,10 +162,8 @@ class DataSet : public KeyValueContainer {
* @return a valid ProductID if the key did not already exist and the write succeeded,
* an invalid one otherwise.
*/
ProductID
storeRawData
(
const
std
::
string
&
key
,
const
std
::
string
&
value
)
override
;
ProductID
storeRawData
(
std
::
string
&&
key
,
std
::
string
&&
value
)
override
;
ProductID
storeRawData
(
WriteBatch
&
batch
,
const
std
::
string
&
key
,
const
std
::
string
&
value
)
override
;
ProductID
storeRawData
(
WriteBatch
&
batch
,
std
::
string
&&
key
,
std
::
string
&&
value
)
override
;
ProductID
storeRawData
(
const
std
::
string
&
key
,
const
char
*
value
,
size_t
vsize
)
override
;
ProductID
storeRawData
(
WriteBatch
&
batch
,
const
std
::
string
&
key
,
const
char
*
value
,
size_t
vsize
)
override
;
/**
* @brief Loads binary data associated with a particular key from the DataSet.
...
...
@@ -179,6 +177,7 @@ class DataSet : public KeyValueContainer {
* false otherwise.
*/
bool
loadRawData
(
const
std
::
string
&
key
,
std
::
string
&
value
)
const
override
;
bool
loadRawData
(
const
std
::
string
&
key
,
char
*
value
,
size_t
*
vsize
)
const
override
;
/**
* @brief Comparison operator.
...
...
include/hepnos/DataStore.hpp
View file @
86650843
...
...
@@ -330,6 +330,13 @@ class DataStore {
* @return true if the data was loaded successfuly, false otherwise.
*/
bool
loadRawProduct
(
const
ProductID
&
productID
,
std
::
string
&
buffer
);
bool
loadRawProduct
(
const
ProductID
&
productID
,
char
*
value
,
size_t
*
value_size
);
template
<
typename
T
>
bool
loadProductImpl
(
const
ProductID
&
productID
,
T
&
t
,
const
std
::
integral_constant
<
bool
,
false
>&
);
template
<
typename
T
>
bool
loadProductImpl
(
const
ProductID
&
productID
,
T
&
t
,
const
std
::
integral_constant
<
bool
,
true
>&
);
};
class
DataStore
::
const_iterator
{
...
...
@@ -574,6 +581,11 @@ Ptr<T,C> DataStore::makePtr(const ProductID& productID, std::size_t index) {
template
<
typename
T
>
bool
DataStore
::
loadProduct
(
const
ProductID
&
productID
,
T
&
t
)
{
return
loadProductImpl
(
productID
,
t
,
std
::
is_pod
<
T
>
());
}
template
<
typename
T
>
bool
DataStore
::
loadProductImpl
(
const
ProductID
&
productID
,
T
&
t
,
const
std
::
integral_constant
<
bool
,
false
>&
)
{
std
::
string
buffer
;
if
(
!
loadRawProduct
(
productID
,
buffer
))
{
return
false
;
...
...
@@ -589,6 +601,16 @@ bool DataStore::loadProduct(const ProductID& productID, T& t) {
return
true
;
}
template
<
typename
T
>
bool
DataStore
::
loadProductImpl
(
const
ProductID
&
productID
,
T
&
t
,
const
std
::
integral_constant
<
bool
,
true
>&
)
{
size_t
value_size
=
sizeof
(
t
);
if
(
loadRawProduct
(
productID
,
reinterpret_cast
<
char
*>
(
&
t
),
&
value_size
))
{
return
value_size
==
sizeof
(
t
);
}
else
{
return
false
;
}
}
}
#endif
include/hepnos/Event.hpp
View file @
86650843
...
...
@@ -109,10 +109,8 @@ class Event : public KeyValueContainer {
*
* @return a valid ProductID if the key did not already exist, an invalid one otherwise.
*/
ProductID
storeRawData
(
const
std
::
string
&
key
,
const
std
::
string
&
value
)
override
;
ProductID
storeRawData
(
std
::
string
&&
key
,
std
::
string
&&
value
)
override
;
ProductID
storeRawData
(
WriteBatch
&
batch
,
const
std
::
string
&
key
,
const
std
::
string
&
value
)
override
;
ProductID
storeRawData
(
WriteBatch
&
batch
,
std
::
string
&&
key
,
std
::
string
&&
value
)
override
;
ProductID
storeRawData
(
const
std
::
string
&
key
,
const
char
*
value
,
size_t
vsize
)
override
;
ProductID
storeRawData
(
WriteBatch
&
batch
,
const
std
::
string
&
key
,
const
char
*
value
,
size_t
vsize
)
override
;
/**
* @brief Loads raw key/value data from this Event.
...
...
@@ -123,6 +121,7 @@ class Event : public KeyValueContainer {
* @return true if the key exists, false otherwise.
*/
bool
loadRawData
(
const
std
::
string
&
key
,
std
::
string
&
value
)
const
override
;
bool
loadRawData
(
const
std
::
string
&
key
,
char
*
value
,
size_t
*
vsize
)
const
override
;
/**
* @brief Compares this Event with another Event. The Events must point to
...
...
include/hepnos/KeyValueContainer.hpp
View file @
86650843
...
...
@@ -67,17 +67,25 @@ class KeyValueContainer {
* This function is virtual and must be overloaded in the child class.
*
* @param key Key
* @param buffer Value
* @param value Value pointer
* @param vsize Value size (in bytes)
*
* @return A valid ProductID if the key did not already exist, an invalid one otherwise.
*/
virtual
ProductID
storeRawData
(
const
std
::
string
&
key
,
const
std
::
string
&
valu
e
)
=
0
;
virtual
ProductID
storeRawData
(
const
std
::
string
&
key
,
const
char
*
value
,
size_t
vsiz
e
)
=
0
;
virtual
ProductID
storeRawData
(
std
::
string
&&
key
,
std
::
string
&&
value
)
=
0
;
virtual
ProductID
storeRawData
(
WriteBatch
&
batch
,
const
std
::
string
&
key
,
const
std
::
string
&
value
)
=
0
;
virtual
ProductID
storeRawData
(
WriteBatch
&
batch
,
std
::
string
&&
key
,
std
::
string
&&
value
)
=
0
;
/**
* @brief Stores raw key/value data in a WriteBatch.
* This function is virtual and must be overloaded in the child class.
*
* @param batch Batch in which to write.
* @param key Key
* @param value Value pointer
* @param vsize Value size (in bytes)
*
* @return
*/
virtual
ProductID
storeRawData
(
WriteBatch
&
batch
,
const
std
::
string
&
key
,
const
char
*
value
,
size_t
vsize
)
=
0
;
/**
* @brief Loads raw key/value data from this KeyValueContainer.
...
...
@@ -90,6 +98,8 @@ class KeyValueContainer {
*/
virtual
bool
loadRawData
(
const
std
::
string
&
key
,
std
::
string
&
buffer
)
const
=
0
;
virtual
bool
loadRawData
(
const
std
::
string
&
key
,
char
*
value
,
size_t
*
vsize
)
const
=
0
;
/**
* @brief Stores a key/value pair into the KeyValueContainer.
* The type of the key should have operator<< available
...
...
@@ -107,16 +117,12 @@ class KeyValueContainer {
*/
template
<
typename
K
,
typename
V
>
ProductID
store
(
const
K
&
key
,
const
V
&
value
)
{
std
::
string
key_str
,
val_str
;
serializeKeyValue
(
key
,
value
,
key_str
,
val_str
);
return
storeRawData
(
std
::
move
(
key_str
),
std
::
move
(
val_str
));
return
storeImpl
(
key
,
value
,
std
::
is_pod
<
V
>
());
}
template
<
typename
K
,
typename
V
>
ProductID
store
(
WriteBatch
&
batch
,
const
K
&
key
,
const
V
&
value
)
{
std
::
string
key_str
,
val_str
;
serializeKeyValue
(
key
,
value
,
key_str
,
val_str
);
return
storeRawData
(
batch
,
std
::
move
(
key_str
),
std
::
move
(
val_str
));
return
storeImpl
(
batch
,
key
,
value
,
std
::
is_pod
<
V
>
());
}
/**
...
...
@@ -136,6 +142,59 @@ class KeyValueContainer {
*/
template
<
typename
K
,
typename
V
>
bool
load
(
const
K
&
key
,
V
&
value
)
const
{
return
loadImpl
(
key
,
value
,
std
::
is_pod
<
V
>
());
}
private:
template
<
typename
K
,
typename
V
>
ProductID
storeImpl
(
const
K
&
key
,
const
V
&
value
,
const
std
::
integral_constant
<
bool
,
false
>&
)
{
std
::
string
key_str
,
val_str
;
serializeKeyValue
(
key
,
value
,
key_str
,
val_str
);
return
storeRawData
(
key_str
,
val_str
.
data
(),
val_str
.
size
());
}
template
<
typename
K
,
typename
V
>
ProductID
storeImpl
(
WriteBatch
&
batch
,
const
K
&
key
,
const
V
&
value
,
const
std
::
integral_constant
<
bool
,
false
>&
)
{
std
::
string
key_str
,
val_str
;
serializeKeyValue
(
key
,
value
,
key_str
,
val_str
);
return
storeRawData
(
batch
,
key_str
,
val_str
.
data
(),
val_str
.
size
());
}
template
<
typename
K
,
typename
V
>
ProductID
storeImpl
(
const
K
&
key
,
const
V
&
value
,
const
std
::
integral_constant
<
bool
,
true
>&
)
{
std
::
string
key_str
;
serializeKeyValue
(
key
,
value
,
key_str
);
return
storeRawData
(
key_str
,
reinterpret_cast
<
const
char
*>
(
&
value
),
sizeof
(
value
));
}
template
<
typename
K
,
typename
V
>
ProductID
storeImpl
(
WriteBatch
&
batch
,
const
K
&
key
,
const
V
&
value
,
const
std
::
integral_constant
<
bool
,
true
>&
)
{
std
::
string
key_str
;
serializeKeyValue
(
key
,
value
,
key_str
);
return
storeRawData
(
batch
,
key_str
,
reinterpret_cast
<
const
char
*>
(
&
value
),
sizeof
(
value
));
}
template
<
typename
K
,
typename
V
>
bool
loadImpl
(
const
K
&
key
,
V
&
value
,
const
std
::
integral_constant
<
bool
,
true
>&
)
const
{
std
::
string
buffer
;
std
::
stringstream
ss_key
;
ss_key
<<
key
<<
"#"
<<
demangle
<
V
>
();
size_t
vsize
=
sizeof
(
value
);
if
(
!
loadRawData
(
ss_key
.
str
(),
reinterpret_cast
<
char
*>
(
&
value
),
&
vsize
))
{
return
false
;
}
return
vsize
==
sizeof
(
value
);
}
template
<
typename
K
,
typename
V
>
bool
loadImpl
(
const
K
&
key
,
V
&
value
,
const
std
::
integral_constant
<
bool
,
false
>&
)
const
{
std
::
string
buffer
;
std
::
stringstream
ss_key
;
ss_key
<<
key
<<
"#"
<<
demangle
<
V
>
();
...
...
@@ -152,15 +211,11 @@ class KeyValueContainer {
return
true
;
}
private:
template
<
typename
K
,
typename
V
>
static
void
serializeKeyValue
(
const
K
&
key
,
const
V
&
value
,
std
::
string
&
key_str
,
std
::
string
&
value_str
)
{
serializeKeyValue
(
key
,
value
,
key_str
);
std
::
stringstream
ss_value
;
std
::
stringstream
ss_key
;
ss_key
<<
key
<<
"#"
<<
demangle
<
V
>
();
key_str
=
std
::
move
(
ss_key
.
str
());
boost
::
archive
::
binary_oarchive
oa
(
ss_value
,
boost
::
archive
::
archive_flags
::
no_header
);
try
{
oa
<<
value
;
...
...
@@ -169,6 +224,13 @@ class KeyValueContainer {
}
value_str
=
ss_value
.
str
();
}
template
<
typename
K
,
typename
V
>
static
void
serializeKeyValue
(
const
K
&
key
,
const
V
&
value
,
std
::
string
&
key_str
)
{
std
::
stringstream
ss_key
;
ss_key
<<
key
<<
"#"
<<
demangle
<
V
>
();
key_str
=
std
::
move
(
ss_key
.
str
());
}
};
}
...
...
include/hepnos/Run.hpp
View file @
86650843
...
...
@@ -116,10 +116,9 @@ class Run : public KeyValueContainer {
*
* @return a valid ProductID if the key did not already exist, an invalid one otherwise.
*/
ProductID
storeRawData
(
const
std
::
string
&
key
,
const
std
::
string
&
value
)
override
;
ProductID
storeRawData
(
std
::
string
&&
key
,
std
::
string
&&
value
)
override
;
ProductID
storeRawData
(
WriteBatch
&
batch
,
const
std
::
string
&
key
,
const
std
::
string
&
value
)
override
;
ProductID
storeRawData
(
WriteBatch
&
batch
,
std
::
string
&&
key
,
std
::
string
&&
value
)
override
;
ProductID
storeRawData
(
const
std
::
string
&
key
,
const
char
*
value
,
size_t
vsize
)
override
;
ProductID
storeRawData
(
WriteBatch
&
batch
,
const
std
::
string
&
key
,
const
char
*
value
,
size_t
vsize
)
override
;
/**
* @brief Loads raw key/value data from this Run.
*
...
...
@@ -129,6 +128,7 @@ class Run : public KeyValueContainer {
* @return true if the key exists, false otherwise.
*/
bool
loadRawData
(
const
std
::
string
&
key
,
std
::
string
&
buffer
)
const
override
;
bool
loadRawData
(
const
std
::
string
&
key
,
char
*
value
,
size_t
*
vsize
)
const
override
;
/**
* @brief Compares this Run with another Run. The Runs must point to
...
...
include/hepnos/SubRun.hpp
View file @
86650843
...
...
@@ -112,10 +112,8 @@ class SubRun : public KeyValueContainer {
*
* @return a valid ProductID if the key did not already exist, an invalid one otherwise.
*/
ProductID
storeRawData
(
const
std
::
string
&
key
,
const
std
::
string
&
value
)
override
;
ProductID
storeRawData
(
std
::
string
&&
key
,
std
::
string
&&
value
)
override
;
ProductID
storeRawData
(
WriteBatch
&
batch
,
const
std
::
string
&
key
,
const
std
::
string
&
value
)
override
;
ProductID
storeRawData
(
WriteBatch
&
batch
,
std
::
string
&&
key
,
std
::
string
&&
value
)
override
;
ProductID
storeRawData
(
const
std
::
string
&
key
,
const
char
*
value
,
size_t
vsize
)
override
;
ProductID
storeRawData
(
WriteBatch
&
batch
,
const
std
::
string
&
key
,
const
char
*
value
,
size_t
vsize
)
override
;
/**
* @brief Loads raw key/value data from this SubRun.
...
...
@@ -126,6 +124,7 @@ class SubRun : public KeyValueContainer {
* @return true if the key exists, false otherwise.
*/
bool
loadRawData
(
const
std
::
string
&
key
,
std
::
string
&
buffer
)
const
override
;
bool
loadRawData
(
const
std
::
string
&
key
,
char
*
value
,
size_t
*
vsize
)
const
override
;
/**
* @brief Compares this SubRun with another SubRun. The SubRuns must point to
...
...
src/DataSet.cpp
View file @
86650843
...
...
@@ -94,40 +94,36 @@ bool DataSet::valid() const {
return
m_impl
&&
m_impl
->
m_datastore
;
}
ProductID
DataSet
::
storeRawData
(
const
std
::
string
&
key
,
const
std
::
string
&
buffer
)
{
ProductID
DataSet
::
storeRawData
(
const
std
::
string
&
key
,
const
char
*
value
,
size_t
vsize
)
{
if
(
!
valid
())
{
throw
Exception
(
"Calling DataSet member function on an invalid DataSet"
);
}
// forward the call to the datastore's store function
return
m_impl
->
m_datastore
->
m_impl
->
store
(
0
,
fullname
(),
key
,
buffer
);
return
m_impl
->
m_datastore
->
m_impl
->
store
(
0
,
fullname
(),
key
,
value
,
vsize
);
}
ProductID
DataSet
::
storeRawData
(
std
::
string
&&
key
,
std
::
string
&&
buffer
)
{
return
storeRawData
(
key
,
buffer
);
// will call the function above
}
ProductID
DataSet
::
storeRawData
(
WriteBatch
&
batch
,
const
std
::
string
&
key
,
const
std
::
string
&
buffer
)
{
ProductID
DataSet
::
storeRawData
(
WriteBatch
&
batch
,
const
std
::
string
&
key
,
const
char
*
value
,
size_t
vsize
)
{
if
(
!
valid
())
{
throw
Exception
(
"Calling DataSet member function on an invalid DataSet"
);
}
// forward the call to the datastore's store function
return
batch
.
m_impl
->
store
(
0
,
fullname
(),
key
,
buffer
);
return
batch
.
m_impl
->
store
(
0
,
fullname
(),
key
,
value
,
vsize
);
}
ProductID
DataSet
::
store
RawData
(
WriteBatch
&
batch
,
std
::
string
&
&
key
,
std
::
string
&
&
buffer
)
{
bool
DataSet
::
load
RawData
(
const
std
::
string
&
key
,
std
::
string
&
buffer
)
const
{
if
(
!
valid
())
{
throw
Exception
(
"Calling DataSet member function on an invalid DataSet"
);
}
// forward the call to the datastore's
store
function
return
batch
.
m_impl
->
store
(
0
,
fullname
(),
std
::
move
(
key
)
,
std
::
move
(
buffer
)
)
;
// forward the call to the datastore's
load
function
return
m_impl
->
m_datastore
->
m_impl
->
load
(
0
,
fullname
(),
key
,
buffer
);
}
bool
DataSet
::
loadRawData
(
const
std
::
string
&
key
,
std
::
string
&
buffer
)
const
{
bool
DataSet
::
loadRawData
(
const
std
::
string
&
key
,
char
*
value
,
size_t
*
vsize
)
const
{
if
(
!
valid
())
{
throw
Exception
(
"Calling DataSet member function on an invalid DataSet"
);
}
// forward the call to the datastore's load function
return
m_impl
->
m_datastore
->
m_impl
->
load
(
0
,
fullname
(),
key
,
buffer
);
return
m_impl
->
m_datastore
->
m_impl
->
load
(
0
,
fullname
(),
key
,
value
,
vsize
);
}
bool
DataSet
::
operator
==
(
const
DataSet
&
other
)
const
{
...
...
@@ -174,7 +170,7 @@ DataSet DataSet::createDataSet(const std::string& name) {
throw
Exception
(
"Invalid character '/' or '%' in dataset name"
);
}
std
::
string
parent
=
fullname
();
m_impl
->
m_datastore
->
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
name
,
std
::
string
()
);
m_impl
->
m_datastore
->
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
name
);
return
DataSet
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
parent
),
name
);
}
...
...
@@ -184,7 +180,7 @@ Run DataSet::createRun(const RunNumber& runNumber) {
}
std
::
string
parent
=
fullname
();
std
::
string
runStr
=
Run
::
Impl
::
makeKeyStringFromRunNumber
(
runNumber
);
m_impl
->
m_datastore
->
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
runStr
,
std
::
string
()
);
m_impl
->
m_datastore
->
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
runStr
);
return
Run
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
parent
),
runNumber
);
}
...
...
@@ -195,7 +191,7 @@ Run DataSet::createRun(WriteBatch& batch, const RunNumber& runNumber) {
}
std
::
string
parent
=
fullname
();
std
::
string
runStr
=
Run
::
Impl
::
makeKeyStringFromRunNumber
(
runNumber
);
batch
.
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
runStr
,
std
::
string
()
);
batch
.
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
runStr
);
return
Run
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
parent
),
runNumber
);
}
...
...
src/DataStore.cpp
View file @
86650843
...
...
@@ -177,7 +177,7 @@ DataSet DataStore::createDataSet(const std::string& name) {
||
name
.
find
(
'%'
)
!=
std
::
string
::
npos
)
{
throw
Exception
(
"Invalid character ('/' or '%') in dataset name"
);
}
m_impl
->
store
(
1
,
""
,
name
,
std
::
string
()
);
m_impl
->
store
(
1
,
""
,
name
);
return
DataSet
(
this
,
1
,
std
::
make_shared
<
std
::
string
>
(
""
),
name
);
}
...
...
@@ -189,7 +189,7 @@ DataSet DataStore::createDataSet(WriteBatch& batch, const std::string& name) {
||
name
.
find
(
'%'
)
!=
std
::
string
::
npos
)
{
throw
Exception
(
"Invalid character ('/' or '%') in dataset name"
);
}
batch
.
m_impl
->
store
(
1
,
""
,
name
,
std
::
string
()
);
batch
.
m_impl
->
store
(
1
,
""
,
name
);
return
DataSet
(
this
,
1
,
std
::
make_shared
<
std
::
string
>
(
""
),
name
);
}
...
...
@@ -209,6 +209,13 @@ bool DataStore::loadRawProduct(const ProductID& productID, std::string& buffer)
return
m_impl
->
load
(
productID
.
m_level
,
productID
.
m_containerName
,
productID
.
m_objectName
,
buffer
);
}
bool
DataStore
::
loadRawProduct
(
const
ProductID
&
productID
,
char
*
data
,
size_t
*
size
)
{
if
(
!
m_impl
)
{
throw
Exception
(
"Calling DataStore member function on an invalid DataStore object"
);
}
return
m_impl
->
load
(
productID
.
m_level
,
productID
.
m_containerName
,
productID
.
m_objectName
,
data
,
size
);
}
////////////////////////////////////////////////////////////////////////////////////////////
// DataStore::const_iterator::Impl implementation
////////////////////////////////////////////////////////////////////////////////////////////
...
...
src/Event.cpp
View file @
86650843
...
...
@@ -61,40 +61,36 @@ bool Event::valid() const {
}
ProductID
Event
::
storeRawData
(
const
std
::
string
&
key
,
const
std
::
string
&
buffer
)
{
ProductID
Event
::
storeRawData
(
const
std
::
string
&
key
,
const
char
*
value
,
size_t
vsize
)
{
if
(
!
valid
())
{
throw
Exception
(
"Calling Event member function on an invalid Event object"
);
}
// forward the call to the datastore's store function
return
m_impl
->
m_datastore
->
m_impl
->
store
(
0
,
m_impl
->
fullpath
(),
key
,
buffer
);
return
m_impl
->
m_datastore
->
m_impl
->
store
(
0
,
m_impl
->
fullpath
(),
key
,
value
,
vsize
);
}
ProductID
Event
::
storeRawData
(
std
::
string
&&
key
,
std
::
string
&&
buffer
)
{
return
storeRawData
(
key
,
buffer
);
// call the above function
}
ProductID
Event
::
storeRawData
(
WriteBatch
&
batch
,
const
std
::
string
&
key
,
const
std
::
string
&
buffer
)
{
ProductID
Event
::
storeRawData
(
WriteBatch
&
batch
,
const
std
::
string
&
key
,
const
char
*
value
,
size_t
vsize
)
{
if
(
!
valid
())
{
throw
Exception
(
"Calling Event member function on an invalid Event object"
);
}
// forward the call to the datastore's store function
return
batch
.
m_impl
->
store
(
0
,
m_impl
->
fullpath
(),
key
,
buffer
);
return
batch
.
m_impl
->
store
(
0
,
m_impl
->
fullpath
(),
key
,
value
,
vsize
);
}
ProductID
Event
::
store
RawData
(
WriteBatch
&
batch
,
std
::
string
&
&
key
,
std
::
string
&
&
buffer
)
{
bool
Event
::
load
RawData
(
const
std
::
string
&
key
,
std
::
string
&
buffer
)
const
{
if
(
!
valid
())
{
throw
Exception
(
"Calling Event member function on an invalid Event object"
);
}
// forward the call to the datastore's
store
function
return
batch
.
m_impl
->
store
(
0
,
m_impl
->
fullpath
(),
std
::
move
(
key
)
,
std
::
move
(
buffer
)
)
;
// forward the call to the datastore's
load
function
return
m_impl
->
m_datastore
->
m_impl
->
load
(
0
,
m_impl
->
fullpath
(),
key
,
buffer
);
}
bool
Event
::
loadRawData
(
const
std
::
string
&
key
,
std
::
string
&
buffer
)
const
{
bool
Event
::
loadRawData
(
const
std
::
string
&
key
,
char
*
value
,
size_t
*
vsize
)
const
{
if
(
!
valid
())
{
throw
Exception
(
"Calling
Even
t member function on an invalid
Event objec
t"
);
throw
Exception
(
"Calling
DataSe
t member function on an invalid
DataSe
t"
);
}
// forward the call to the datastore's load function
return
m_impl
->
m_datastore
->
m_impl
->
load
(
0
,
m_impl
->
fullpath
(),
key
,
buffer
);
return
m_impl
->
m_datastore
->
m_impl
->
load
(
0
,
m_impl
->
fullpath
(),
key
,
value
,
vsize
);
}
bool
Event
::
operator
==
(
const
Event
&
other
)
const
{
...
...
src/Run.cpp
View file @
86650843
...
...
@@ -63,40 +63,36 @@ bool Run::valid() const {
}
ProductID
Run
::
storeRawData
(
const
std
::
string
&
key
,
const
std
::
string
&
buffer
)
{
ProductID
Run
::
storeRawData
(
const
std
::
string
&
key
,
const
char
*
value
,
size_t
vsize
)
{
if
(
!
valid
())
{
throw
Exception
(
"Calling Run member function on an invalid Run object"
);
}
// forward the call to the datastore's store function
return
m_impl
->
m_datastore
->
m_impl
->
store
(
0
,
m_impl
->
fullpath
(),
key
,
buffer
);
return
m_impl
->
m_datastore
->
m_impl
->
store
(
0
,
m_impl
->
fullpath
(),
key
,
value
,
vsize
);
}
ProductID
Run
::
storeRawData
(
std
::
string
&&
key
,
std
::
string
&&
buffer
)
{
return
storeRawData
(
key
,
buffer
);
// calls the above function
}
ProductID
Run
::
storeRawData
(
WriteBatch
&
batch
,
const
std
::
string
&
key
,
const
std
::
string
&
buffer
)
{
ProductID
Run
::
storeRawData
(
WriteBatch
&
batch
,
const
std
::
string
&
key
,
const
char
*
value
,
size_t
vsize
)
{
if
(
!
valid
())
{
throw
Exception
(
"Calling Run member function on an invalid Run object"
);
}
// forward the call to the datastore's store function
return
batch
.
m_impl
->
store
(
0
,
m_impl
->
fullpath
(),
key
,
buffer
);
return
batch
.
m_impl
->
store
(
0
,
m_impl
->
fullpath
(),
key
,
value
,
vsize
);
}
ProductID
Run
::
store
RawData
(
WriteBatch
&
batch
,
std
::
string
&
&
key
,
std
::
string
&
&
buffer
)
{
bool
Run
::
load
RawData
(
const
std
::
string
&
key
,
std
::
string
&
buffer
)
const
{
if
(
!
valid
())
{
throw
Exception
(
"Calling Run member function on an invalid Run object"
);
}
// forward the call to the datastore's
store
function
return
batch
.
m_impl
->
store
(
0
,
m_impl
->
fullpath
(),
std
::
move
(
key
)
,
std
::
move
(
buffer
)
)
;
// forward the call to the datastore's
load
function
return
m_impl
->
m_datastore
->
m_impl
->
load
(
0
,
m_impl
->
fullpath
(),
key
,
buffer
);
}
bool
Run
::
loadRawData
(
const
std
::
string
&
key
,
std
::
string
&
buffer
)
const
{
bool
Run
::
loadRawData
(
const
std
::
string
&
key
,
char
*
value
,
size_t
*
vsize
)
const
{
if
(
!
valid
())
{
throw
Exception
(
"Calling
Run
member function on an invalid
Run objec
t"
);
throw
Exception
(
"Calling
DataSet
member function on an invalid
DataSe
t"
);
}
// forward the call to the datastore's load function
return
m_impl
->
m_datastore
->
m_impl
->
load
(
0
,
m_impl
->
fullpath
(),
key
,
buffer
);
return
m_impl
->
m_datastore
->
m_impl
->
load
(
0
,
m_impl
->
fullpath
(),
key
,
value
,
vsize
);
}
bool
Run
::
operator
==
(
const
Run
&
other
)
const
{
...
...
@@ -135,7 +131,7 @@ SubRun Run::createSubRun(const SubRunNumber& subRunNumber) {
}
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
subRunStr
=
SubRun
::
Impl
::
makeKeyStringFromSubRunNumber
(
subRunNumber
);
m_impl
->
m_datastore
->
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
subRunStr
,
std
::
string
()
);
m_impl
->
m_datastore
->
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
subRunStr
);
return
SubRun
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
parent
),
subRunNumber
);
}
...
...
@@ -146,7 +142,7 @@ SubRun Run::createSubRun(WriteBatch& batch, const SubRunNumber& subRunNumber) {
}
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
subRunStr
=
SubRun
::
Impl
::
makeKeyStringFromSubRunNumber
(
subRunNumber
);
batch
.
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
subRunStr
,
std
::
string
()
);
batch
.
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
subRunStr
);
return
SubRun
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
parent
),
subRunNumber
);
}
...
...
src/SubRun.cpp
View file @
86650843
...
...
@@ -65,40 +65,36 @@ bool SubRun::valid() const {
return
m_impl
&&
m_impl
->
m_datastore
;
}
ProductID
SubRun
::
storeRawData
(
const
std
::
string
&
key
,
const
std
::
string
&
buffer
)
{
ProductID
SubRun
::
storeRawData
(
const
std
::
string
&
key
,
const
char
*
value
,
size_t
vsize
)
{
if
(
!
valid
())
{
throw
Exception
(
"Calling SubRun member function on invalid SubRun object"
);
}
// forward the call to the datastore's store function
return
m_impl
->
m_datastore
->
m_impl
->
store
(
0
,
m_impl
->
fullpath
(),
key
,
buffer
);
return
m_impl
->
m_datastore
->
m_impl
->
store
(
0
,
m_impl
->
fullpath
(),
key
,
value
,
vsize
);
}
ProductID
SubRun
::
storeRawData
(
std
::
string
&&
key
,
std
::
string
&&
buffer
)
{
return
storeRawData
(
key
,
buffer
);
// call above function
}
ProductID
SubRun
::
storeRawData
(
WriteBatch
&
batch
,
const
std
::
string
&
key
,
const
std
::
string
&
buffer
)
{
ProductID
SubRun
::
storeRawData
(
WriteBatch
&
batch
,
const
std
::
string
&
key
,
const
char
*
value
,
size_t
vsize
)
{
if
(
!
valid
())
{
throw
Exception
(
"Calling SubRun member function on invalid SubRun object"
);
}
// forward the call to the datastore's store function
return
batch
.
m_impl
->
store
(
0
,
m_impl
->
fullpath
(),
key
,
buffer
);
return
batch
.
m_impl
->
store
(
0
,
m_impl
->
fullpath
(),
key
,
value
,
vsize
);
}
ProductID
SubRun
::
store
RawData
(
WriteBatch
&
batch
,
std
::
string
&
&
key
,
std
::
string
&
&
buffer
)
{
bool
SubRun
::
load
RawData
(
const
std
::
string
&
key
,
std
::
string
&
buffer
)
const
{
if
(
!
valid
())
{
throw
Exception
(
"Calling SubRun member function on invalid SubRun object"
);
}
// forward the call to the datastore's
store
function
return
batch
.
m_impl
->
store
(
0
,
m_impl
->
fullpath
(),
std
::
move
(
key
)
,
std
::
move
(
buffer
)
)
;
// forward the call to the datastore's
load
function
return
m_impl
->
m_datastore
->
m_impl
->
load
(
0
,
m_impl
->
fullpath
(),
key
,
buffer
);
}
bool
SubRun
::
loadRawData
(
const
std
::
string
&
key
,
std
::
string
&
buffer
)
const
{
bool
SubRun
::
loadRawData
(
const
std
::
string
&
key
,
char
*
value
,
size_t
*
vsize
)
const
{
if
(
!
valid
())
{
throw
Exception
(
"Calling
SubRun
member function on invalid
SubRun objec
t"
);
throw
Exception
(
"Calling
DataSet
member function on
an
invalid
DataSe
t"
);
}
// forward the call to the datastore's load function
return
m_impl
->
m_datastore
->
m_impl
->
load
(
0
,
m_impl
->
fullpath
(),
key
,
buffer
);
return
m_impl
->
m_datastore
->
m_impl
->
load
(
0
,
m_impl
->
fullpath
(),
key
,
value
,
vsize
);
}
bool
SubRun
::
operator
==
(
const
SubRun
&
other
)
const
{
...
...
@@ -127,7 +123,7 @@ Event SubRun::createEvent(const EventNumber& eventNumber) {
}
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
eventStr
=
Event
::
Impl
::
makeKeyStringFromEventNumber
(
eventNumber
);
m_impl
->
m_datastore
->
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
eventStr
,
std
::
string
()
);
m_impl
->
m_datastore
->
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
eventStr
);
return
Event
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
parent
),
eventNumber
);
}
...
...
@@ -138,7 +134,7 @@ Event SubRun::createEvent(WriteBatch& batch, const EventNumber& eventNumber) {
}
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
eventStr
=
Event
::
Impl
::
makeKeyStringFromEventNumber
(
eventNumber
);
batch
.
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
eventStr
,
std
::
string
()
);
batch
.
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
eventStr
);
return
Event
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
parent
),
eventNumber
);
}
...
...
src/private/DataStoreImpl.hpp
View file @
86650843
...
...
@@ -208,6 +208,29 @@ class DataStore::Impl {