souffle  2.0.2-371-g6315b36
Data Structures | Public Types | Public Member Functions
souffle::Relation Class Referenceabstract

Object-oriented wrapper class for Souffle's templatized relations. More...

#include <SouffleInterface.h>

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

Data Structures

class  iterator
 Wrapper class for abstract iterator. More...
 
class  iterator_base
 Abstract iterator class. More...
 

Public Types

using arity_type = uint32_t
 

Public Member Functions

virtual iterator begin () const =0
 Return an iterator pointing to the first tuple of the relation. More...
 
virtual bool contains (const tuple &t) const =0
 Check whether a tuple exists in a relation. More...
 
virtual iterator end () const =0
 Return an iterator pointing to next to the last tuple of the relation. More...
 
virtual arity_type getArity () const =0
 Return the arity of a relation. More...
 
virtual const char * getAttrName (size_t) const =0
 Get the attribute name of a relation at the column specified by the parameter. More...
 
virtual const char * getAttrType (size_t) const =0
 Get the attribute type of a relation at the column specified by the parameter. More...
 
virtual arity_type getAuxiliaryArity () const =0
 Return the number of auxiliary attributes. More...
 
virtual std::string getName () const =0
 Get the name of a relation. More...
 
arity_type getPrimaryArity () const
 Return the number of non-auxiliary attributes. More...
 
std::string getSignature ()
 Get the signature of a relation. More...
 
virtual SymbolTablegetSymbolTable () const =0
 Get the symbol table of a relation. More...
 
virtual void insert (const tuple &t)=0
 Insert a new tuple into the relation. More...
 
virtual void purge ()=0
 Delete all the tuples in relation. More...
 
virtual std::size_t size () const =0
 Get the number of tuples in a relation. More...
 
virtual ~Relation ()=default
 Destructor. More...
 

Detailed Description

Object-oriented wrapper class for Souffle's templatized relations.

Definition at line 49 of file SouffleInterface.h.

Member Typedef Documentation

◆ arity_type

Definition at line 51 of file SouffleInterface.h.

Constructor & Destructor Documentation

◆ ~Relation()

virtual souffle::Relation::~Relation ( )
virtualdefault

Destructor.

Member Function Documentation

◆ begin()

virtual iterator souffle::Relation::begin ( ) const
pure virtual

Return an iterator pointing to the first tuple of the relation.

This iterator is used to access the tuples of the relation.

Returns
Iterator

Implemented in souffle::RelationWrapper< RelType >, and souffle::interpreter::RelInterface.

◆ contains()

virtual bool souffle::Relation::contains ( const tuple t) const
pure virtual

Check whether a tuple exists in a relation.

The definition of contains has to be defined by the child class of relation class.

Parameters
tReference to a tuple object
Returns
Boolean. True, if the tuple exists. False, otherwise

Implemented in souffle::interpreter::RelInterface, and souffle::RelationWrapper< RelType >.

◆ end()

virtual iterator souffle::Relation::end ( ) const
pure virtual

Return an iterator pointing to next to the last tuple of the relation.

Returns
Iterator

Implemented in souffle::RelationWrapper< RelType >, and souffle::interpreter::RelInterface.

◆ getArity()

virtual arity_type souffle::Relation::getArity ( ) const
pure virtual

Return the arity of a relation.

For example for a tuple (1 2) the arity is 2 and for a tuple (1 2 3) the arity is 3.

Returns
Arity of a relation (arity_type)

Implemented in souffle::RelationWrapper< RelType >, and souffle::interpreter::RelInterface.

Referenced by souffle::tuple::begin(), getPrimaryArity(), and souffle::Relation::iterator::operator!=().

◆ getAttrName()

virtual const char* souffle::Relation::getAttrName ( size_t  ) const
pure virtual

Get the attribute name of a relation at the column specified by the parameter.

The attribute name is the name given to the type by the user in the .decl statement. For example, for ".decl edge (node1:Node, node2:Node)", the attribute names are node1 and node2.

Parameters
Theindex of the column starting starting from 0 (size_t)
Returns
The constant string of the attribute name

Implemented in souffle::interpreter::RelInterface, and souffle::RelationWrapper< RelType >.

◆ getAttrType()

virtual const char* souffle::Relation::getAttrType ( size_t  ) const
pure virtual

Get the attribute type of a relation at the column specified by the parameter.

The attribute type is in the form "<primitive type>:<type name>". <primitive type> can be s, f, u, or i standing for symbol, float, unsigned, and integer respectively, which are the primitive types in Souffle. <type name> is the name given by the user in the Souffle program

