souffle  2.0.2-371-g6315b36
Public Member Functions | Protected Member Functions
souffle::ram::transform::ExpandFilterTransformer Class Reference

Transforms Conjunctions into consecutive filter operations. More...

#include <ExpandFilter.h>

Inheritance diagram for souffle::ram::transform::ExpandFilterTransformer:
Inheritance graph
Collaboration diagram for souffle::ram::transform::ExpandFilterTransformer:
Collaboration graph

Public Member Functions

bool expandFilters (Program &program)
 Expand filter operations. More...
 
std::string getName () const override
 @Brief get name of the transformer More...
 
- Public Member Functions inherited from souffle::ram::transform::Transformer
bool apply (TranslationUnit &translationUnit)
 @Brief apply the transformer to a translation unit @Param translationUnit that will be transformed. More...
 
virtual ~Transformer ()=default
 

Protected Member Functions

bool transform (TranslationUnit &translationUnit) override
 @Brief transform the translation unit / used by apply @Param translationUnit that will be transformed. More...
 

Detailed Description

Transforms Conjunctions into consecutive filter operations.

For example ..

QUERY
...
IF C1 /\ C2 then
...

will be rewritten to

QUERY
...
IF C1
IF C2
...

Definition at line 52 of file ExpandFilter.h.

Member Function Documentation

◆ expandFilters()

bool souffle::ram::transform::ExpandFilterTransformer::expandFilters ( Program program)

Expand filter operations.

Parameters
programProgram that is transformed
Returns
Flag showing whether the program has been changed by the transformation

Definition at line 37 of file ExpandFilter.cpp.

37  {
38  const Condition* condition = &filter->getCondition();
39  VecOwn<Condition> conditionList = toConjunctionList(condition);
40  if (conditionList.size() > 1) {
41  changed = true;
42  VecOwn<Filter> filters;
43  for (auto& cond : conditionList) {
44  if (filters.empty()) {
45  filters.emplace_back(mk<Filter>(
46  souffle::clone(cond), souffle::clone(&filter->getOperation())));
47  } else {
48  filters.emplace_back(mk<Filter>(souffle::clone(cond), std::move(filters.back())));
49  }
50  }
51  node = std::move(filters.back());
52  }
53  }
54  node->apply(makeLambdaRamMapper(filterRewriter));
55  return node;
56  };
57  const_cast<Query*>(&query)->apply(makeLambdaRamMapper(filterRewriter));
58  });
59  return changed;
60 }
61 
62 } // namespace ram::transform
63 } // end of namespace souffle

References souffle::clone(), souffle::filter(), and souffle::ram::toConjunctionList().

Here is the call graph for this function:

◆ getName()

std::string souffle::ram::transform::ExpandFilterTransformer::getName ( ) const
inlineoverridevirtual

@Brief get name of the transformer

Implements souffle::ram::transform::Transformer.

Definition at line 54 of file ExpandFilter.h.

61  :
62  bool transform(TranslationUnit& translationUnit) override {

◆ transform()

bool souffle::ram::transform::ExpandFilterTransformer::transform ( TranslationUnit translationUnit)
inlineoverrideprotectedvirtual

@Brief transform the translation unit / used by apply @Param translationUnit that will be transformed.

@Return flag reporting whether the RAM program has changed

Implements souffle::ram::transform::Transformer.

Definition at line 66 of file ExpandFilter.h.


The documentation for this class was generated from the following files:
souffle::ram::toConjunctionList
VecOwn< Condition > toConjunctionList(const Condition *condition)
Convert terms of a conjunction to a list.
Definition: Utils.h:57
souffle::ram::transform::Transformer::apply
bool apply(TranslationUnit &translationUnit)
@Brief apply the transformer to a translation unit @Param translationUnit that will be transformed.
Definition: Transformer.cpp:39
souffle::clone
auto clone(const std::vector< A * > &xs)
Definition: ContainerUtil.h:172
souffle::filter
std::vector< A > filter(std::vector< A > xs, F &&f)
Filter a vector to include certain elements.
Definition: FunctionalUtil.h:155
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::makeLambdaRamMapper
LambdaNodeMapper< Lambda > makeLambdaRamMapper(const Lambda &lambda)
Creates a node mapper based on a corresponding lambda expression.
Definition: LambdaNodeMapper.h:67