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

Use an index to find a tuple in a relation such that a given condition holds. More...

#include <IndexChoice.h>

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

Public Member Functions

void apply (const NodeMapper &map) override
 Apply the mapper to all child nodes. More...
 
IndexChoiceclone () const override
 Create a clone (i.e. More...
 
std::vector< const Node * > getChildNodes () const override
 Obtain list of all embedded child nodes. More...
 
 IndexChoice (std::string rel, int ident, Own< Condition > cond, RamPattern queryPattern, Own< Operation > nested, std::string profileText="")
 
- Public Member Functions inherited from souffle::ram::IndexOperation
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
 
- Public Member Functions inherited from souffle::ram::AbstractChoice
 AbstractChoice (Own< Condition > cond)
 
void apply (const NodeMapper &map)
 
std::vector< const Node * > getChildNodes () const
 
const ConditiongetCondition () const
 Getter for the condition. More...
 

Protected Member Functions

bool equal (const Node &node) const override
 Equality check for two RAM nodes. More...
 
void print (std::ostream &os, int tabpos) const override
 Pretty print with indentation. More...
 
- Protected Member Functions inherited from souffle::ram::IndexOperation
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 Member Functions inherited from souffle::ram::AbstractChoice
bool equal (const Node &node) const
 

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...
 
- Protected Attributes inherited from souffle::ram::IndexOperation
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...
 
- Protected Attributes inherited from souffle::ram::AbstractChoice
Own< Conditioncondition
 Condition for which a tuple in the relation may hold. More...
 

Detailed Description

Use an index to find a tuple in a relation such that a given condition holds.

Only one tuple is returned (if one exists), even if multiple tuples satisfying the condition exist.

For example:

QUERY
...
CHOICE A AS t1 ON INDEX t1.x=10 AND t1.y = 20
WHERE (t1.x, t1.y) NOT IN A
...

Definition at line 58 of file IndexChoice.h.

Constructor & Destructor Documentation

◆ IndexChoice()

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

Definition at line 60 of file IndexChoice.h.

60  {
61  assert(getRangePattern().first.size() == getRangePattern().second.size() && "Arity mismatch");
62  }
63 
64  void apply(const NodeMapper& map) override {
66  for (auto& pattern : queryPattern.first) {

References souffle::ram::IndexOperation::getRangePattern().

Here is the call graph for this function:

Member Function Documentation

◆ apply()

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

Apply the mapper to all child nodes.

Reimplemented from souffle::ram::Node.

Definition at line 68 of file IndexChoice.h.

69  : queryPattern.second) {
70  pattern = map(std::move(pattern));
71  }
73  }
74 
75  std::vector<const Node*> getChildNodes() const override {
76  auto res = IndexOperation::getChildNodes();
77  res.push_back(AbstractChoice::getChildNodes().at(0));

◆ clone()

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

Create a clone (i.e.

deep copy) of this node

Implements souffle::ram::RelationOperation.

Reimplemented in souffle::ram::ParallelIndexChoice.

Definition at line 85 of file IndexChoice.h.

86  : queryPattern.second) {
87  resQueryPattern.second.emplace_back(i->clone());
88  }
90  std::move(resQueryPattern), souffle::clone(&getOperation()), getProfileText());
91  return res;
92  }
93 
94 protected:
95  void print(std::ostream& os, int tabpos) const override {
96  os << times(" ", tabpos);

◆ equal()

bool souffle::ram::IndexChoice::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 108 of file IndexChoice.h.

◆ getChildNodes()

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

Obtain list of all embedded child nodes.

Reimplemented from souffle::ram::Node.

Definition at line 79 of file IndexChoice.h.

81  {
82  RamPattern resQueryPattern;
83  for (const auto& i : queryPattern.first) {

◆ print()

void souffle::ram::IndexChoice::print ( std::ostream &  os,
int  tabpos 
) const
inlineoverrideprotectedvirtual

Pretty print with indentation.

Implements souffle::ram::Operation.

Reimplemented in souffle::ram::ParallelIndexChoice.

Definition at line 99 of file IndexChoice.h.

104  {
105  const auto& other = static_cast<const IndexChoice&>(node);
106  return IndexOperation::equal(other) && AbstractChoice::equal(other);

The documentation for this class was generated from the following file:
souffle::ram::AbstractChoice::apply
void apply(const NodeMapper &map)
Definition: AbstractChoice.h:50
souffle::ram::IndexOperation::getRangePattern
std::pair< std::vector< Expression * >, std::vector< Expression * > > getRangePattern() const
Get range pattern.
Definition: IndexOperation.h:70
souffle::ram::IndexOperation::getChildNodes
std::vector< const Node * > getChildNodes() const override
Obtain list of all embedded child nodes.
Definition: IndexOperation.h:74
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::IndexChoice::getChildNodes
std::vector< const Node * > getChildNodes() const override
Obtain list of all embedded child nodes.
Definition: IndexChoice.h:79
souffle::ram::RelationOperation::relation
const std::string relation
Search relation.
Definition: RelationOperation.h:60
souffle::clone
auto clone(const std::vector< A * > &xs)
Definition: ContainerUtil.h:172
souffle::ram::AbstractChoice::equal
bool equal(const Node &node) const
Definition: AbstractChoice.h:59
souffle::times
detail::multiplying_printer< T > times(const T &value, unsigned num)
A utility printing a given value multiple times.
Definition: StreamUtil.h:322
i
size_t i
Definition: json11.h:663
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::AbstractChoice::getChildNodes
std::vector< const Node * > getChildNodes() const
Definition: AbstractChoice.h:54
CHOICE
#define CHOICE(Structure, Arity,...)
souffle::ram::IndexChoice::print
void print(std::ostream &os, int tabpos) const override
Pretty print with indentation.
Definition: IndexChoice.h:99
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::AbstractChoice::condition
Own< Condition > condition
Condition for which a tuple in the relation may hold.
Definition: AbstractChoice.h:65
souffle::ram::IndexChoice::apply
void apply(const NodeMapper &map) override
Apply the mapper to all child nodes.
Definition: IndexChoice.h:68
souffle::ram::IndexChoice::IndexChoice
IndexChoice(std::string rel, int ident, Own< Condition > cond, RamPattern queryPattern, Own< Operation > nested, std::string profileText="")
Definition: IndexChoice.h:60