souffle  2.0.2-371-g6315b36
CollapseFilters.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 CollapseFilters.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 CollapseFiltersTransformer
26  * @brief Transforms consecutive filters into a single filter containing a conjunction
27  *
28  * For example ..
29  *
30  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
31  * QUERY
32  * ...
33  * IF C1
34  * IF C2
35  * ...
36  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
37  *
38  * will be rewritten to
39  *
40  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
41  * QUERY
42  * ...
43  * IF C1 /\ C2 then
44  * ...
45  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
46  *
47  */
48 class CollapseFiltersTransformer : public Transformer {
49 public:
50  std::string getName() const override {
51  return "CollapseFiltersTransformer";
52  }
53 
54  /**
55  * @brief Collapse consecutive 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 collapseFilters(Program& program);
60 
61 protected:
62  bool transform(TranslationUnit& translationUnit) override {
63  return collapseFilters(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
souffle::ram::transform::CollapseFiltersTransformer::collapseFilters
bool collapseFilters(Program &program)
Collapse consecutive filter operations.
Definition: CollapseFilters.cpp:35
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
TranslationUnit.h
Transformer.h
souffle::ram::transform::CollapseFiltersTransformer::getName
std::string getName() const override
@Brief get name of the transformer
Definition: CollapseFilters.h:54
souffle::ram::transform::CollapseFiltersTransformer::transform
bool transform(TranslationUnit &translationUnit) override
@Brief transform the translation unit / used by apply @Param translationUnit that will be transformed...
Definition: CollapseFilters.h:66