souffle  2.0.2-371-g6315b36
Data Structures | Public Member Functions | Static Public Member Functions | Private Attributes | Friends
souffle::ram::analysis::SearchSignature Class Reference

search signature of a RAM operation; each bit represents an attribute of a relation. More...

#include <Index.h>

Collaboration diagram for souffle::ram::analysis::SearchSignature:
Collaboration graph

Data Structures

class  Hasher
 

Public Member Functions

size_t arity () const
 
bool containsEquality () const
 
bool empty () const
 
bool operator!= (const SearchSignature &other) const
 
bool operator< (const SearchSignature &other) const
 
bool operator== (const SearchSignature &other) const
 
AttributeConstraintoperator[] (std::size_t pos)
 
const AttributeConstraintoperator[] (std::size_t pos) const
 
 SearchSignature (size_t arity)
 

Static Public Member Functions

static SearchSignature getDelta (const SearchSignature &lhs, const SearchSignature &rhs)
 
static SearchSignature getDischarged (const SearchSignature &signature)
 
static SearchSignature getFullSearchSignature (size_t arity)
 
static bool isComparable (const SearchSignature &lhs, const SearchSignature &rhs)
 
static bool isSubset (const SearchSignature &lhs, const SearchSignature &rhs)
 

Private Attributes

std::vector< AttributeConstraintconstraints
 

Friends

std::ostream & operator<< (std::ostream &out, const SearchSignature &signature)
 

Detailed Description

search signature of a RAM operation; each bit represents an attribute of a relation.

A one represents that the attribute has an assigned value; a zero represents that no value exists (i.e. attribute is unbounded) in the search.

Definition at line 52 of file Index.h.

Constructor & Destructor Documentation

◆ SearchSignature()

souffle::ram::analysis::SearchSignature::SearchSignature ( size_t  arity)
explicit

Definition at line 45 of file Index.cpp.

Member Function Documentation

◆ arity()

size_t souffle::ram::analysis::SearchSignature::arity ( ) const

◆ containsEquality()

bool souffle::ram::analysis::SearchSignature::containsEquality ( ) const

Definition at line 87 of file Index.cpp.

