Skip to content

Commit

Permalink
Revert "Revert "DPL: add wildcards when creating matchers via DataDes…
Browse files Browse the repository at this point in the history
…criptorMatcher::parse (AliceO2Group#5413)" (AliceO2Group#5596)"

This reverts commit 9ad45ec.
  • Loading branch information
chiarazampolli committed Mar 20, 2021
1 parent 87e94b8 commit 412bba1
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Framework/Core/src/DataDescriptorQueryBuilder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ std::vector<InputSpec> DataDescriptorQueryBuilder::parse(char const* config)
auto lastMatcher =
std::make_unique<DataDescriptorMatcher>(DataDescriptorMatcher::Op::Just,
StartTimeValueMatcher(ContextRef{0}));
size_t extraNodes = 0;
if (nodes.size() <= 1) {
nodes.push_back(DescriptionValueMatcher{ContextRef{++extraNodes}});
}
if (nodes.size() <= 2) {
nodes.push_back(SubSpecificationTypeValueMatcher{ContextRef{++extraNodes}});
}

for (size_t ni = 0, ne = nodes.size(); ni < ne; ++ni) {
auto& node = nodes[nodes.size() - 1 - ni];
auto tmp = std::make_unique<DataDescriptorMatcher>(DataDescriptorMatcher::Op::And,
Expand Down Expand Up @@ -187,6 +195,8 @@ std::vector<InputSpec> DataDescriptorQueryBuilder::parse(char const* config)
case IN_END_DESCRIPTION: {
if (assignLastStringMatch("description", 16, currentDescription, IN_BEGIN_SUBSPEC)) {
nodes.push_back(DescriptionValueMatcher{*currentDescription});
} else {
nodes.push_back(DescriptionValueMatcher{ContextRef{1}});
}
} break;
case IN_BEGIN_SUBSPEC: {
Expand All @@ -196,6 +206,8 @@ std::vector<InputSpec> DataDescriptorQueryBuilder::parse(char const* config)
case IN_END_SUBSPEC: {
if (assignLastNumericMatch("subspec", currentSubSpec, IN_BEGIN_TIMEMODULO)) {
nodes.push_back(SubSpecificationTypeValueMatcher{*currentSubSpec});
} else {
nodes.push_back(SubSpecificationTypeValueMatcher{ContextRef{2}});
}
} break;
case IN_BEGIN_TIMEMODULO: {
Expand Down
40 changes: 40 additions & 0 deletions Framework/Core/test/test_DataDescriptorMatcher.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -605,3 +605,43 @@ BOOST_AUTO_TEST_CASE(DataQuery)
<< DataDescriptorMatcher::Op::Just;
BOOST_CHECK_EQUAL(ops.str(), "andorxorjust");
}

BOOST_AUTO_TEST_CASE(CheckOriginWildcard)
{
auto result0 = DataDescriptorQueryBuilder::parse("x:TST");
BOOST_CHECK_EQUAL(result0.size(), 1);
DataDescriptorMatcher expectedMatcher00{
DataDescriptorMatcher::Op::And,
OriginValueMatcher{"TST"},
std::make_unique<DataDescriptorMatcher>(
DataDescriptorMatcher::Op::And,
DescriptionValueMatcher{ContextRef{1}},
std::make_unique<DataDescriptorMatcher>(
DataDescriptorMatcher::Op::And,
SubSpecificationTypeValueMatcher{ContextRef{2}},
std::make_unique<DataDescriptorMatcher>(DataDescriptorMatcher::Op::Just,
StartTimeValueMatcher{ContextRef{0}})))};
auto matcher = std::get_if<DataDescriptorMatcher>(&result0[0].matcher);
BOOST_REQUIRE(matcher != nullptr);
BOOST_CHECK_EQUAL(expectedMatcher00, *matcher);
}

BOOST_AUTO_TEST_CASE(CheckOriginDescriptionWildcard)
{
auto result0 = DataDescriptorQueryBuilder::parse("x:TST/A");
BOOST_CHECK_EQUAL(result0.size(), 1);
DataDescriptorMatcher expectedMatcher00{
DataDescriptorMatcher::Op::And,
OriginValueMatcher{"TST"},
std::make_unique<DataDescriptorMatcher>(
DataDescriptorMatcher::Op::And,
DescriptionValueMatcher{"A"},
std::make_unique<DataDescriptorMatcher>(
DataDescriptorMatcher::Op::And,
SubSpecificationTypeValueMatcher{ContextRef{1}},
std::make_unique<DataDescriptorMatcher>(DataDescriptorMatcher::Op::Just,
StartTimeValueMatcher{ContextRef{0}})))};
auto matcher = std::get_if<DataDescriptorMatcher>(&result0[0].matcher);
BOOST_REQUIRE(matcher != nullptr);
BOOST_CHECK_EQUAL(expectedMatcher00, *matcher);
}

0 comments on commit 412bba1

Please sign in to comment.