souffle
2.0.2-371-g6315b36
|
Defines a tuple for the OO interface such that relations with varying columns can be accessed. More...
#include <SouffleInterface.h>
Public Member Functions | |
decltype(array) ::iterator | begin () |
Iterator for direct access to tuple's data. More... | |
const Relation & | getRelation () const |
Get the reference to the relation to which the tuple belongs. More... | |
tuple & | operator<< (const std::string &str) |
Set the "current element" of the tuple to the given string, then increment the index giving the current element. More... | |
tuple & | operator<< (RamFloat ramFloat) |
Set the "current element" of the tuple to the given float, then increment the index giving the current element. More... | |
tuple & | operator<< (RamSigned integer) |
Set the "current element" of the tuple to the given int, then increment the index giving the current element. More... | |
tuple & | operator<< (RamUnsigned uint) |
Set the "current element" of the tuple to the given uint, then increment the index giving the current element. More... | |
tuple & | operator>> (RamFloat &ramFloat) |
Get the "current element" of the tuple as a float, then increment the index giving the current element. More... | |
tuple & | operator>> (RamSigned &integer) |
Get the "current element" of the tuple as a int, then increment the index giving the current element. More... | |
tuple & | operator>> (RamUnsigned &uint) |
Get the "current element" of the tuple as a unsigned, then increment the index giving the current element. More... | |
tuple & | operator>> (std::string &str) |
Get the "current element" of the tuple as a string, then increment the index giving the current element. More... | |
RamDomain & | operator[] (size_t idx) |
Overload the operator []. More... | |
const RamDomain & | operator[] (size_t idx) const |
Overload the operator []. More... | |
void | rewind () |
Reset the index giving the "current element" of the tuple to zero. More... | |
Relation::arity_type | size () const |
Return the number of elements in the tuple. More... | |
tuple (const Relation *r) | |
Constructor. More... | |
tuple (const Relation *relation, std::initializer_list< RamDomain > tupleList) | |
Construct using initialisation list. More... | |
tuple (const tuple &t) | |
Constructor. More... | |
Data Fields | |
const RamDomain * | data = nullptr |
Allows printing using WriteStream. More... | |
Private Attributes | |
std::vector< RamDomain > | array |
Dynamic array used to store the elements in a tuple. More... | |
size_t | pos |
pos shows what the current position of a tuple is. More... | |
const Relation & | relation |
The relation to which the tuple belongs. More... | |
Defines a tuple for the OO interface such that relations with varying columns can be accessed.
Tuples are stored in relations. In Souffle, one row of data to be stored into a relation is represented as a tuple. For example if we have a relation called dog with attributes name, colour and age which are string, string and interger type respectively. One row of data a relation to be stored can be (mydog, black, 3). However, this is not directly stored as a tuple. There will be a symbol table storing the actual content and associate them with numbers (For example, |1|mydog| |2|black| |3|3|). And when this row of data is stored as a tuple, (1, 2, 3) will be stored.
Definition at line 443 of file SouffleInterface.h.
|
inline |
Constructor.
Tuples are constructed here by passing a relation, then may be subsequently inserted into that same passed relation. The passed relation pointer will be stored within the tuple instance, while the arity of the relation will be used to initialize the vector holding the elements of the tuple. Where such an element is of integer type, it will be stored directly within the vector. Otherwise, if the element is of a string type, the index of that string within the associated symbol table will be stored instead. The tuple also stores the index of some "current" element, referred to as its position. The constructor initially sets this position to the first (zeroth) element of the tuple, while subsequent methods of this class use that position for element access and modification.
r | Relation pointer pointing to a relation |
Definition at line 480 of file SouffleInterface.h.
|
inline |
Constructor.
Tuples are constructed here by passing a tuple. The relation to which the passed tuple belongs to will be stored. The array of the passed tuple, which stores the elements will be stroed. The pos will be set to be the same as the pos of passed tuple. belongs to.
Reference | to a tuple object. |
Definition at line 493 of file SouffleInterface.h.
|
inline |
Iterator for direct access to tuple's data.
Definition at line 677 of file SouffleInterface.h.
References souffle::Relation::getArity(), and relation.
|
inline |
Get the reference to the relation to which the tuple belongs.
Definition at line 505 of file SouffleInterface.h.
|
inline |
Set the "current element" of the tuple to the given string, then increment the index giving the current element.
str | Symbol to be added (std::string) |
Definition at line 565 of file SouffleInterface.h.
References souffle::Relation::getAttrType(), pos, relation, and size().
Set the "current element" of the tuple to the given float, then increment the index giving the current element.
float | float to be added |
Definition at line 608 of file SouffleInterface.h.
References souffle::Relation::getAttrType(), souffle::Relation::getSymbolTable(), pos, relation, souffle::SymbolTable::resolve(), size(), and str.
Set the "current element" of the tuple to the given int, then increment the index giving the current element.
integer | Integer to be added |
Definition at line 579 of file SouffleInterface.h.
|
inline |
Set the "current element" of the tuple to the given uint, then increment the index giving the current element.
uint | Unsigned number to be added |
Definition at line 594 of file SouffleInterface.h.
References souffle::Relation::getAttrType(), pos, souffle::ramBitCast(), relation, and size().
Get the "current element" of the tuple as a float, then increment the index giving the current element.
ramFloat | Float to be loaded from the tuple |
Definition at line 665 of file SouffleInterface.h.
Get the "current element" of the tuple as a int, then increment the index giving the current element.
integer | Integer to be loaded from the tuple |
Definition at line 636 of file SouffleInterface.h.
|
inline |
Get the "current element" of the tuple as a unsigned, then increment the index giving the current element.
uint | Unsigned number to be loaded from the tuple |
Definition at line 651 of file SouffleInterface.h.
References souffle::Relation::getAttrType(), pos, relation, and size().
|
inline |
Get the "current element" of the tuple as a string, then increment the index giving the current element.
str | Symbol to be loaded from the tuple(std::string) |
Definition at line 622 of file SouffleInterface.h.
References souffle::Relation::getAttrType(), pos, relation, and size().
|
inline |
Overload the operator [].
Direct access to tuple elements via index and return the element in idx position of a tuple.
TODO (Honghyw) : This interface should be hidden and only be used by friendly classes such as iterators; users should not use this interface.
idx | This is the idx of element in a tuple (size_t). |
Definition at line 531 of file SouffleInterface.h.
|
inline |
Overload the operator [].
Direct access to tuple elements via index and Return the element in idx position of a tuple. The returned element can not be changed.
TODO (Honghyw) : This interface should be hidden and only be used by friendly classes such as iterators; users should not use this interface.
idx | This is the idx of element in a tuple (size_t). |
Definition at line 547 of file SouffleInterface.h.
References pos.
|
inline |
Reset the index giving the "current element" of the tuple to zero.
Definition at line 554 of file SouffleInterface.h.
References souffle::Relation::getAttrType(), souffle::Relation::getSymbolTable(), souffle::SymbolTable::lookup(), pos, relation, size(), and str.
|
inline |
Return the number of elements in the tuple.
Definition at line 514 of file SouffleInterface.h.
Referenced by operator<<(), operator>>(), and rewind().
|
private |
Dynamic array used to store the elements in a tuple.
Definition at line 452 of file SouffleInterface.h.
const RamDomain* souffle::tuple::data = nullptr |
Allows printing using WriteStream.
Definition at line 498 of file SouffleInterface.h.
Referenced by souffle::interpreter::Engine::execute(), and souffle::interpreter::RelInterface::RelInterface().
|
private |
pos shows what the current position of a tuple is.
Initially, pos is 0 meaning we are at the head of the tuple. If we have an empty tuple and try to insert things, pos lets us know where to insert the element. After the element is inserted, pos will be incremented by 1. If we have a tuple with content, pos lets us know where to read the element. After we have read one element, pos will be incremented by 1. pos also helps to make sure we access an insert a tuple within the bound by making sure pos never exceeds the arity of the relation.
Definition at line 463 of file SouffleInterface.h.
Referenced by operator<<(), operator>>(), operator[](), and rewind().
|
private |
The relation to which the tuple belongs.
Definition at line 447 of file SouffleInterface.h.
Referenced by begin(), operator<<(), operator>>(), and rewind().