Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
HEPnOS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sds
HEP
HEPnOS
Commits
18f93fd1
Commit
18f93fd1
authored
Feb 12, 2020
by
Matthieu Dorier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplified conversion of numbers to string keys
parent
c691fddc
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
112 additions
and
165 deletions
+112
-165
src/DataSet.cpp
src/DataSet.cpp
+2
-2
src/Event.cpp
src/Event.cpp
+1
-1
src/EventImpl.hpp
src/EventImpl.hpp
+2
-45
src/NumberUtil.hpp
src/NumberUtil.hpp
+69
-0
src/Run.cpp
src/Run.cpp
+17
-13
src/RunImpl.hpp
src/RunImpl.hpp
+14
-54
src/RunSet.cpp
src/RunSet.cpp
+1
-1
src/SubRun.cpp
src/SubRun.cpp
+4
-4
src/SubRunImpl.hpp
src/SubRunImpl.hpp
+2
-45
No files found.
src/DataSet.cpp
View file @
18f93fd1
...
@@ -179,7 +179,7 @@ Run DataSet::createRun(const RunNumber& runNumber) {
...
@@ -179,7 +179,7 @@ Run DataSet::createRun(const RunNumber& runNumber) {
throw
Exception
(
"Trying to create a Run with InvalidRunNumber"
);
throw
Exception
(
"Trying to create a Run with InvalidRunNumber"
);
}
}
std
::
string
parent
=
fullname
();
std
::
string
parent
=
fullname
();
std
::
string
runStr
=
Run
::
Impl
::
makeKeyStringFromRun
Number
(
runNumber
);
std
::
string
runStr
=
makeKeyStringFrom
Number
(
runNumber
);
m_impl
->
m_datastore
->
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
runStr
);
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
,
return
Run
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
parent
),
runNumber
);
std
::
make_shared
<
std
::
string
>
(
parent
),
runNumber
);
...
@@ -190,7 +190,7 @@ Run DataSet::createRun(WriteBatch& batch, const RunNumber& runNumber) {
...
@@ -190,7 +190,7 @@ Run DataSet::createRun(WriteBatch& batch, const RunNumber& runNumber) {
throw
Exception
(
"Trying to create a Run with InvalidRunNumber"
);
throw
Exception
(
"Trying to create a Run with InvalidRunNumber"
);
}
}
std
::
string
parent
=
fullname
();
std
::
string
parent
=
fullname
();
std
::
string
runStr
=
Run
::
Impl
::
makeKeyStringFromRun
Number
(
runNumber
);
std
::
string
runStr
=
makeKeyStringFrom
Number
(
runNumber
);
batch
.
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
runStr
);
batch
.
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
runStr
);
return
Run
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
return
Run
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
parent
),
runNumber
);
std
::
make_shared
<
std
::
string
>
(
parent
),
runNumber
);
...
...
src/Event.cpp
View file @
18f93fd1
...
@@ -51,7 +51,7 @@ Event Event::next() const {
...
@@ -51,7 +51,7 @@ Event Event::next() const {
if
(
s
==
0
)
return
Event
();
if
(
s
==
0
)
return
Event
();
size_t
i
=
m_impl
->
m_container
->
size
()
+
1
;
size_t
i
=
m_impl
->
m_container
->
size
()
+
1
;
if
(
keys
[
0
].
size
()
<=
i
)
return
Event
();
if
(
keys
[
0
].
size
()
<=
i
)
return
Event
();
EventNumber
n
=
Impl
::
parseEventNumberFromKeyString
(
&
keys
[
0
][
i
]);
EventNumber
n
=
parseNumberFromKeyString
<
EventNumber
>
(
&
keys
[
0
][
i
]);
if
(
n
==
InvalidEventNumber
)
return
Event
();
if
(
n
==
InvalidEventNumber
)
return
Event
();
return
Event
(
m_impl
->
m_datastore
,
m_impl
->
m_level
,
m_impl
->
m_container
,
n
);
return
Event
(
m_impl
->
m_datastore
,
m_impl
->
m_level
,
m_impl
->
m_container
,
n
);
}
}
...
...
src/EventImpl.hpp
View file @
18f93fd1
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#include <iomanip>
#include <iomanip>
#include <memory>
#include <memory>
#include "hepnos/Event.hpp"
#include "hepnos/Event.hpp"
#include "NumberUtil.hpp"
namespace
hepnos
{
namespace
hepnos
{
...
@@ -29,52 +30,8 @@ class Event::Impl {
...
@@ -29,52 +30,8 @@ class Event::Impl {
,
m_container
(
container
)
,
m_container
(
container
)
,
m_event_nr
(
n
)
{}
,
m_event_nr
(
n
)
{}
static
std
::
string
makeKeyStringFromEventNumber
(
const
EventNumber
&
n
)
{
std
::
string
str
(
1
+
sizeof
(
n
),
'\0'
);
str
[
0
]
=
'%'
;
#ifndef HEPNOS_READABLE_NUMBERS
#if BOOST_ENDIAN_BIG_BYTE
std
::
memcpy
(
&
str
[
1
],
&
n
,
sizeof
(
n
));
return
str
;
#else
unsigned
i
=
sizeof
(
n
);
auto
n2
=
n
;
while
(
n2
!=
0
)
{
str
[
i
]
=
n2
&
0xff
;
n2
=
n2
>>
8
;
i
-=
1
;
}
return
str
;
#endif
#else
std
::
stringstream
strstr
;
strstr
<<
"%"
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
16
)
<<
std
::
hex
<<
n
;
return
strstr
.
str
();
#endif
}
static
EventNumber
parseEventNumberFromKeyString
(
const
char
*
str
)
{
if
(
str
[
0
]
!=
'%'
)
return
InvalidEventNumber
;
EventNumber
n
;
#ifdef HEPNOS_READABLE_NUMBERS
std
::
stringstream
strEventNumber
;
strEventNumber
<<
std
::
hex
<<
std
::
string
(
str
+
1
,
16
);
strEventNumber
>>
n
;
#else
#if BOOST_ENDIAN_BIG_BYTE
std
::
memcpy
(
&
n
,
&
str
[
1
],
sizeof
(
n
));
#else
n
=
0
;
for
(
unsigned
i
=
0
;
i
<
sizeof
(
n
);
i
++
)
{
n
=
256
*
n
+
str
[
i
+
1
];
}
#endif
#endif
return
n
;
}
std
::
string
makeKeyStringFromEventNumber
()
const
{
std
::
string
makeKeyStringFromEventNumber
()
const
{
return
makeKeyStringFrom
Event
Number
(
m_event_nr
);
return
makeKeyStringFromNumber
(
m_event_nr
);
}
}
std
::
string
fullpath
()
const
{
std
::
string
fullpath
()
const
{
...
...
src/NumberUtil.hpp
0 → 100644
View file @
18f93fd1
/*
* (C) 2018 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#ifndef __HEPNOS_PRIVATE_NUMBER_UTIL_H
#define __HEPNOS_PRIVATE_NUMBER_UTIL_H
#include <sstream>
#include <memory>
#include <iomanip>
namespace
hepnos
{
template
<
typename
T
>
static
std
::
string
makeReadableKeyStringFromNumber
(
const
T
&
n
)
{
constexpr
int
s
=
sizeof
(
T
)
*
2
;
std
::
stringstream
strstr
;
strstr
<<
'%'
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
s
)
<<
std
::
hex
<<
n
;
return
strstr
.
str
();
}
template
<
typename
T
>
static
std
::
string
makeKeyStringFromNumber
(
const
T
&
n
)
{
#ifdef HEPNOS_READABLE_NUMBERS
return
makeReadableKeyStringFromNumber
(
n
);
#else
std
::
string
str
(
1
+
sizeof
(
n
),
'\0'
);
str
[
0
]
=
'%'
;
#if BOOST_ENDIAN_BIG_BYTE
std
::
memcpy
(
&
str
[
1
],
&
n
,
sizeof
(
n
));
return
str
;
#else
unsigned
i
=
sizeof
(
n
);
auto
n2
=
n
;
while
(
n2
!=
0
)
{
str
[
i
]
=
n2
&
0xff
;
n2
=
n2
>>
8
;
i
-=
1
;
}
return
str
;
#endif
#endif
}
template
<
typename
T
>
static
T
parseNumberFromKeyString
(
const
char
*
str
)
{
// string is assumed to start with a '%'
T
n
;
#ifdef HEPNOS_READABLE_NUMBERS
std
::
stringstream
strNumber
;
strNumber
<<
std
::
hex
<<
std
::
string
(
str
+
1
,
sizeof
(
T
)
*
2
);
strNumber
>>
n
;
#else
#if BOOST_ENDIAN_BIG_BYTE
std
::
memcpy
(
&
n
,
&
str
[
1
],
sizeof
(
n
));
#else
n
=
0
;
for
(
unsigned
i
=
0
;
i
<
sizeof
(
n
);
i
++
)
{
n
=
256
*
n
+
str
[
i
+
1
];
}
#endif
#endif
return
n
;
}
}
#endif
src/Run.cpp
View file @
18f93fd1
...
@@ -11,6 +11,8 @@
...
@@ -11,6 +11,8 @@
namespace
hepnos
{
namespace
hepnos
{
Run
::
iterator
Run
::
Impl
::
m_end
;
Run
::
Run
()
Run
::
Run
()
:
m_impl
(
std
::
make_unique
<
Run
::
Impl
>
(
nullptr
,
0
,
std
::
make_shared
<
std
::
string
>
(
""
),
InvalidRunNumber
))
{}
:
m_impl
(
std
::
make_unique
<
Run
::
Impl
>
(
nullptr
,
0
,
std
::
make_shared
<
std
::
string
>
(
""
),
InvalidRunNumber
))
{}
...
@@ -48,14 +50,15 @@ Run Run::next() const {
...
@@ -48,14 +50,15 @@ Run Run::next() const {
std
::
vector
<
std
::
string
>
keys
;
std
::
vector
<
std
::
string
>
keys
;
size_t
s
=
m_impl
->
m_datastore
->
m_impl
->
nextKeys
(
size_t
s
=
m_impl
->
m_datastore
->
m_impl
->
nextKeys
(
m_impl
->
m_level
,
*
m_impl
->
m_
container
,
m_impl
->
m_level
,
*
m_impl
->
m_
dataset_name
,
m_impl
->
makeKeyStringFromRunNumber
(),
keys
,
1
);
m_impl
->
makeKeyStringFromRunNumber
(),
keys
,
1
);
if
(
s
==
0
)
return
Run
();
if
(
s
==
0
)
return
Run
();
size_t
i
=
m_impl
->
m_
container
->
size
()
+
1
;
size_t
i
=
m_impl
->
m_
dataset_name
->
size
()
+
1
;
if
(
keys
[
0
].
size
()
<=
i
)
return
Run
();
if
(
keys
[
0
].
size
()
<=
i
)
return
Run
();
RunNumber
rn
=
Impl
::
parseRunNumberFromKeyString
(
&
keys
[
0
][
i
]);
RunNumber
rn
=
parseNumberFromKeyString
<
RunNumber
>
(
&
keys
[
0
][
i
]);
if
(
rn
==
InvalidRunNumber
)
return
Run
();
if
(
rn
==
InvalidRunNumber
)
return
Run
();
return
Run
(
m_impl
->
m_datastore
,
m_impl
->
m_level
,
m_impl
->
m_container
,
rn
);
return
Run
(
m_impl
->
m_datastore
,
m_impl
->
m_level
,
m_impl
->
m_dataset_name
,
rn
);
}
}
bool
Run
::
valid
()
const
{
bool
Run
::
valid
()
const
{
...
@@ -101,10 +104,11 @@ bool Run::operator==(const Run& other) const {
...
@@ -101,10 +104,11 @@ bool Run::operator==(const Run& other) const {
if
(
!
v1
&&
!
v2
)
return
true
;
if
(
!
v1
&&
!
v2
)
return
true
;
if
(
v1
&&
!
v2
)
return
false
;
if
(
v1
&&
!
v2
)
return
false
;
if
(
!
v1
&&
v2
)
return
false
;
if
(
!
v1
&&
v2
)
return
false
;
return
m_impl
->
m_datastore
==
other
.
m_impl
->
m_datastore
return
m_impl
->
m_datastore
==
other
.
m_impl
->
m_datastore
&&
m_impl
->
m_level
==
other
.
m_impl
->
m_level
&&
m_impl
->
m_level
==
other
.
m_impl
->
m_level
&&
*
m_impl
->
m_container
==
*
other
.
m_impl
->
m_container
&&
(
m_impl
->
m_dataset_name
==
other
.
m_impl
->
m_dataset_name
&&
m_impl
->
m_run_nr
==
other
.
m_impl
->
m_run_nr
;
||
*
m_impl
->
m_dataset_name
==
*
other
.
m_impl
->
m_dataset_name
)
&&
m_impl
->
m_run_number
==
other
.
m_impl
->
m_run_number
;
}
}
bool
Run
::
operator
!=
(
const
Run
&
other
)
const
{
bool
Run
::
operator
!=
(
const
Run
&
other
)
const
{
...
@@ -115,14 +119,14 @@ const RunNumber& Run::number() const {
...
@@ -115,14 +119,14 @@ const RunNumber& Run::number() const {
if
(
!
valid
())
{
if
(
!
valid
())
{
throw
Exception
(
"Calling Run member function on an invalid Run object"
);
throw
Exception
(
"Calling Run member function on an invalid Run object"
);
}
}
return
m_impl
->
m_run_nr
;
return
m_impl
->
m_run_n
umbe
r
;
}
}
const
std
::
string
&
Run
::
container
()
const
{
const
std
::
string
&
Run
::
container
()
const
{
if
(
!
valid
())
{
if
(
!
valid
())
{
throw
Exception
(
"Calling Run member function on an invalid Run object"
);
throw
Exception
(
"Calling Run member function on an invalid Run object"
);
}
}
return
*
m_impl
->
m_
container
;
return
*
m_impl
->
m_
dataset_name
;
}
}
SubRun
Run
::
createSubRun
(
const
SubRunNumber
&
subRunNumber
)
{
SubRun
Run
::
createSubRun
(
const
SubRunNumber
&
subRunNumber
)
{
...
@@ -130,7 +134,7 @@ SubRun Run::createSubRun(const SubRunNumber& subRunNumber) {
...
@@ -130,7 +134,7 @@ SubRun Run::createSubRun(const SubRunNumber& subRunNumber) {
throw
Exception
(
"Calling Run member function on an invalid Run object"
);
throw
Exception
(
"Calling Run member function on an invalid Run object"
);
}
}
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
subRunStr
=
SubRun
::
Impl
::
makeKeyStringFromSubRun
Number
(
subRunNumber
);
std
::
string
subRunStr
=
makeKeyStringFrom
Number
(
subRunNumber
);
m_impl
->
m_datastore
->
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
subRunStr
);
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
,
return
SubRun
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
parent
),
subRunNumber
);
std
::
make_shared
<
std
::
string
>
(
parent
),
subRunNumber
);
...
@@ -141,7 +145,7 @@ SubRun Run::createSubRun(WriteBatch& batch, const SubRunNumber& subRunNumber) {
...
@@ -141,7 +145,7 @@ SubRun Run::createSubRun(WriteBatch& batch, const SubRunNumber& subRunNumber) {
throw
Exception
(
"Calling Run member function on an invalid Run object"
);
throw
Exception
(
"Calling Run member function on an invalid Run object"
);
}
}
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
subRunStr
=
SubRun
::
Impl
::
makeKeyStringFromSubRun
Number
(
subRunNumber
);
std
::
string
subRunStr
=
makeKeyStringFrom
Number
(
subRunNumber
);
batch
.
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
subRunStr
);
batch
.
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
subRunStr
);
return
SubRun
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
return
SubRun
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
parent
),
subRunNumber
);
std
::
make_shared
<
std
::
string
>
(
parent
),
subRunNumber
);
...
@@ -160,7 +164,7 @@ Run::iterator Run::find(const SubRunNumber& subRunNumber) {
...
@@ -160,7 +164,7 @@ Run::iterator Run::find(const SubRunNumber& subRunNumber) {
}
}
int
ret
;
int
ret
;
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
subRunStr
=
SubRun
::
Impl
::
makeKeyStringFromSubRun
Number
(
subRunNumber
);
std
::
string
subRunStr
=
makeKeyStringFrom
Number
(
subRunNumber
);
bool
b
=
m_impl
->
m_datastore
->
m_impl
->
exists
(
m_impl
->
m_level
+
1
,
parent
,
subRunStr
);
bool
b
=
m_impl
->
m_datastore
->
m_impl
->
exists
(
m_impl
->
m_level
+
1
,
parent
,
subRunStr
);
if
(
!
b
)
{
if
(
!
b
)
{
return
m_impl
->
m_end
;
return
m_impl
->
m_end
;
...
...
src/RunImpl.hpp
View file @
18f93fd1
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include <iomanip>
#include <iomanip>
#include <memory>
#include <memory>
#include "hepnos/Run.hpp"
#include "hepnos/Run.hpp"
#include "NumberUtil.hpp"
namespace
hepnos
{
namespace
hepnos
{
...
@@ -17,68 +18,27 @@ class Run::Impl {
...
@@ -17,68 +18,27 @@ class Run::Impl {
public:
public:
DataStore
*
m_datastore
;
DataStore
*
m_datastore
;
uint8_t
m_level
;
uint8_t
m_level
;
std
::
shared_ptr
<
std
::
string
>
m_container
;
std
::
shared_ptr
<
std
::
string
>
m_dataset_name
;
RunNumber
m_run_nr
;
RunNumber
m_run_number
;
iterator
m_end
;
Impl
(
DataStore
*
ds
,
uint8_t
level
,
const
std
::
shared_ptr
<
std
::
string
>&
container
,
const
RunNumber
&
rn
)
static
iterator
m_end
;
Impl
(
DataStore
*
ds
,
uint8_t
level
,
const
std
::
shared_ptr
<
std
::
string
>&
dataset
,
const
RunNumber
&
rn
)
:
m_datastore
(
ds
)
:
m_datastore
(
ds
)
,
m_level
(
level
)
,
m_level
(
level
)
,
m_container
(
container
)
,
m_dataset_name
(
dataset
)
,
m_run_nr
(
rn
)
{}
,
m_run_number
(
rn
)
{}
static
std
::
string
makeKeyStringFromRunNumber
(
const
RunNumber
&
n
)
{
std
::
string
str
(
1
+
sizeof
(
n
),
'\0'
);
str
[
0
]
=
'%'
;
#ifndef HEPNOS_READABLE_NUMBERS
#if BOOST_ENDIAN_BIG_BYTE
std
::
memcpy
(
&
str
[
1
],
&
n
,
sizeof
(
n
));
return
str
;
#else
unsigned
i
=
sizeof
(
n
);
auto
n2
=
n
;
while
(
n2
!=
0
)
{
str
[
i
]
=
n2
&
0xff
;
n2
=
n2
>>
8
;
i
-=
1
;
}
return
str
;
#endif
#else
std
::
stringstream
strstr
;
strstr
<<
"%"
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
16
)
<<
std
::
hex
<<
n
;
return
strstr
.
str
();
#endif
}
static
RunNumber
parseRunNumberFromKeyString
(
const
char
*
str
)
{
if
(
str
[
0
]
!=
'%'
)
return
InvalidRunNumber
;
RunNumber
n
;
#ifdef HEPNOS_READABLE_NUMBERS
std
::
stringstream
strRunNumber
;
strRunNumber
<<
std
::
hex
<<
std
::
string
(
str
+
1
,
16
);
strRunNumber
>>
n
;
#else
#if BOOST_ENDIAN_BIG_BYTE
std
::
memcpy
(
&
n
,
&
str
[
1
],
sizeof
(
n
));
#else
n
=
0
;
for
(
unsigned
i
=
0
;
i
<
sizeof
(
n
);
i
++
)
{
n
=
256
*
n
+
str
[
i
+
1
];
}
#endif
#endif
return
n
;
}
std
::
string
makeKeyStringFromRunNumber
()
const
{
std
::
string
makeKeyStringFromRunNumber
()
const
{
return
makeKeyStringFrom
RunNumber
(
m_run_n
r
);
return
makeKeyStringFrom
Number
(
m_run_numbe
r
);
}
}
std
::
string
fullpath
()
const
{
std
::
string
fullpath
()
const
{
return
*
m_
container
+
std
::
string
(
"/"
)
+
makeKeyStringFromRunNumber
(
m_run_nr
);
return
*
m_
dataset_name
+
std
::
string
(
"/"
)
+
makeKeyStringFromRunNumber
(
);
}
}
};
};
...
...
src/RunSet.cpp
View file @
18f93fd1
...
@@ -35,7 +35,7 @@ Run RunSet::operator[](const RunNumber& runNumber) {
...
@@ -35,7 +35,7 @@ Run RunSet::operator[](const RunNumber& runNumber) {
RunSet
::
iterator
RunSet
::
find
(
const
RunNumber
&
runNumber
)
{
RunSet
::
iterator
RunSet
::
find
(
const
RunNumber
&
runNumber
)
{
int
ret
;
int
ret
;
std
::
string
parent
=
m_impl
->
m_dataset
->
fullname
();
std
::
string
parent
=
m_impl
->
m_dataset
->
fullname
();
std
::
string
strNum
=
Run
::
Impl
::
makeKeyStringFromRun
Number
(
runNumber
);
std
::
string
strNum
=
makeKeyStringFrom
Number
(
runNumber
);
auto
datastore
=
m_impl
->
m_dataset
->
m_impl
->
m_datastore
;
auto
datastore
=
m_impl
->
m_dataset
->
m_impl
->
m_datastore
;
auto
level
=
m_impl
->
m_dataset
->
m_impl
->
m_level
;
auto
level
=
m_impl
->
m_dataset
->
m_impl
->
m_level
;
bool
b
=
datastore
->
m_impl
->
exists
(
level
+
1
,
parent
,
strNum
);
bool
b
=
datastore
->
m_impl
->
exists
(
level
+
1
,
parent
,
strNum
);
...
...
src/SubRun.cpp
View file @
18f93fd1
...
@@ -56,7 +56,7 @@ SubRun SubRun::next() const {
...
@@ -56,7 +56,7 @@ SubRun SubRun::next() const {
if
(
s
==
0
)
return
SubRun
();
if
(
s
==
0
)
return
SubRun
();
size_t
i
=
m_impl
->
m_container
->
size
()
+
1
;
size_t
i
=
m_impl
->
m_container
->
size
()
+
1
;
if
(
keys
[
0
].
size
()
<=
i
)
return
SubRun
();
if
(
keys
[
0
].
size
()
<=
i
)
return
SubRun
();
SubRunNumber
rn
=
Impl
::
parseSubRunNumberFromKeyString
(
&
keys
[
0
][
i
]);
SubRunNumber
rn
=
parseNumberFromKeyString
<
SubRunNumber
>
(
&
keys
[
0
][
i
]);
if
(
rn
==
InvalidSubRunNumber
)
return
SubRun
();
if
(
rn
==
InvalidSubRunNumber
)
return
SubRun
();
return
SubRun
(
m_impl
->
m_datastore
,
m_impl
->
m_level
,
m_impl
->
m_container
,
rn
);
return
SubRun
(
m_impl
->
m_datastore
,
m_impl
->
m_level
,
m_impl
->
m_container
,
rn
);
}
}
...
@@ -122,7 +122,7 @@ Event SubRun::createEvent(const EventNumber& eventNumber) {
...
@@ -122,7 +122,7 @@ Event SubRun::createEvent(const EventNumber& eventNumber) {
throw
Exception
(
"Calling SubRun member function on invalid SubRun object"
);
throw
Exception
(
"Calling SubRun member function on invalid SubRun object"
);
}
}
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
eventStr
=
Event
::
Impl
::
makeKeyStringFromEvent
Number
(
eventNumber
);
std
::
string
eventStr
=
makeKeyStringFrom
Number
(
eventNumber
);
m_impl
->
m_datastore
->
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
eventStr
);
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
,
return
Event
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
parent
),
eventNumber
);
std
::
make_shared
<
std
::
string
>
(
parent
),
eventNumber
);
...
@@ -133,7 +133,7 @@ Event SubRun::createEvent(WriteBatch& batch, const EventNumber& eventNumber) {
...
@@ -133,7 +133,7 @@ Event SubRun::createEvent(WriteBatch& batch, const EventNumber& eventNumber) {
throw
Exception
(
"Calling SubRun member function on invalid SubRun object"
);
throw
Exception
(
"Calling SubRun member function on invalid SubRun object"
);
}
}
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
eventStr
=
Event
::
Impl
::
makeKeyStringFromEvent
Number
(
eventNumber
);
std
::
string
eventStr
=
makeKeyStringFrom
Number
(
eventNumber
);
batch
.
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
eventStr
);
batch
.
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
eventStr
);
return
Event
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
return
Event
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
std
::
make_shared
<
std
::
string
>
(
parent
),
eventNumber
);
std
::
make_shared
<
std
::
string
>
(
parent
),
eventNumber
);
...
@@ -152,7 +152,7 @@ SubRun::iterator SubRun::find(const EventNumber& eventNumber) {
...
@@ -152,7 +152,7 @@ SubRun::iterator SubRun::find(const EventNumber& eventNumber) {
}
}
int
ret
;
int
ret
;
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
eventStr
=
Event
::
Impl
::
makeKeyStringFromEvent
Number
(
eventNumber
);
std
::
string
eventStr
=
makeKeyStringFrom
Number
(
eventNumber
);
bool
b
=
m_impl
->
m_datastore
->
m_impl
->
exists
(
m_impl
->
m_level
+
1
,
parent
,
eventStr
);
bool
b
=
m_impl
->
m_datastore
->
m_impl
->
exists
(
m_impl
->
m_level
+
1
,
parent
,
eventStr
);
if
(
!
b
)
{
if
(
!
b
)
{
return
m_impl
->
m_end
;
return
m_impl
->
m_end
;
...
...
src/SubRunImpl.hpp
View file @
18f93fd1
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include <memory>
#include <memory>
#include <iomanip>
#include <iomanip>
#include "hepnos/SubRun.hpp"
#include "hepnos/SubRun.hpp"
#include "NumberUtil.hpp"
namespace
hepnos
{
namespace
hepnos
{
...
@@ -29,52 +30,8 @@ class SubRun::Impl {
...
@@ -29,52 +30,8 @@ class SubRun::Impl {
,
m_container
(
container
)
,
m_container
(
container
)
,
m_subrun_nr
(
rn
)
{}
,
m_subrun_nr
(
rn
)
{}
static
std
::
string
makeKeyStringFromSubRunNumber
(
const
SubRunNumber
&
n
)
{
std
::
string
str
(
1
+
sizeof
(
n
),
'\0'
);
str
[
0
]
=
'%'
;
#ifndef HEPNOS_READABLE_NUMBERS
#if BOOST_ENDIAN_BIG_BYTE
std
::
memcpy
(
&
str
[
1
],
&
n
,
sizeof
(
n
));
return
str
;
#else
unsigned
i
=
sizeof
(
n
);
auto
n2
=
n
;
while
(
n2
!=
0
)
{
str
[
i
]
=
n2
&
0xff
;
n2
=
n2
>>
8
;
i
-=
1
;
}
return
str
;
#endif
#else
std
::
stringstream
strstr
;
strstr
<<
"%"
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
16
)
<<
std
::
hex
<<
n
;
return
strstr
.
str
();
#endif
}
static
SubRunNumber
parseSubRunNumberFromKeyString
(
const
char
*
str
)
{
if
(
str
[
0
]
!=
'%'
)
return
InvalidSubRunNumber
;
SubRunNumber
n
;
#ifdef HEPNOS_READABLE_NUMBERS
std
::
stringstream
strSubRunNumber
;
strSubRunNumber
<<
std
::
hex
<<
std
::
string
(
str
+
1
,
16
);
strSubRunNumber
>>
n
;
#else
#if BOOST_ENDIAN_BIG_BYTE
std
::
memcpy
(
&
n
,
&
str
[
1
],
sizeof
(
n
));
#else
n
=
0
;
for
(
unsigned
i
=
0
;
i
<
sizeof
(
n
);
i
++
)
{
n
=
256
*
n
+
str
[
i
+
1
];
}
#endif
#endif
return
n
;
}
std
::
string
makeKeyStringFromSubRunNumber
()
const
{
std
::
string
makeKeyStringFromSubRunNumber
()
const
{
return
makeKeyStringFrom
SubRun
Number
(
m_subrun_nr
);
return
makeKeyStringFromNumber
(
m_subrun_nr
);
}
}
std
::
string
fullpath
()
const
{
std
::
string
fullpath
()
const
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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