Skip to content

Commit 6bc3aab

Browse files
author
Michal Tichák
committed
hash length hardwired in objects
1 parent 61ba560 commit 6bc3aab

10 files changed

+49
-18
lines changed

Framework/include/QualityControl/AggregatorRunner.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ struct AggregatorSource;
8282
/// \author Barthélémy von Haller
8383
class AggregatorRunner : public framework::Task
8484
{
85+
/// \brief Number of bytes in data description used for hashing of AggregatorRunner names. See HashDataDescription.h for details
86+
static constexpr size_t descriptionHashLength = 4;
87+
static_assert(descriptionHashLength <= o2::header::DataDescription::size);
88+
8589
public:
8690
/// Constructor
8791
/**
@@ -109,7 +113,7 @@ class AggregatorRunner : public framework::Task
109113
static framework::DataProcessorLabel getLabel() { return { "qc-aggregator" }; }
110114
static std::string createAggregatorRunnerIdString() { return "qc-aggregator"; };
111115
static std::string createAggregatorRunnerName();
112-
static header::DataDescription createAggregatorRunnerDataDescription(const std::string& aggregatorName, size_t hashSize = 4);
116+
static header::DataDescription createAggregatorRunnerDataDescription(const std::string& aggregatorName);
113117

114118
/// \brief Compute the detector name to be used in the infologger for this runner.
115119
/// Compute the detector name to be used in the infologger for this runner.

Framework/include/QualityControl/Check.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ struct CheckSpec;
4343
/// \author Rafal Pacholek
4444
class Check
4545
{
46+
/// \brief Number of bytes in data description used for hashing of Check descrition names. See HashDataDescription.h for details
47+
static constexpr size_t descriptionHashLength = 4;
48+
static_assert(descriptionHashLength <= o2::header::DataDescription::size);
49+
4650
public:
4751
/// Constructor
4852
/**
@@ -73,7 +77,7 @@ class Check
7377
void endOfActivity(const core::Activity& activity);
7478

7579
// TODO: Unique Input string
76-
static o2::header::DataDescription createCheckDataDescription(const std::string& checkName, size_t hash_length = 4);
80+
static o2::header::DataDescription createCheckDataDescription(const std::string& checkName);
7781

7882
UpdatePolicyType getUpdatePolicyType() const;
7983
std::vector<std::string> getObjectsNames() const;

Framework/include/QualityControl/HashDataDescription.h

+13-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,21 @@
1717

1818
#include <Headers/DataHeader.h>
1919

20-
namespace o2::common::hash
20+
namespace o2::quality_control::core
2121
{
2222

23-
o2::header::DataDescription createDataDescription(const std::string& name, size_t hash_length = 4);
23+
/// \brief Creates DataDescription from given name.
24+
///
25+
/// If the length of the name is <= 16 (hardcoded in DataDescription) it creates DataDescription from the original name.
26+
/// However, if the length of the name is > 16, it will create hash of the whole name and replace ending hashLength of bytes
27+
/// of the name with hexa representation of computed hash.
28+
/// eg.: name == "veryLongNameThatIsLongerThan16B" with hashLengh == 4 will result in "veryLongNameABCD", where ABCD
29+
/// is the hash create inside the function
30+
///
31+
/// \param name - name which should cut and hashed
32+
/// \param hashLenght - number of bytes which will overwrite the end of the name
33+
o2::header::DataDescription createDataDescription(const std::string& name, size_t hashLength);
2434

25-
} // namespace o2::common::hash
35+
} // namespace o2::quality_control::core
2636

2737
#endif

Framework/include/QualityControl/PostProcessingDevice.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ struct PostProcessingRunnerConfig;
3636
/// \author Piotr Konopka
3737
class PostProcessingDevice : public framework::Task
3838
{
39+
/// \brief Number of bytes in data description used for hashing DataDescription. See HashDataDescription.h for details
40+
static constexpr size_t descriptionHashLength = 4;
41+
static_assert(descriptionHashLength <= o2::header::DataDescription::size);
42+
3943
public:
4044
/// \brief Constructor
4145
///
@@ -60,7 +64,7 @@ class PostProcessingDevice : public framework::Task
6064
/// \brief Unified DataOrigin for Post-processing tasks
6165
static header::DataOrigin createPostProcessingDataOrigin(const std::string& detectorCode);
6266
/// \brief Unified DataDescription naming scheme for all Post-processing tasks
63-
static header::DataDescription createPostProcessingDataDescription(const std::string& taskName, size_t hashLength = 4);
67+
static header::DataDescription createPostProcessingDataDescription(const std::string& taskName);
6468

6569
private:
6670
/// \brief Callback for CallbackService::Id::Start (DPL) a.k.a. RUN transition (FairMQ)
@@ -78,4 +82,4 @@ class PostProcessingDevice : public framework::Task
7882

7983
} // namespace o2::quality_control::postprocessing
8084

81-
#endif //QUALITYCONTROL_POSTPROCESSINGDEVICE_H
85+
#endif // QUALITYCONTROL_POSTPROCESSINGDEVICE_H

Framework/include/QualityControl/TaskRunner.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ class ObjectsManager;
7777
/// \author Barthelemy von Haller
7878
class TaskRunner : public framework::Task
7979
{
80+
/// \brief Number of bytes in data description used for hashing of Task names. See HashDataDescription.h for details
81+
static constexpr size_t taskDescriptionHashLength = 4;
82+
static_assert(taskDescriptionHashLength <= o2::header::DataDescription::size);
83+
8084
public:
8185
/// \brief Constructor
8286
///
@@ -108,7 +112,7 @@ class TaskRunner : public framework::Task
108112
/// \brief Unified DataOrigin for Quality Control tasks
109113
static header::DataOrigin createTaskDataOrigin(const std::string& detectorCode, bool movingWindows = false);
110114
/// \brief Unified DataDescription naming scheme for all tasks
111-
static header::DataDescription createTaskDataDescription(const std::string& taskName, size_t hash_size = 4);
115+
static header::DataDescription createTaskDataDescription(const std::string& taskName);
112116
/// \brief Unified DataDescription naming scheme for all timers
113117
static header::DataDescription createTimerDataDescription(const std::string& taskName);
114118

Framework/src/AggregatorRunner.cxx

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ void AggregatorRunner::prepareInputs()
130130
}
131131
}
132132

133-
header::DataDescription AggregatorRunner::createAggregatorRunnerDataDescription(const std::string& aggregatorName, size_t hashSize)
133+
header::DataDescription AggregatorRunner::createAggregatorRunnerDataDescription(const std::string& aggregatorName)
134134
{
135135
if (aggregatorName.empty()) {
136136
BOOST_THROW_EXCEPTION(FatalException() << errinfo_details("Empty taskName for task's data description"));
137137
}
138-
return common::hash::createDataDescription(aggregatorName, hashSize);
138+
return quality_control::core::createDataDescription(aggregatorName, AggregatorRunner::descriptionHashLength);
139139
}
140140

141141
std::string AggregatorRunner::createAggregatorRunnerName()

Framework/src/Check.cxx

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ namespace o2::quality_control::checker
4444
{
4545

4646
/// Static functions
47-
o2::header::DataDescription Check::createCheckDataDescription(const std::string& checkName, size_t hashLength)
47+
o2::header::DataDescription Check::createCheckDataDescription(const std::string& checkName)
4848
{
4949
if (checkName.empty()) {
5050
BOOST_THROW_EXCEPTION(FatalException() << errinfo_details("Empty checkName for check's data description"));
5151
}
5252

53-
return common::hash::createDataDescription(checkName, hashLength);
53+
return quality_control::core::createDataDescription(checkName, Check::descriptionHashLength);
5454
}
5555

5656
/// Members

Framework/src/HashDataDescription.cxx

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414

1515
#include "QualityControl/HashDataDescription.h"
1616

17-
namespace o2::common::hash
17+
namespace o2::quality_control::core
18+
{
19+
20+
namespace hash
1821
{
1922

2023
// creates hash of input string and returns hexadecimal representation
@@ -25,6 +28,8 @@ auto to_hexa(const std::string& input, size_t hash_length) -> std::string
2528
return std::move(ss).str().substr(0, hash_length);
2629
};
2730

31+
} // namespace hash
32+
2833
o2::header::DataDescription createDataDescription(const std::string& name, size_t hashLength)
2934
{
3035
o2::header::DataDescription description{};
@@ -42,4 +47,4 @@ o2::header::DataDescription createDataDescription(const std::string& name, size_
4247
}
4348
}
4449

45-
} // namespace o2::common::hash
50+
} // namespace o2::quality_control::core

Framework/src/PostProcessingDevice.cxx

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ header::DataOrigin PostProcessingDevice::createPostProcessingDataOrigin(const st
9696
return origin;
9797
}
9898

99-
header::DataDescription PostProcessingDevice::createPostProcessingDataDescription(const std::string& taskName, size_t hashLength)
99+
header::DataDescription PostProcessingDevice::createPostProcessingDataDescription(const std::string& taskName)
100100
{
101101
if (taskName.empty()) {
102102
BOOST_THROW_EXCEPTION(FatalException() << errinfo_details("Empty taskName for pp-task's data description"));
103103
}
104104

105-
return common::hash::createDataDescription(taskName, hashLength);
105+
return quality_control::core::createDataDescription(taskName, PostProcessingDevice::descriptionHashLength);
106106
}
107107

108108
void PostProcessingDevice::start(ServiceRegistryRef services)

Framework/src/TaskRunner.cxx

+2-2
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,13 @@ header::DataOrigin TaskRunner::createTaskDataOrigin(const std::string& detectorC
292292
return origin;
293293
}
294294

295-
header::DataDescription TaskRunner::createTaskDataDescription(const std::string& taskName, size_t hashSize)
295+
header::DataDescription TaskRunner::createTaskDataDescription(const std::string& taskName)
296296
{
297297
if (taskName.empty()) {
298298
BOOST_THROW_EXCEPTION(FatalException() << errinfo_details("Empty taskName for task's data description"));
299299
}
300300

301-
return common::hash::createDataDescription(taskName, hashSize);
301+
return quality_control::core::createDataDescription(taskName, TaskRunner::taskDescriptionHashLength);
302302
}
303303

304304
header::DataDescription TaskRunner::createTimerDataDescription(const std::string& taskName)

0 commit comments

Comments
 (0)