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

An abstract class for performing indexed operations. More...

#include <Relation.h>

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

Public Member Functions

Relationclone () const override
 Create a clone (i.e. More...
 
unsigned getArity () const
 Get arity of relation. More...
 
const std::vector< std::string > & getAttributeNames () const
 Get attribute names. More...
 
const std::vector< std::string > & getAttributeTypes () const
 Get attribute types. More...
 
unsigned getAuxiliaryArity () const
 Get number of auxiliary attributes. More...
 
const std::string & getName () const
 Get name. More...
 
RelationRepresentation getRepresentation () const
 Relation representation type. More...
 
bool isNullary () const
 Is nullary relation. More...
 
bool isTemp () const
 Is temporary relation (for semi-naive evaluation) More...
 
bool operator< (const Relation &other) const
 Compare two relations via their name. More...
 
 Relation (std::string name, size_t arity, size_t auxiliaryArity, std::vector< std::string > attributeNames, std::vector< std::string > attributeTypes, RelationRepresentation representation)
 
- Public Member Functions inherited from souffle::ram::Node
virtual void apply (const NodeMapper &)
 Apply the mapper to all child nodes. More...
 
virtual std::vector< const Node * > getChildNodes () const
 Obtain list of all embedded child nodes. More...
 
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...
 
void print (std::ostream &out) const override
 Print RAM node. More...
 

Protected Attributes

const size_t arity
 Arity, i.e., number of attributes. More...
 
const std::vector< std::string > attributeNames
 Name of attributes. More...
 
const std::vector< std::string > attributeTypes
 Type of attributes. More...
 
const size_t auxiliaryArity
 Number of auxiliary attributes (e.g. More...
 
const std::string name
 Name of relation. More...
 
const RelationRepresentation representation
 Data-structure representation. More...
 

Detailed Description

An abstract class for performing indexed operations.

A RAM Relation in the RAM intermediate representation.

Index

Definition at line 40 of file Relation.h.

Constructor & Destructor Documentation

◆ Relation()

souffle::ram::Relation::Relation ( std::string  name,
size_t  arity,
size_t  auxiliaryArity,
std::vector< std::string >  attributeNames,
std::vector< std::string >  attributeTypes,
RelationRepresentation  representation 
)
inline

Definition at line 42 of file Relation.h.

44  {
45  assert(!this->attributeNames[i].empty() && "no attribute name specified");
46  assert(!this->attributeTypes[i].empty() && "no attribute type specified");
47  }
48  }
49 
50  /** @brief Get name */
51  const std::string& getName() const {
52  return name;
53  }

Member Function Documentation

◆ clone()

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

Create a clone (i.e.

deep copy) of this node

Implements souffle::ram::Node.

Definition at line 100 of file Relation.h.

100  {
101  out << name;
102  if (arity > 0) {

References arity, attributeNames, attributeTypes, i, and name.

◆ equal()

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

126  :
127  /** Data-structure representation */
129 

◆ getArity()

unsigned souffle::ram::Relation::getArity ( ) const
inline

Get arity of relation.

Definition at line 86 of file Relation.h.

86  {
87  return auxiliaryArity;
88  }

References auxiliaryArity.

Referenced by souffle::synthesiser::Relation::getSynthesiserRelation().

◆ getAttributeNames()

const std::vector<std::string>& souffle::ram::Relation::getAttributeNames ( ) const
inline

Get attribute names.

Definition at line 66 of file Relation.h.

66  {
67  return arity == 0;
68  }

References arity.

◆ getAttributeTypes()

const std::vector<std::string>& souffle::ram::Relation::getAttributeTypes ( ) const
inline

Get attribute types.

Definition at line 61 of file Relation.h.

61  {
62  return attributeNames;
63  }

References attributeNames.

◆ getAuxiliaryArity()

unsigned souffle::ram::Relation::getAuxiliaryArity ( ) const
inline

Get number of auxiliary attributes.

Definition at line 91 of file Relation.h.

91  {
92  return name < other.name;
93  }

References name.

◆ getName()

const std::string& souffle::ram::Relation::getName ( ) const
inline

Get name.

Definition at line 56 of file Relation.h.

56  {
57  return attributeTypes;
58  }

References attributeTypes.

◆ getRepresentation()

RelationRepresentation souffle::ram::Relation::getRepresentation ( ) const
inline

Relation representation type.

Definition at line 76 of file Relation.h.

76  {
77  return name.at(0) == '@';
78  }

References name.

Referenced by souffle::synthesiser::Relation::getSynthesiserRelation().

◆ isNullary()

bool souffle::ram::Relation::isNullary ( ) const
inline

Is nullary relation.

Definition at line 71 of file Relation.h.

71  {
72  return representation;
73  }

References representation.

Referenced by souffle::synthesiser::Relation::getSynthesiserRelation().

◆ isTemp()

bool souffle::ram::Relation::isTemp ( ) const
inline

Is temporary relation (for semi-naive evaluation)

Definition at line 81 of file Relation.h.

81  {
82  return arity;
83  }

References arity.

◆ operator<()

bool souffle::ram::Relation::operator< ( const Relation other) const
inline

Compare two relations via their name.

Definition at line 96 of file Relation.h.

99  :
100  void print(std::ostream& out) const override {

◆ print()

void souffle::ram::Relation::print ( std::ostream &  out) const
inlineoverrideprotectedvirtual

Print RAM node.

Implements souffle::ram::Node.

Definition at line 105 of file Relation.h.

106  :" << attributeTypes[i];
107  if (i >= arity - auxiliaryArity) {
108  out << " auxiliary";
109  }
110  }
111  out << ")";
112  out << " " << representation;
113  } else {
114  out << " nullary";
115  }
116  }
117 
118  bool equal(const Node& node) const override {
119  assert(isA<Relation>(&node));
120  const auto& other = static_cast<const Relation&>(node);
121  return representation == other.representation && name == other.name && arity == other.arity &&

Field Documentation

◆ arity

const size_t souffle::ram::Relation::arity
protected

Arity, i.e., number of attributes.

Definition at line 139 of file Relation.h.

Referenced by clone(), getAttributeNames(), and isTemp().

◆ attributeNames

const std::vector<std::string> souffle::ram::Relation::attributeNames
protected

Name of attributes.

Definition at line 145 of file Relation.h.

Referenced by clone(), and getAttributeTypes().

◆ attributeTypes

const std::vector<std::string> souffle::ram::Relation::attributeTypes
protected

Type of attributes.

Definition at line 148 of file Relation.h.

Referenced by clone(), and getName().

◆ auxiliaryArity

const size_t souffle::ram::Relation::auxiliaryArity
protected

Number of auxiliary attributes (e.g.

provenance attributes etc)

Definition at line 142 of file Relation.h.

Referenced by getArity().

◆ name

const std::string souffle::ram::Relation::name
protected

Name of relation.

Definition at line 136 of file Relation.h.

Referenced by clone(), getAuxiliaryArity(), and getRepresentation().

◆ representation

const RelationRepresentation souffle::ram::Relation::representation
protected

Data-structure representation.

Definition at line 133 of file Relation.h.

Referenced by isNullary().


The documentation for this class was generated from the following file:
souffle::ram::Relation::name
const std::string name
Name of relation.
Definition: Relation.h:136
souffle::ram::Relation::arity
const size_t arity
Arity, i.e., number of attributes.
Definition: Relation.h:139
souffle::ram::Relation::attributeNames
const std::vector< std::string > attributeNames
Name of attributes.
Definition: Relation.h:145
souffle::ram::Relation::auxiliaryArity
const size_t auxiliaryArity
Number of auxiliary attributes (e.g.
Definition: Relation.h:142
souffle::ram::Relation::print
void print(std::ostream &out) const override
Print RAM node.
Definition: Relation.h:105
souffle::ram::Relation::representation
const RelationRepresentation representation
Data-structure representation.
Definition: Relation.h:133
i
size_t i
Definition: json11.h:663
souffle::ram::Relation::attributeTypes
const std::vector< std::string > attributeTypes
Type of attributes.
Definition: Relation.h:148
souffle::ram::Relation::getName
const std::string & getName() const
Get name.
Definition: Relation.h:56
souffle::RelationRepresentation
RelationRepresentation
Space of internal representations that a relation can have.
Definition: RelationTag.h:56