Skip to content

Commit

Permalink
Pushed atom ordering generation to as late as possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
azreika committed Dec 8, 2020
1 parent 9cf062a commit c2b404b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
13 changes: 5 additions & 8 deletions src/ast2ram/ClauseTranslator.cpp
Expand Up @@ -197,12 +197,9 @@ Own<ram::Statement> ClauseTranslator::createRamRuleQuery(
const ast::Clause& clause, const ast::Clause& originalClause, int version) {
assert(isRule(clause) && "clause should be rule");

// Set up atom ordering
atomOrder = getAtomOrdering(clause, version);

// Index all variables and generators in the clause
valueIndex = mk<ValueIndex>();
indexClause(clause);
indexClause(clause, version);

// Set up the RAM statement bottom-up
auto op = createProjection(clause, originalClause);
Expand Down Expand Up @@ -704,8 +701,8 @@ void ClauseTranslator::indexGenerator(const ast::Argument& arg) {
valueIndex->setGeneratorLoc(arg, Location({aggLoc, 0}));
}

void ClauseTranslator::indexAtoms(const ast::Clause& clause) {
for (const auto* atom : atomOrder) {
void ClauseTranslator::indexAtoms(const ast::Clause& clause, int version) {
for (const auto* atom : getAtomOrdering(clause, version)) {
// give the atom the current level
int scanLevel = addOperatorLevel(atom);
indexNodeArguments(scanLevel, atom->getArguments());
Expand Down Expand Up @@ -767,8 +764,8 @@ void ClauseTranslator::indexMultiResultFunctors(const ast::Clause& clause) {
});
}

void ClauseTranslator::indexClause(const ast::Clause& clause) {
indexAtoms(clause);
void ClauseTranslator::indexClause(const ast::Clause& clause, int version) {
indexAtoms(clause, version);
indexAggregators(clause);
indexMultiResultFunctors(clause);
}
Expand Down
5 changes: 2 additions & 3 deletions src/ast2ram/ClauseTranslator.h
Expand Up @@ -95,7 +95,6 @@ class ClauseTranslator {
private:
std::vector<const ast::Argument*> generators;
std::vector<const ast::Node*> operators;
std::vector<ast::Atom*> atomOrder;

Own<ram::Statement> generateClauseVersion(const std::set<const ast::Relation*>& scc,
const ast::Clause* cl, size_t deltaAtomIdx, size_t version);
Expand All @@ -106,8 +105,8 @@ class ClauseTranslator {
int addOperatorLevel(const ast::Node* node);

/** Indexing */
void indexClause(const ast::Clause& clause);
void indexAtoms(const ast::Clause& clause);
void indexClause(const ast::Clause& clause, int version);
void indexAtoms(const ast::Clause& clause, int version);
void indexAggregators(const ast::Clause& clause);
void indexMultiResultFunctors(const ast::Clause& clause);
void indexNodeArguments(int nodeLevel, const std::vector<ast::Argument*>& nodeArgs);
Expand Down

0 comments on commit c2b404b

Please sign in to comment.