Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix apply on user-defined aggregate init #2456

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/ast/UserDefinedAggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ Node::NodeVec UserDefinedAggregator::getChildren() const {
}

void UserDefinedAggregator::print(std::ostream& os) const {
os << "@" << name;
os << " init: " << *initValue;
os << "@@" << name << " " << *initValue;
if (targetExpression) {
os << " " << *targetExpression;
os << ", " << *targetExpression;
}
os << " : { " << join(body) << " }";
}
Expand Down
1 change: 1 addition & 0 deletions src/ram/Aggregate.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class Aggregate : public RelationOperation, public AbstractAggregate {
RelationOperation::apply(map);
condition = map(std::move(condition));
expression = map(std::move(expression));
function->apply(map);
}

static bool classof(const Node* n) {
Expand Down
2 changes: 2 additions & 0 deletions src/ram/Aggregator.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class Aggregator {
return {};
}

virtual void apply(const NodeMapper&) {}

/**
* @brief Create a cloning (i.e. deep copy) of this node
*/
Expand Down
1 change: 1 addition & 0 deletions src/ram/IndexAggregate.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class IndexAggregate : public IndexOperation, public AbstractAggregate {
IndexOperation::apply(map);
condition = map(std::move(condition));
expression = map(std::move(expression));
function->apply(map);
}

static bool classof(const Node* n) {
Expand Down
6 changes: 5 additions & 1 deletion src/ram/UserDefinedAggregator.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ class UserDefinedAggregator : public Aggregator {
os << name << " INIT " << *initValue << " ";
}

void apply(const NodeMapper& map) override {
initValue = map(std::move(initValue));
}

protected:
/** Aggregation function */
const std::string name;
Expand All @@ -92,4 +96,4 @@ class UserDefinedAggregator : public Aggregator {
/** Stateful */
const bool stateful;
};
} // namespace souffle::ram
} // namespace souffle::ram
Loading