92  {
93  assert(lhs.arity() == rhs.arity());
94  if (lhs == rhs) {

◆ empty()

bool souffle::ram::analysis::SearchSignature::empty ( ) const

Definition at line 77 of file Index.cpp.

81  {
82  for (auto constraint : constraints) {
83  if (constraint == AttributeConstraint::Equal) {
84  return true;
85  }

Referenced by souffle::ram::analysis::MinIndexSelection::addSearch().

◆ getDelta()

SearchSignature souffle::ram::analysis::SearchSignature::getDelta ( const SearchSignature lhs,
const SearchSignature rhs 
)
static

Definition at line 126 of file Index.cpp.

127  {
128  delta.constraints[i] = AttributeConstraint::None;
129  }
130  }
131  return delta;
132 }
133 
135  SearchSignature res(arity);
136  for (size_t i = 0; i < arity; ++i) {
137  res.constraints[i] = AttributeConstraint::Equal;
138  }

◆ getDischarged()

SearchSignature souffle::ram::analysis::SearchSignature::getDischarged ( const SearchSignature signature)
static

Definition at line 148 of file Index.cpp.

152  {
153  size_t len = signature.constraints.size();
154  for (size_t i = 0; i < len; ++i) {
155  switch (signature.constraints[i]) {
156  case AttributeConstraint::None: out << 0; break;

◆ getFullSearchSignature()

SearchSignature souffle::ram::analysis::SearchSignature::getFullSearchSignature ( size_t  arity)
static

Definition at line 140 of file Index.cpp.

142  {
143  SearchSignature res = signature; // copy original
144  for (size_t i = 0; i < res.arity(); ++i) {
145  if (res[i] == AttributeConstraint::Inequal) {

Referenced by souffle::interpreter::NodeGenerator::encodeIndexPos(), and souffle::ram::analysis::MinIndexSelection::insertDefaultTotalIndex().

◆ isComparable()

bool souffle::ram::analysis::SearchSignature::isComparable ( const SearchSignature lhs,
const SearchSignature rhs 
)
static

Definition at line 98 of file Index.cpp.

99  {
101  if (lhs[i] != AttributeConstraint::None) {
102  withinDelta = false;
103  }
104  }
105  }
106  return withinDelta;
107 }
108 
110  assert(lhs.arity() == rhs.arity());
111  size_t len = lhs.arity();
112  for (size_t i = 0; i < len; ++i) {

References i, souffle::ram::analysis::Inequal, lhs, souffle::ram::analysis::None, and rhs.

Referenced by operator[]().

◆ isSubset()

bool souffle::ram::analysis::SearchSignature::isSubset ( const SearchSignature lhs,
const SearchSignature rhs 
)
static

Definition at line 115 of file Index.cpp.

120  {
121  assert(lhs.arity() == rhs.arity());
122  SearchSignature delta(lhs.arity());
123  for (size_t i = 0; i < lhs.arity(); ++i) {
124  // if constraints are the same then delta is nothing

Referenced by operator[]().

◆ operator!=()

bool souffle::ram::analysis::SearchSignature::operator!= ( const SearchSignature other) const

Definition at line 73 of file Index.cpp.

73  {
75  return false;

References constraints, i, and souffle::ram::analysis::None.

◆ operator<()

bool souffle::ram::analysis::SearchSignature::operator< ( const SearchSignature other) const

Definition at line 63 of file Index.cpp.

◆ operator==()

bool souffle::ram::analysis::SearchSignature::operator== ( const SearchSignature other) const

Definition at line 68 of file Index.cpp.

71  {

◆ operator[]() [1/2]

AttributeConstraint & souffle::ram::analysis::SearchSignature::operator[] ( std::size_t  pos)

Definition at line 52 of file Index.cpp.

◆ operator[]() [2/2]

const AttributeConstraint & souffle::ram::analysis::SearchSignature::operator[] ( std::size_t  pos) const

Definition at line 57 of file Index.cpp.

57  {
58  assert(constraints.size() == other.constraints.size());
59  return isComparable(*this, other) && isSubset(*this, other);
60 }

References constraints, isComparable(), and isSubset().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const SearchSignature signature 
)
friend

Definition at line 158 of file Index.cpp.

158  : out << 2; break;
159  }
160  }
161  return out;
162 }
163 
164 void MaxMatching::addEdge(Node u, Node v) {
165  assert(u >= 1 && v >= 1 && "Nodes must be greater than or equal to 1");
166  if (graph.find(u) == graph.end()) {
167  Edges vals;
168  vals.insert(v);

Field Documentation

◆ constraints

std::vector<AttributeConstraint> souffle::ram::analysis::SearchSignature::constraints
private

The documentation for this class was generated from the following files:
souffle::ram::analysis::SearchSignature::SearchSignature
SearchSignature(size_t arity)
Definition: Index.cpp:45
souffle::ram::analysis::AttributeConstraint::Inequal
@ Inequal
rhs
Own< Argument > rhs
Definition: ResolveAliases.cpp:185
souffle::ram::analysis::SearchSignature::arity
size_t arity() const
Definition: Index.cpp:47
souffle::ram::analysis::AttributeConstraint::None
@ None
lhs
Own< Argument > lhs
Definition: ResolveAliases.cpp:184
souffle::ram::analysis::SearchSignature::constraints
std::vector< AttributeConstraint > constraints
Definition: Index.h:90
i
size_t i
Definition: json11.h:663
souffle::ram::analysis::SearchSignature::isSubset
static bool isSubset(const SearchSignature &lhs, const SearchSignature &rhs)
Definition: Index.cpp:115
souffle::ram::analysis::SearchSignature::isComparable
static bool isComparable(const SearchSignature &lhs, const SearchSignature &rhs)
Definition: Index.cpp:98
souffle::ram::analysis::SearchSignature::getFullSearchSignature
static SearchSignature getFullSearchSignature(size_t arity)
Definition: Index.cpp:140
souffle::ram::analysis::AttributeConstraint::Equal
@ Equal
souffle::ram::analysis::MaxMatching::addEdge
void addEdge(Node u, Node v)
@Brief add an edge to the bi-partite graph
Definition: Index.cpp:170