souffle  2.0.2-371-g6315b36
Public Member Functions | Static Public Member Functions | Protected Attributes
souffle::synthesiser::Relation Class Referenceabstract

#include <Relation.h>

Collaboration diagram for souffle::synthesiser::Relation:
Collaboration graph

Public Member Functions

virtual void computeIndices ()=0
 Compute the final list of indices to be used. More...
 
virtual void generateTypeStruct (std::ostream &out)=0
 Generate relation type struct. More...
 
size_t getArity () const
 Get arity of relation. More...
 
const std::string & getDataStructure () const
 Get data structure of relation. More...
 
MinIndexSelection::OrderCollection getIndices () const
 Get list of indices used for relation, guaranteed that original indices in analysis::MinIndexSelection come before any generated indices. More...
 
const MinIndexSelectiongetMinIndexSelection () const
 Get stored analysis::MinIndexSelection. More...
 
std::set< int > getProvenenceIndexNumbers () const
 
const ram::RelationgetRelation () const
 Get stored ram::Relation. More...
 
std::string getTypeAttributeString (const std::vector< std::string > &attributeTypes, const std::unordered_set< uint32_t > &attributesUsed) const
 Helper function to convert attribute types to a single string. More...
 
virtual std::string getTypeName ()=0
 Print type name. More...
 
 Relation (const ram::Relation &rel, const MinIndexSelection &indices, const bool isProvenance=false)
 
virtual ~Relation ()=default
 

Static Public Member Functions

static Own< RelationgetSynthesiserRelation (const ram::Relation &ramRel, const MinIndexSelection &indexSet, bool isProvenance)
 Factory method to generate a SynthesiserRelation. More...
 

Protected Attributes

MinIndexSelection::OrderCollection computedIndices
 The final list of indices used. More...
 
std::string dataStructure
 The data structure used for the relation. More...
 
const MinIndexSelectionindices
 Indices used for this relation. More...
 
const bool isProvenance
 Is this relation used with provenance. More...
 
size_t masterIndex = -1
 The number of the master index. More...
 
std::set< int > provenanceIndexNumbers
 The list of indices added for provenance computation. More...
 
const ram::Relationrelation
 Ram relation referred to by this. More...
 

Detailed Description

Definition at line 26 of file Relation.h.

Constructor & Destructor Documentation

◆ Relation()

souffle::synthesiser::Relation::Relation ( const ram::Relation rel,
const MinIndexSelection indices,
const bool  isProvenance = false 
)
inline

Definition at line 28 of file Relation.h.

29  : relation(rel), indices(indices), isProvenance(isProvenance) {}

References isProvenance.

◆ ~Relation()

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

Member Function Documentation

◆ computeIndices()

virtual void souffle::synthesiser::Relation::computeIndices ( )
pure virtual

Compute the final list of indices to be used.

◆ generateTypeStruct()

virtual void souffle::synthesiser::Relation::generateTypeStruct ( std::ostream &  out)
pure virtual

Generate relation type struct.

◆ getArity()

size_t souffle::synthesiser::Relation::getArity ( ) const
inline

Get arity of relation.

Definition at line 37 of file Relation.h.

37  {
38  return relation.getArity();
39  }

References relation.

◆ getDataStructure()

const std::string& souffle::synthesiser::Relation::getDataStructure ( ) const
inline

Get data structure of relation.

Definition at line 42 of file Relation.h.

42  {
43  return dataStructure;
44  }

References dataStructure.

◆ getIndices()

MinIndexSelection::OrderCollection souffle::synthesiser::Relation::getIndices ( ) const
inline

Get list of indices used for relation, guaranteed that original indices in analysis::MinIndexSelection come before any generated indices.

Definition at line 49 of file Relation.h.

49  {
50  return computedIndices;
51  }

References computedIndices.

◆ getMinIndexSelection()

const MinIndexSelection& souffle::synthesiser::Relation::getMinIndexSelection ( ) const
inline

Get stored analysis::MinIndexSelection.

Definition at line 58 of file Relation.h.

58  {
59  return indices;
60  }

References indices.

◆ getProvenenceIndexNumbers()

std::set<int> souffle::synthesiser::Relation::getProvenenceIndexNumbers ( ) const
inline

Definition at line 53 of file Relation.h.

53  {
55  }

References provenanceIndexNumbers.

◆ getRelation()

const ram::Relation& souffle::synthesiser::Relation::getRelation ( ) const
inline

Get stored ram::Relation.

Definition at line 63 of file Relation.h.

63  {
64  return relation;
65  }

References relation.

◆ getSynthesiserRelation()

Own< Relation > souffle::synthesiser::Relation::getSynthesiserRelation ( const ram::Relation ramRel,
const MinIndexSelection indexSet,
bool  isProvenance 
)
static

Factory method to generate a SynthesiserRelation.

Definition at line 45 of file Relation.cpp.