Parameters
Theindex of the column starting starting from 0 (size_t)
Returns
The constant string of the attribute type

Implemented in souffle::interpreter::RelInterface, and souffle::RelationWrapper< RelType >.

Referenced by getPrimaryArity(), souffle::tuple::operator<<(), souffle::tuple::operator>>(), and souffle::tuple::rewind().

◆ getAuxiliaryArity()

virtual arity_type souffle::Relation::getAuxiliaryArity ( ) const
pure virtual

Return the number of auxiliary attributes.

Auxiliary attributes are used for provenance and and other alternative evaluation strategies. They are stored as the last attributes of a tuple.

Returns
Number of auxiliary attributes of a relation (arity_type)

Implemented in souffle::RelationWrapper< RelType >, and souffle::interpreter::RelInterface.

Referenced by souffle::Relation::iterator::operator!=().

◆ getName()

virtual std::string souffle::Relation::getName ( ) const
pure virtual

Get the name of a relation.

Returns
The name of a relation (std::string)

Implemented in souffle::RelationWrapper< RelType >, and souffle::interpreter::RelInterface.

Referenced by souffle::SouffleProgram::getRelationSize().

◆ getPrimaryArity()

arity_type souffle::Relation::getPrimaryArity ( ) const
inline

Return the number of non-auxiliary attributes.

Auxiliary attributes are used for provenance and and other alternative evaluation strategies. They are stored as the last attributes of a tuple.

Returns
Number of non-auxiliary attributes of a relation (arity_type)

Definition at line 381 of file SouffleInterface.h.

References getArity(), and getAttrType().

Here is the call graph for this function:

◆ getSignature()

std::string souffle::Relation::getSignature ( )
inline

Get the signature of a relation.

The signature is in the form <<primitive type 1>:<type name 1>,<primitive type 2>:<type name 2>...> for all the attributes in a relation. For example, <s:Node,s:Node>. The primitive type and type name are explained in getAttrType.

Returns
String of the signature of a relation

Definition at line 408 of file SouffleInterface.h.

408  {
409  signature += "," + std::string(getAttrType(i));
410  }
411  signature += ">";
412  return signature;
413  }
414 
415  /**
416  * Delete all the tuples in relation.
417  *
418  * When purge() is called, it sets the head and tail of the table (table is a
419  * singly-linked list structure) to nullptr, and for every elements

◆ getSymbolTable()

virtual SymbolTable& souffle::Relation::getSymbolTable ( ) const
pure virtual

Get the symbol table of a relation.

The symbols in a tuple to be stored into a relation are stored and assigned with a number in a table called symbol table. For example, to insert ("John","Student") to a relation, "John" and "Student" are stored in symbol table and they are assigned with number say 0 and 1. After this, instead of inserting ("John","Student"), (0, 1) is inserted. When accessing this tuple, 0 and 1 will be looked up in the table and replaced by "John" and "Student". This is done so to save memory space if same symbols are inserted many times. Symbol table has many rows where each row contains a symbol and its corresponding assigned number.

Returns
Reference to a symbolTable object

Implemented in souffle::RelationWrapper< RelType >, and souffle::interpreter::RelInterface.

Referenced by souffle::tuple::operator<<(), and souffle::tuple::rewind().

◆ insert()

virtual void souffle::Relation::insert ( const tuple t)
pure virtual

Insert a new tuple into the relation.

The definition of insert function has to be defined by the child class of relation class.

Parameters
tReference to a tuple class object

Implemented in souffle::interpreter::RelInterface, and souffle::RelationWrapper< RelType >.

◆ purge()

virtual void souffle::Relation::purge ( )
pure virtual

Delete all the tuples in relation.

When purge() is called, it sets the head and tail of the table (table is a singly-linked list structure) to nullptr, and for every elements in the table, set the next element pointer points to the current element itself.

Implemented in souffle::RelationWrapper< RelType >, and souffle::interpreter::RelInterface.

◆ size()

virtual std::size_t souffle::Relation::size ( ) const
pure virtual

Get the number of tuples in a relation.

Returns
The number of tuples in a relation (std::size_t)

Implemented in souffle::RelationWrapper< RelType >, and souffle::interpreter::RelInterface.


The documentation for this class was generated from the following file:
souffle::Relation::getAttrType
virtual const char * getAttrType(size_t) const =0
Get the attribute type of a relation at the column specified by the parameter.
i
size_t i
Definition: json11.h:663