souffle  2.0.2-371-g6315b36
Public Member Functions | Protected Member Functions | Protected Attributes
souffle::ram::IndexOperation Class Reference

#include <IndexOperation.h>

Inheritance diagram for souffle::ram::IndexOperation:
Inheritance graph
Collaboration diagram for souffle::ram::IndexOperation:
Collaboration graph

Public Member Functions

void apply (const NodeMapper &map) override
 Apply the mapper to all child nodes. More...
 
IndexOperationclone () const override
 Create a clone (i.e. More...
 
std::vector< const Node * > getChildNodes () const override
 Obtain list of all embedded child nodes. More...
 
std::pair< std::vector< Expression * >, std::vector< Expression * > > getRangePattern () const
 Get range pattern. More...
 
 IndexOperation (std::string rel, int ident, RamPattern queryPattern, Own< Operation > nested, std::string profileText="")
 
void printIndex (std::ostream &os) const
 Helper method for printing. More...
 
- Public Member Functions inherited from souffle::ram::RelationOperation
const std::string & getRelation () const
 Get search relation. More...
 
 RelationOperation (std::string rel, int ident, Own< Operation > nested, std::string profileText="")
 
- Public Member Functions inherited from souffle::ram::TupleOperation
std::vector< const Node * > getChildNodes () const override
 Obtain list of all embedded child nodes. More...
 
int getTupleId () const
 Get identifier. More...
 
void setTupleId (int id)
 Set identifier. More...
 
 TupleOperation (int ident, Own< Operation > nested, std::string profileText="")
 
- Public Member Functions inherited from souffle::ram::NestedOperation
void apply (const NodeMapper &map) override
 Apply the mapper to all child nodes. More...
 
OperationgetOperation () const
 Get nested operation. More...
 
const std::string & getProfileText () const
 Get profile text. More...
 
 NestedOperation (Own< Operation > nested, std::string profileText="")
 
- Public Member Functions inherited from souffle::ram::Node
bool operator!= (const Node &other) const
 Inequality check for two RAM nodes. More...
 
bool operator== (const Node &other) const
 Equivalence check for two RAM nodes. More...
 
virtual void rewrite (const Node *oldNode, Own< Node > newNode)
 Rewrite a child node. More...
 
virtual ~Node ()=default
 

Protected Member Functions

bool equal (const Node &node) const override
 Equality check for two RAM nodes. More...
 
- Protected Member Functions inherited from souffle::ram::RelationOperation
bool equal (const Node &node) const override
 Equality check for two RAM nodes. More...
 
- Protected Member Functions inherited from souffle::ram::TupleOperation
bool equal (const Node &node) const override
 Equality check for two RAM nodes. More...
 
- Protected Member Functions inherited from souffle::ram::NestedOperation
void print (std::ostream &os, int tabpos) const override
 Pretty print with indentation. More...
 
- Protected Member Functions inherited from souffle::ram::Operation
void print (std::ostream &os) const override
 Print RAM node. More...
 

Protected Attributes

RamPattern queryPattern
 Values of index per column of table (if indexable) More...
 
- Protected Attributes inherited from souffle::ram::RelationOperation
const std::string relation
 Search relation. More...
 
- Protected Attributes inherited from souffle::ram::TupleOperation
int identifier
 Identifier for the tuple, corresponding to its position in the loop nest. More...
 
- Protected Attributes inherited from souffle::ram::NestedOperation
Own< OperationnestedOperation
 Nested operation. More...
 
const std::string profileText
 Text used by the profiler. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from souffle::ram::Operation
static void print (const Operation *operation, std::ostream &os, int tabpos)
 Pretty print jump-bed. More...
 

Detailed Description

Definition at line 48 of file IndexOperation.h.

Constructor & Destructor Documentation

◆ IndexOperation()

souffle::ram::IndexOperation::IndexOperation ( std::string  rel,
int  ident,
RamPattern  queryPattern,
Own< Operation nested,
std::string  profileText = "" 
)
inline

Definition at line 50 of file IndexOperation.h.

51  : queryPattern.first) {
52  assert(pattern != nullptr && "pattern is a null-pointer");
53  }
54  for (const auto& pattern : queryPattern.second) {
55  assert(pattern != nullptr && "pattern is a null-pointer");
56  }
57  }
58 
59  /**
60  * @brief Get range pattern
61  * @return A pair of std::vector of pointers to Expression objects

Member Function Documentation

◆ apply()

void souffle::ram::IndexOperation::apply ( const NodeMapper )
inlineoverridevirtual

Apply the mapper to all child nodes.

Reimplemented from souffle::ram::Node.

Definition at line 85 of file IndexOperation.h.

86  : queryPattern.second) {
87  pattern = map(std::move(pattern));
88  }
89  }
90 
91  IndexOperation* clone() const override {
92  RamPattern resQueryPattern;
93  for (const auto& i : queryPattern.first) {

◆ clone()

IndexOperation* souffle::ram::IndexOperation::clone ( ) const
inlineoverridevirtual

Create a clone (i.e.

deep copy) of this node

Implements souffle::ram::RelationOperation.

Reimplemented in souffle::ram::ParallelIndexChoice, souffle::ram::ParallelIndexScan, souffle::ram::IndexScan, and souffle::ram::ParallelIndexAggregate.

Definition at line 95 of file IndexOperation.h.

96  : queryPattern.second) {
97  resQueryPattern.second.emplace_back(i->clone());
98  }
99  return new IndexOperation(relation, getTupleId(), std::move(resQueryPattern),
101  }
102 
103  /** @brief Helper method for printing */
104  void printIndex(std::ostream& os) const {
105  // const auto& attrib = getRelation().getAttributeNames();

◆ equal()

bool souffle::ram::IndexOperation::equal ( const Node ) const
inlineoverrideprotectedvirtual

Equality check for two RAM nodes.

Default action is that nothing needs to be checked.

Reimplemented from souffle::ram::Node.

Definition at line 153 of file IndexOperation.h.

◆ getChildNodes()

std::vector<const Node*> souffle::ram::IndexOperation::getChildNodes ( ) const
inlineoverridevirtual

Obtain list of all embedded child nodes.

Reimplemented from souffle::ram::Node.

Definition at line 74 of file IndexOperation.h.

75  : queryPattern.second) {
76  res.push_back(pattern.get());
77  }
78  return res;
79  }
80 
81  void apply(const NodeMapper& map) override {
83  for (auto& pattern : queryPattern.first) {

Referenced by souffle::ram::IndexAggregate::IndexAggregate().

◆ getRangePattern()

std::pair<std::vector<Expression*>, std::vector<Expression*> > souffle::ram::IndexOperation::getRangePattern ( ) const
inline

Get range pattern.

Returns
A pair of std::vector of pointers to Expression objects These vectors represent the lower and upper bounds for each attribute in the tuple <expr1> <= Tuple[level, element] <= <expr2> We have that at an index for an attribute, its bounds are <expr1> and <expr2> respectively

Definition at line 70 of file IndexOperation.h.

70  {
72  for (auto& pattern : queryPattern.first) {

References souffle::ram::TupleOperation::getChildNodes(), and queryPattern.

Referenced by souffle::ram::IndexChoice::IndexChoice().

Here is the call graph for this function:

◆ printIndex()

void souffle::ram::IndexOperation::printIndex ( std::ostream &  os) const
inline

Helper method for printing.

Definition at line 108 of file IndexOperation.h.

109  {
110  continue;
111  }
112 
113  if (first) {
114  os << " ON INDEX ";
115  first = false;
116  } else {
117  os << " AND ";
118  }
119 
120  // both bounds defined and equal => equality
121  if (!isUndefValue(queryPattern.first[i].get()) && !isUndefValue(queryPattern.second[i].get())) {
122  // print equality when lower bound = upper bound
123  if (*(queryPattern.first[i]) == *(queryPattern.second[i])) {
124  os << "t" << getTupleId() << ".";
125  os << i << " = ";
126  os << *(queryPattern.first[i]);
127  continue;
128  }
129  }
130  // at least one bound defined => inequality
131  if (!isUndefValue(queryPattern.first[i].get()) || !isUndefValue(queryPattern.second[i].get())) {
132  if (!isUndefValue(queryPattern.first[i].get())) {
133  os << *(queryPattern.first[i]) << " <= ";
134  }
135 
136  os << "t" << getTupleId() << ".";
137  os << i;
138 
139  if (!isUndefValue(queryPattern.second[i].get())) {
140  os << " <= " << *(queryPattern.second[i]);
141  }
142 
143  continue;
144  }
145  }
146  }
147 
148 protected:
149  bool equal(const Node& node) const override {
150  const auto& other = static_cast<const IndexOperation&>(node);

Field Documentation

◆ queryPattern

RamPattern souffle::ram::IndexOperation::queryPattern
protected

The documentation for this class was generated from the following file:
souffle::ram::isUndefValue
bool isUndefValue(const Expression *expr)
Determines if an expression represents an undefined value.
Definition: Utils.h:40
souffle::ram::TupleOperation::getChildNodes
std::vector< const Node * > getChildNodes() const override
Obtain list of all embedded child nodes.
Definition: TupleOperation.h:52
souffle::ram::NestedOperation::apply
void apply(const NodeMapper &map) override
Apply the mapper to all child nodes.
Definition: NestedOperation.h:75
souffle::ram::NestedOperation::getOperation
Operation & getOperation() const
Get nested operation.
Definition: NestedOperation.h:62
souffle::map
auto map(const std::vector< A > &xs, F &&f)
Applies a function to each element of a vector and returns the results.
Definition: ContainerUtil.h:158
souffle::ram::RelationOperation::relation
const std::string relation
Search relation.
Definition: RelationOperation.h:60
souffle::ram::IndexOperation::apply
void apply(const NodeMapper &map) override
Apply the mapper to all child nodes.
Definition: IndexOperation.h:85
souffle::clone
auto clone(const std::vector< A * > &xs)
Definition: ContainerUtil.h:172
i
size_t i
Definition: json11.h:663
souffle::ram::IndexOperation::clone
IndexOperation * clone() const override
Create a clone (i.e.
Definition: IndexOperation.h:95
souffle::ram::NestedOperation::getProfileText
const std::string & getProfileText() const
Get profile text.
Definition: NestedOperation.h:67
souffle::ram::IndexOperation::equal
bool equal(const Node &node) const override
Equality check for two RAM nodes.
Definition: IndexOperation.h:153
souffle::ram::TupleOperation::getTupleId
int getTupleId() const
Get identifier.
Definition: TupleOperation.h:43
souffle::ram::IndexOperation::printIndex
void printIndex(std::ostream &os) const
Helper method for printing.
Definition: IndexOperation.h:108
souffle::ram::IndexOperation::queryPattern
RamPattern queryPattern
Values of index per column of table (if indexable)
Definition: IndexOperation.h:161
souffle::ram::RamPattern
std::pair< RamBound, RamBound > RamPattern
Definition: IndexOperation.h:42
souffle::ram::IndexOperation::IndexOperation
IndexOperation(std::string rel, int ident, RamPattern queryPattern, Own< Operation > nested, std::string profileText="")
Definition: IndexOperation.h:50