Skip to content

Commit 59033a5

Browse files
aalkinktf
authored andcommitted
Allow filters to be set in init(); Add ability to set a filter from string directly
1 parent 81851e7 commit 59033a5

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

Framework/Core/include/Framework/AnalysisTask.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,11 @@ DataProcessorSpec adaptAnalysisTask(ConfigContext const& ctx, Args&&... args)
574574

575575
callbacks.set<CallbackService::Id::EndOfStream>(eoscb);
576576

577+
/// call the task's init() function first as it may manipulate the task's elements
578+
if constexpr (requires { task->init(ic); }) {
579+
task->init(ic);
580+
}
581+
577582
/// update configurables in filters and partitions
578583
homogeneous_apply_refs(
579584
[&ic](auto& element) -> bool { return analysis_task_parsers::updatePlaceholders(ic, element); },
@@ -584,10 +589,6 @@ DataProcessorSpec adaptAnalysisTask(ConfigContext const& ctx, Args&&... args)
584589
},
585590
*task.get());
586591

587-
if constexpr (requires { task->init(ic); }) {
588-
task->init(ic);
589-
}
590-
591592
/// parse process functions to enable requested grouping caches - note that at this state process configurables have their final values
592593
if constexpr (requires { &T::process; }) {
593594
AnalysisDataProcessorBuilder::cacheFromArgs(&T::process, true, bindingsKeys, bindingsKeysUnsorted);

Framework/Core/include/Framework/Expressions.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,15 +610,29 @@ struct Filter {
610610
(void)designateSubtrees(node.get());
611611
}
612612

613+
Filter(std::string const& input_) : input{input_} {}
614+
613615
Filter& operator=(Filter&& other) noexcept
614616
{
615617
node = std::move(other.node);
618+
input = std::move(other.input);
619+
return *this;
620+
}
621+
622+
Filter& operator=(std::string const& input_)
623+
{
624+
input = input_;
625+
if (node != nullptr) {
626+
node = nullptr;
627+
}
616628
return *this;
617629
}
618630

619631
std::unique_ptr<Node> node = nullptr;
632+
std::string input;
620633

621634
size_t designateSubtrees(Node* node, size_t index = 0);
635+
void parse();
622636
};
623637

624638
template <typename T>

Framework/Core/src/Expressions.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ size_t Filter::designateSubtrees(Node* node, size_t index)
152152
return index;
153153
}
154154

155+
void Filter::parse()
156+
{
157+
node = std::make_unique<Node>(Parser::parse(input));
158+
(void)designateSubtrees(node.get());
159+
}
160+
155161
template <typename T>
156162
constexpr inline auto makeDatum(T const&)
157163
{
@@ -252,6 +258,9 @@ std::ostream& operator<<(std::ostream& os, DatumSpec const& spec)
252258

253259
void updatePlaceholders(Filter& filter, InitContext& context)
254260
{
261+
if (filter.node == nullptr && !filter.input.empty()) {
262+
filter.parse();
263+
}
255264
expressions::walk(filter.node.get(), [&](Node* node) {
256265
if (node->self.index() == 3) {
257266
std::get_if<3>(&node->self)->reset(context);

0 commit comments

Comments
 (0)