46  {
47  Relation* rel;
48 
49  // Handle the qualifier in souffle code
50  if (isProvenance) {
51  rel = new DirectRelation(ramRel, indexSet, isProvenance);
52  } else if (ramRel.isNullary()) {
53  rel = new NullaryRelation(ramRel, indexSet, isProvenance);
54  } else if (ramRel.getRepresentation() == RelationRepresentation::BTREE) {
55  rel = new DirectRelation(ramRel, indexSet, isProvenance);
56  } else if (ramRel.getRepresentation() == RelationRepresentation::BRIE) {
57  rel = new BrieRelation(ramRel, indexSet, isProvenance);
58  } else if (ramRel.getRepresentation() == RelationRepresentation::EQREL) {
59  rel = new EqrelRelation(ramRel, indexSet, isProvenance);
60  } else if (ramRel.getRepresentation() == RelationRepresentation::INFO) {
61  rel = new InfoRelation(ramRel, indexSet, isProvenance);
62  } else {
63  // Handle the data structure command line flag
64  if (ramRel.getArity() > 6) {
65  rel = new IndirectRelation(ramRel, indexSet, isProvenance);
66  } else {
67  rel = new DirectRelation(ramRel, indexSet, isProvenance);
68  }
69  }
70 
71  assert(rel != nullptr && "relation type not specified");
72  // generate index set
73  rel->computeIndices();
74 
75  return Own<Relation>(rel);
76 }

References souffle::BRIE, souffle::BTREE, souffle::EQREL, souffle::ram::Relation::getArity(), souffle::ram::Relation::getRepresentation(), souffle::INFO, souffle::ram::Relation::isNullary(), and rel().

Here is the call graph for this function:

◆ getTypeAttributeString()

std::string souffle::synthesiser::Relation::getTypeAttributeString ( const std::vector< std::string > &  attributeTypes,
const std::unordered_set< uint32_t > &  attributesUsed 
) const

Helper function to convert attribute types to a single string.

Definition at line 29 of file Relation.cpp.

30  {
31  std::stringstream type;
32  for (size_t i = 0; i < attributeTypes.size(); ++i) {
33  // consider only attributes used in a lex-order
34  if (attributesUsed.find(i) != attributesUsed.end()) {
35  switch (attributeTypes[i][0]) {
36  case 'f': type << 'f'; break;
37  case 'u': type << 'u'; break;
38  default: type << 'i'; // consider all non-float/unsigned types (i.e. records) as RamSigned
39  }
40  }
41  }
42  return type.str();
43 }

References i.

◆ getTypeName()

virtual std::string souffle::synthesiser::Relation::getTypeName ( )
pure virtual

Print type name.

Field Documentation

◆ computedIndices

MinIndexSelection::OrderCollection souffle::synthesiser::Relation::computedIndices
protected

The final list of indices used.

Definition at line 92 of file Relation.h.

Referenced by getIndices().

◆ dataStructure

std::string souffle::synthesiser::Relation::dataStructure
protected

The data structure used for the relation.

Definition at line 89 of file Relation.h.

Referenced by getDataStructure().

◆ indices

const MinIndexSelection& souffle::synthesiser::Relation::indices
protected

Indices used for this relation.

Definition at line 86 of file Relation.h.

Referenced by getMinIndexSelection().

◆ isProvenance

const bool souffle::synthesiser::Relation::isProvenance
protected

Is this relation used with provenance.

Definition at line 101 of file Relation.h.

Referenced by Relation().

◆ masterIndex

size_t souffle::synthesiser::Relation::masterIndex = -1
protected

The number of the master index.

Definition at line 98 of file Relation.h.

◆ provenanceIndexNumbers

std::set<int> souffle::synthesiser::Relation::provenanceIndexNumbers
protected

The list of indices added for provenance computation.

Definition at line 95 of file Relation.h.

Referenced by getProvenenceIndexNumbers().

◆ relation

const ram::Relation& souffle::synthesiser::Relation::relation
protected

Ram relation referred to by this.

Definition at line 83 of file Relation.h.


The documentation for this class was generated from the following files:
souffle::synthesiser::Relation::computedIndices
MinIndexSelection::OrderCollection computedIndices
The final list of indices used.
Definition: Relation.h:92
souffle::RelationRepresentation::BRIE
@ BRIE
souffle::synthesiser::Relation::provenanceIndexNumbers
std::set< int > provenanceIndexNumbers
The list of indices added for provenance computation.
Definition: Relation.h:95
souffle::RelationRepresentation::EQREL
@ EQREL
relation
Relation & relation
Definition: Reader.h:130
souffle::synthesiser::Relation::indices
const MinIndexSelection & indices
Indices used for this relation.
Definition: Relation.h:86
souffle::ram::Relation::Relation
Relation(std::string name, size_t arity, size_t auxiliaryArity, std::vector< std::string > attributeNames, std::vector< std::string > attributeTypes, RelationRepresentation representation)
Definition: Relation.h:42
souffle::synthesiser::Relation::isProvenance
const bool isProvenance
Is this relation used with provenance.
Definition: Relation.h:101
i
size_t i
Definition: json11.h:663
souffle::synthesiser::Relation::dataStructure
std::string dataStructure
The data structure used for the relation.
Definition: Relation.h:89
souffle::ram::Relation::attributeTypes
const std::vector< std::string > attributeTypes
Type of attributes.
Definition: Relation.h:148
souffle::RelationRepresentation::INFO
@ INFO
souffle::RelationRepresentation::BTREE
@ BTREE
rel
void rel(size_t limit, bool showLimit=true)
Definition: Tui.h:1086
std::type
ElementType type
Definition: span.h:640