souffle  2.0.2-371-g6315b36
ExpandFilter.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2018, The Souffle Developers. All rights reserved
4  * Licensed under the Universal Permissive License v 1.0 as shown at:
5  * - https://opensource.org/licenses/UPL
6  * - <souffle root>/licenses/SOUFFLE-UPL.txt
7  */
8 
9 /************************************************************************
10  *
11  * @file ExpandFilter.h
12  *
13  ***********************************************************************/
14 
15 #pragma once
16 
17 #include "ram/Program.h"
18 #include "ram/TranslationUnit.h"
20 #include <string>
21 
22 namespace souffle::ram::transform {
23 
24 /**
25  * @class ExpandFilterTransformer
26  * @brief Transforms Conjunctions into consecutive filter operations.
27  *
28  * For example ..
29  *
30  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
31  * QUERY
32  * ...
33  * IF C1 /\ C2 then
34  * ...
35  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
36  *
37  * will be rewritten to
38  *
39  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
40  * QUERY
41  * ...
42  * IF C1
43  * IF C2
44  * ...
45  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
46  *
47  */
48 class ExpandFilterTransformer : public Transformer {
49 public:
50  std::string getName() const override {
51  return "ExpandFilterTransformer";
52  }
53 
54  /**
55  * @brief Expand filter operations
56  * @param program Program that is transformed
57  * @return Flag showing whether the program has been changed by the transformation
58  */
59  bool expandFilters(Program& program);
60 
61 protected:
62  bool transform(TranslationUnit& translationUnit) override {
63  return expandFilters(translationUnit.getProgram());
64  }
65 };
66 
67 } // namespace souffle::ram::transform
souffle::ram::transform
Definition: ChoiceConversion.cpp:30
souffle::ram::Program
RAM program relation declaration and functions.
Definition: Program.h:58
Program.h
souffle::ram::TranslationUnit::getProgram
Program & getProgram() const
Get the RAM Program of the translation unit
Definition: TranslationUnit.h:107
souffle::ram::TranslationUnit
Translating a RAM program.
Definition: TranslationUnit.h:55
souffle::ram::transform::ExpandFilterTransformer::transform
bool transform(TranslationUnit &translationUnit) override
@Brief transform the translation unit / used by apply @Param translationUnit that will be transformed...
Definition: ExpandFilter.h:66
souffle::ram::transform::ExpandFilterTransformer::getName
std::string getName() const override
@Brief get name of the transformer
Definition: ExpandFilter.h:54
TranslationUnit.h
Transformer.h
souffle::ram::transform::ExpandFilterTransformer::expandFilters
bool expandFilters(Program &program)
Expand filter operations.
Definition: ExpandFilter.cpp:37